Normally when developing simple code there is no need to modify
- module/2,3 public list (think export list).
- use_module/2 import list.
When developing more structured code the public list and import list often need modifications. Once a modification is made to either I find that I have to run halt/0
then start a new instance of the top level so that the database is clean. After starting the top level, the typical scenario to check the updated export and/or import list is to consult the source code, which runs check/0. After the load is successful with no errors, I run the test cases which must be done manually, e.g.
Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.4-19-gefb65916d)
?- working_directory(_,'C:/Users/Groot/Documents').
true.
?- [rfc3986].
true.
?- run_tests.
% PL-Unit: rfc3986 ...... done
% PL-Unit: rfc5234 ...... done
% All 12 tests passed
true.
Questions
-
Is running halt/0 and starting a new top level required to get a clean database? (I recall a similar question being asked but can not find it).
-
Is there a way to get the test to run automatically after consult? In looking at set_test_options/1 for run it seems such an option for
run
is needed. As noted, for simple code themake
option works nicely, I don’t know all of the scenarios for needing to run the test upon consulting right after starting a top level so can’t think of a name to suggest for the option, but having the option would be nice.I also tried adding
:- run_tests.
separately to the source code file and then the test file, but the sequencing was wrong. It seems the code was not fully loaded before the test were run which resulted in errors.