Debian Codegraph @

tests/run_all_unit_tests.m

raw
1 % Copyright © 2013-2025 Dynare Team
2 %
3 % This file is part of Dynare.
4 %
5 % Dynare is free software: you can redistribute it and/or modify
6 % it under the terms of the GNU General Public License as published by
7 % the Free Software Foundation, either version 3 of the License, or
8 % (at your option) any later version.
9 %
10 % Dynare is distributed in the hope that it will be useful,
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 % GNU General Public License for more details.
14 %
15 % You should have received a copy of the GNU General Public License
16 % along with Dynare. If not, see <https://www.gnu.org/licenses/>.
17
18 source_dir = getenv('source_root');
19 addpath([source_dir filesep 'tests' filesep 'utils']);
20 matlab_dir = [source_dir filesep 'matlab'];
21 addpath(matlab_dir);
22
23 dynare_config();
24
25 if isoctave
26 load_octave_packages
27 end
28
29 mlist = get_directory_description(matlab_dir);
30
31 % Under Octave, do not run tests under matlab/missing/stats/
32 % Also skip load_m_data_file_legacy.m: it fails in the first test, but
33 % this is impossible to reproduce outside the runners.
34 if isoctave
35 mlist = mlist(~strncmp([matlab_dir filesep 'missing/stats/'], mlist, 24));
36 mlist = mlist(~strcmp([matlab_dir filesep 'load_m_file_data_legacy.m'], mlist));
37 end
38
39 failedtests = {};
40
41 for i = 1:length(mlist)
42 f = mlist{i};
43 if is_unit_test_available(f)
44 [check, info] = mtest(f);
45 for j = 1:size(info, 1)
46 if ~info{j,3}
47 failedtests{length(failedtests)+1} = [ mlist{i} '#' num2str(info{j,2}) ];
48 end
49 end
50 end
51 end
52
53 if ~isempty(failedtests)
54 fprintf('\n*** Failed tests: %s\n', failedtests{:})
55 end
56
57 quit(~isempty(failedtests))