The test suite for building SWI-Prolog is run by the command ctest
, which uses the file packages/cmake/PrologPackage.cmake
to run tests defined by
add_test(NAME "${SWIPL_PKG}:${test_name}"
COMMAND ${PROG_SWIPL} -p "foreign=${pforeign}"
-f none --no-packs -s ${test_source}
-g "${test_goal}"
-t halt)
Unfortunately, this doesn’t catch syntax errors in the tests, as demonstrated here (outside the ctest
framework, because I’m working in a separate module:
$ swipl "-p" "foreign=" "-f" "none" "--no-packs" "-s" test_protobufs.pl "-g" "test_protobufs" "-t" "halt" ; echo $?
ERROR: /home/peter/src/contrib-protobufs/test_protobufs.pl:267:22: Syntax error: Operator expected
% PL-Unit: protobuf_message ....... done
% PL-Unit: protobuf_segment_convert ....... done
% All 14 tests passed
0
Question: is there an option to swipl
that will cause a failure if a file is loaded that has a syntax error?
By the way, here’s the same thing done using ctest
, by introducing a deliberate syntax error into the current source (which doesn’t use plunit
, so it produces different output):
$ ctest -R protobufs
Test project /home/peter/src/swipl-devel/build
Start 49: protobufs:protobufs
1/1 Test #49: protobufs:protobufs .............. Passed 0.18 sec
100% tests passed, 0 tests failed out of 1
Total Test time (real) = 0.19 sec
$ ctest -V -R protobufs
UpdateCTestConfiguration from :/home/peter/src/swipl-devel/build/DartConfiguration.tcl
UpdateCTestConfiguration from :/home/peter/src/swipl-devel/build/DartConfiguration.tcl
Test project /home/peter/src/swipl-devel/build
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 49
Start 49: protobufs:protobufs
49: Test command: /home/peter/src/swipl-devel/build/src/swipl "-p" "foreign=" "-f" "none" "--no-packs" "-s" "/home/peter/src/swipl-devel/packages/protobufs/test_protobufs.pl" "-g" "test_protobufs" "-t" "halt"
49: Test timeout computed to be: 10000000
49: ERROR: /home/peter/src/swipl-devel/packages/protobufs/test_protobufs.pl:308:5: Syntax error: Operator expected
49: Loading Google's Golden Wirestream (2.5.0)...OK
49: Unifying canned Golden Message with canned Golden Template...OK
49: Unifying canned Golden Message with Google's Golden Wirestream...OK
49: Parsing Google's Golden Wirestream to canned Golden Template...OK
49: Comparing canned Golden Message to parsed Golden Template...OK
49: Serializing canned Golden Message to Codes...OK
49: Comparing Google's Golden Wirestream to Codes...OK
49: Parsing Codes to canned Golden Template...OK
49: Comparing canned Golden Message to parsed Golden Template...OK
49: All tests passed.
1/1 Test #49: protobufs:protobufs .............. Passed 0.18 sec
The following tests passed:
protobufs:protobufs
100% tests passed, 0 tests failed out of 1
Total Test time (real) = 0.18 secc