Add unitary tests to testsuite

time-shift
Sébastien Villemot 2013-12-09 19:05:36 +01:00
parent b840af9fa5
commit 5f3d56c31a
2 changed files with 49 additions and 2 deletions

View File

@ -237,12 +237,12 @@ dsge-var/dsgevar_forward_estimated_lambda.o.trs: dsge-var/simul_hybrid.o.trs
# Matlab TRS Files
M_TRS_FILES = $(patsubst %.mod, %.m.trs, $(MODFILES))
M_TRS_FILES += run_block_byte_tests_matlab.m.trs run_reporting_test_matlab.m.trs
M_TRS_FILES += run_block_byte_tests_matlab.m.trs run_reporting_test_matlab.m.trs run_unitary_tests.m.trs
M_XFAIL_TRS_FILES = $(patsubst %.mod, %.m.trs, $(XFAIL_MODFILES))
# Octave TRS Files
O_TRS_FILES = $(patsubst %.mod, %.o.trs, $(MODFILES))
O_TRS_FILES += run_block_byte_tests_octave.o.trs run_reporting_test_octave.o.trs
O_TRS_FILES += run_block_byte_tests_octave.o.trs run_reporting_test_octave.o.trs run_unitary_tests.o.trs
O_XFAIL_TRS_FILES = $(patsubst %.mod, %.o.trs, $(XFAIL_MODFILES))
EXTRA_DIST = \

47
tests/run_unitary_tests.m Normal file
View File

@ -0,0 +1,47 @@
top_test_dir = getenv('TOP_TEST_DIR');
addpath(top_test_dir);
addpath([top_test_dir filesep '..' filesep 'matlab']);
dynare_config([], 0);
% Test Dynare Version
if ~strcmp(dynare_version(), getenv('DYNARE_VERSION'))
error('Incorrect version of Dynare is being tested')
end
mlist = get_directory_description('../matlab');
failedtests = {};
counter = 0;
for i = 1:length(mlist)
f = [top_test_dir filesep mlist{i} ];
if is_unitary_test_available(f)
[check, info] = mtest(f);
for j = 1:size(info, 1)
counter = counter + 1;
if ~info{j,3}
failedtests{length(failedtests)+1} = [ mlist{i} '#' num2str(info{j,2}) ];
end
end
end
end
cd(getenv('TOP_TEST_DIR'));
if isoctave
fid = fopen('run_unitary_tests.o.trs', 'w+');
else
fid = fopen('run_unitary_tests.m.trs', 'w+');
end
if length(failedtests) > 0
fprintf(fid,':test-result: FAIL\n');
fprintf(fid,':number-tests: %d\n', counter);
fprintf(fid,':number-failed-tests: %d\n', length(failedtests));
fprintf(fid,':list-of-failed-tests: %s\n', failedtests{:});
else
fprintf(fid,':test-result: PASS\n');
fprintf(fid,':number-tests: %d\n', counter);
fprintf(fid,':number-failed-tests: 0\n');
end
fclose(fid);
exit