run_unitary_tests.m 2.02 KB
Newer Older
Stéphane Adjemian's avatar
Stéphane Adjemian committed
1
function [report, time] = run_unitary_tests(listoffiles)
Stéphane Adjemian's avatar
Stéphane Adjemian committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

% Runs unitary tests defined in a collection of files.
%
% INPUTS 
%  - listoffiles [cell], The list of m files (with path) where the unitary tests are written.
%                This cell, with n elements, is the output of get_directory_description routine.
%
% OUTPUTS 
%  - report      [cell], Results of the unitary tests (n rows and 5 columns). Each row stores
%                the second output argument of mtest routine (info).
%  - time        [double], Current date and time as date vector.
%
%
% See also get_directory_description, mtest

% Copyright (C) 2013-2014 Dynare Team
Stéphane Adjemian's avatar
Stéphane Adjemian committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare.  If not, see <http://www.gnu.org/licenses/>.

report = {};
35
36
37

testcoverage = zeros(2,1);

Stéphane Adjemian's avatar
Stéphane Adjemian committed
38
39
skipline()

Stéphane Adjemian's avatar
Stéphane Adjemian committed
40
for f=1:length(listoffiles)
Stéphane Adjemian's avatar
Stéphane Adjemian committed
41
    if isempty(strfind(listoffiles{f},'.#'))
Stéphane Adjemian's avatar
Stéphane Adjemian committed
42
        if is_unitary_test_available(listoffiles{f})
43
            testcoverage(1) = testcoverage(1) + 1;
Stéphane Adjemian's avatar
Stéphane Adjemian committed
44
            [check, info] = mtest(listoffiles{f});
Stéphane Adjemian's avatar
Stéphane Adjemian committed
45
46
47
48
49
            if check
                disp(['***** Unitary tests in ' listoffiles{f} ' PASSED!'] )
            else
                disp(['***** Unitary tests in ' listoffiles{f} ' FAILED!'] )
            end
Stéphane Adjemian's avatar
Stéphane Adjemian committed
50
51
            report = [report; info];
        else
52
            testcoverage(2) = testcoverage(2) + 1;
Stéphane Adjemian's avatar
Stéphane Adjemian committed
53
54
55
56
        end
    end
end

57
58
59
60
61
atc = 100*testcoverage(1)/sum(testcoverage);

skipline(2)
disp(sprintf('Approximated test coverage is %s%%',num2str(atc)))

Stéphane Adjemian's avatar
Stéphane Adjemian committed
62
63
64
if nargout>1
    time = clock;
end