testmark-go

selfexercise.md

testexec selfexercise file🔗

We will run a script with some files provisioned:

body-a

The script is simple:

echo hello
ls

The output is unsurprising:

hello
a

We can make subtests which add more files:

body-b
ls
a
b

We can also affect the filesystem in subtests:

echo "body-c" > ./c
ls

Notice that this doesn't inherit the file "b" from the last test -- this is because they're siblings, so they each got a copy of the parent filesystem state.

a
c

If we make a subtest of that subtest, it also inherits a copy of those effects:

ls
cat ./c
a
c
body-c

Stdin can also be emulated:

this is stdin and will be echoed
cat - | sed 's/ is/ was/'  | sed s/will/should/
this was stdin and should be echoed

testexec/selfexercise.md · 1.4 KiB · 4d87fa095d