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
warningsto 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-warning=and related Prolog flags
on_warningthat can all have the values
status(continue as normal, but exit with status 1) and
halt(halt with status 1 on first error/warning).
halt/0 interprets the
on-error=status(and for warnings) to either call
halt(1). Directly calling halt/1 bypasses this.
-c filecompilation to set the default
status. 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).
silentprint_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.