As a followup to Automatic tests can succeed with syntax errors and similar topics raised in the past I’ve pushed a number of changes:
-
Add global and thread statistics/2 keys
errors
andwarnings
to count errors and warnings. This only counts errors and warnings printed using print_message/2 that are not intercepted using message_hook/3. -
Add an option
--on-error=
and--on-warning=
and related Prolog flagson_error
andon_warning
that can all have the valuesprint
(default),status
(continue as normal, but exit with status 1) andhalt
(halt with status 1 on first error/warning). -
halt/0 interprets the
on-error=status
(and for warnings) to either callhalt(0)
orhalt(1)
. Directly calling halt/1 bypasses this. -
Change
-c file
compilation to set the defaulton_error
tostatus
. This causes the system to load all code, check for errors and if there are no errors proceed with saving the state (and still report an error should some error message be printed). -
Use a
silent
print_message/2 at the end of compiling a file if loading the file causes an error or warning. Note that this also traps errors in initialization/1,2. -
Run all system tests with
--on-error=status
, so also syntax errors cause tests to fail.
By default everything remains compatible except for swipl -c file
returns non-zero exit state on an error and does not produce a saved state. Using swipl --on-error=print -c file
you get the old behavior.
I think this covers most scenarios. Please jump in if you see anything wrong with this.