Well, I started writing my dune files for these test cases, and… it feels a bit like a sadder version of Makefile, in fact.
For each command, I have to write a rule (action (with-stdout-to test1.log) (run ./script.sh test1.txt))
, plus (deps ./script.sh tool.exe test1.txt)
, then (targets test1.log test1.out1 test1.out2 test1.out3 ...)
. Then another rule for the test with a different script, and then the diff rules: (rule (alias runtest) (action (diff test1.log.expected test1.log))
, (rule (alias runtest) (action (diff test1.out1.expected test1.out1))
, etc…
Then, when adding a second test test2.log
, I have to copy everything, renaming test1.*
to test2.*
everywhere. So I get hundreds of lines of code, with lots of copy-paste.
I’d honestly prefer to use a Makefile at this point, since at least I’d have access to lots of macros and special variables and incantations. They would make it harder to read for neophytes, but minimizing the amount of repetition would actually improve readability and the ease of adding a new test case.
It seems I’m doing something wrong, and that I’m missing a cleverer way to do this testing…
By the way, I know I can save some deps
lines by using %{dep:/script.sh}
in the action
stanza, but I want to avoid them for a specific reason: whenever something goes wrong, and I have to re-run the test manually, one of the simplest ways to do so is to open the dune
file, copy-paste the command from it, and run it in the terminal. Adding the %{dep:}
syntax in the middle of the command line makes it impossible to do so. And because Dune outputs the diff command that failed, but not the command actually running the script, I cannot simply look at the terminal, see the original command, and copy-paste it to manually test it. Maybe there’s also a better way to do this…