This reminds me of Littlecheck [0], the test helper we use in fish [1].
The way that works is that you provide a script to be run in some interpreter (for our cases that's usually fish, but it can also be sh or python or ruby or whatever you want), and then you give the expected output in "#CHECK" and "#CHECKERR" (for stderr) comments, optionally with regexes.
So you can write your test as a script and compare the output.
So the hello world example from the article would be one file called "hello.sh":
#RUN: /bin/sh %s
cat hello.txt
#CHECK: hello world
And you'd run it with `littlecheck hello.sh`. Unmatched output is an error, so if `cat` errored out the test would fail. (the `#RUN` directive can also be a shebang line, but #RUN allows substitutions, so you can e.g. define the script runner).
The way that works is that you provide a script to be run in some interpreter (for our cases that's usually fish, but it can also be sh or python or ruby or whatever you want), and then you give the expected output in "#CHECK" and "#CHECKERR" (for stderr) comments, optionally with regexes.
So you can write your test as a script and compare the output.
So the hello world example from the article would be one file called "hello.sh":
And you'd run it with `littlecheck hello.sh`. Unmatched output is an error, so if `cat` errored out the test would fail. (the `#RUN` directive can also be a shebang line, but #RUN allows substitutions, so you can e.g. define the script runner).[0]:https://github.com/ridiculousfish/littlecheck [1]:https://fishshell.com/