CI systems including CMake CTest generally rely on integer return code to detect success (== 0) or failure (!= 0). For consistent return of error code for GNU Octave and Matlab, consider wrapping the testing script as in errorret.m
This script uses
fprintf(2, 'test message') to write to
stderr from Matlab / Octave.
For CI, note you should call Octave using
octave-cli --eval myscript
This is necessary for exit on
error, etc., since
octave runs interactively without forced exit.
where status is 0 for success and not 0 for failure is necessary. This works for GNU Octave and Matlab.
Without the technique above, here’s what can happen upon raising
error in a .m script:
octave-cli --eval "mytest()"returns non-zero error code
matlab -nojvm -r "mytest()"hangs at