So, I’ve got a little CLI (shell) wrapper that lets me invoke plunit to run the unit tests in a Prolog file like so (pltest
is the name of the script):
pltest myfile.pl
The script looks like this:
#!/bin/sh
# First argument is the Prolog file we want to test.
prolog_file="$1"
# - Load the prolog file as a script
# - Run `run_tests` as the main goal.
swipl -s "$prolog_file" -g 'initialization(run_tests, main).'
As you can tell, this is a very limited script, especially considering what run_tests
can do when invoked from the swipl
REPL. I hope it can be useful as a conversation starter. Does anybody else have their own personal script to run plunit from the command line, perhaps with more features than this one? Or perhaps one written in Prolog, so it doesn’t depend on a Unix shell? Who wants to share?
The reason for this question: I’d like to contribute a small ‘Running the test suite from the command line’ section to section 4 of the plunit
docs, and I think that my own script above is perhaps too simple.