%RUN_TESTS Run the full matlab.unittest suite and exit nonzero on failure.
%   Usage: matlab -batch "run_tests"
%   (add the analysis/matlab directory to the path first if it is not
%   already on it, e.g. matlab -batch "addpath('analysis/matlab'); run_tests")

thisDir = fileparts(mfilename('fullpath'));
results = runtests(fullfile(thisDir, 'tests'));
disp(results);

fprintf('PASS=%d FAIL=%d\n', sum([results.Passed]), sum([results.Failed]));

if any([results.Failed])
    error('run_tests:failed', 'One or more tests failed.');
end
