Removed matlab/utilities/tests subfolder.
parent
e6789a3707
commit
1c62420909
|
@ -1,101 +0,0 @@
|
|||
function str = build_report_summary(reportfile, printonscreen, mailreport)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
if isequal(nargin,1)
|
||||
printonscreen = 1;
|
||||
mailreport = 0;
|
||||
end
|
||||
|
||||
if nargin<3
|
||||
mailreport = 0;
|
||||
else
|
||||
if ischar(mailreport)
|
||||
mailto = mailreport;
|
||||
mailreport = 1;
|
||||
fid = fopen('~/.matlab-send-report');
|
||||
server = fgetl(fid);
|
||||
fclose(fid);
|
||||
fprintf('\n\n');
|
||||
disp('Send report...')
|
||||
system(['scp ' reportfile ' ' server]);
|
||||
system(['scp ' reportfile(1:end-3) 'log ' server]);
|
||||
else
|
||||
if ~isequal(mailreport,0)
|
||||
error('build_report_summary:: Third argument must be an adress email!')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
reportfilecontent = load(reportfile);
|
||||
reportcell = reportfilecontent.report;
|
||||
gitinfo = reportfilecontent.gitinfo;
|
||||
gitlastcommithash = reportfilecontent.gitlastcommithash;
|
||||
|
||||
str = 'Hi,';
|
||||
str = char(str,'');
|
||||
str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be found at:');
|
||||
str = char(str,'');
|
||||
str = char(str,'');
|
||||
str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile]);
|
||||
str = char(str,'');
|
||||
str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile(1:end-3) 'log']);
|
||||
str = char(str,'');
|
||||
str = char(str,gitinfo(1,:));
|
||||
str = char(str,gitinfo(2,:));
|
||||
str = char(str,'');
|
||||
str = char(str,'');
|
||||
str = char(str,['===========================']);
|
||||
str = char(str,'DYNARE/MATLAB UNITARY TESTS');
|
||||
str = char(str,'===========================');
|
||||
str = char(str,['| TOTAL: ' int2str(size(reportcell,1))]);
|
||||
str = char(str,['| PASS: ' int2str(length(find(cell2mat(reportcell(:,3)))))]);
|
||||
str = char(str,['| FAIL: ' int2str(length(find(~cell2mat(reportcell(:,3)))))]);
|
||||
str = char(str,'|');
|
||||
str = char(str,'| LIST OF FAILED TESTS:');
|
||||
for i=1:size(reportcell,1)
|
||||
if ~reportcell{i,3}
|
||||
str = char(str,['| * ' reportcell{i,1} ' (test #' int2str(reportcell{i,2}) '{' strrep(int2str(transpose(find(~reportcell{i,4}))),' ',',') '})']);
|
||||
end
|
||||
end
|
||||
|
||||
if printonscreen
|
||||
skipline(2);
|
||||
disp(str)
|
||||
skipline(2);
|
||||
end
|
||||
|
||||
if mailreport
|
||||
if exist('~/.matlab-send-mail-info','file')
|
||||
fid = fopen('~/.matlab-send-mail-info','r');
|
||||
else
|
||||
disp(['build_report_summary:: I Cannot send the report to ' mailto ' because the sender and the smtp server are not defined!'])
|
||||
disp([' You probably need to add a ''.matlab-send-mail-info'' in your root directory...'])
|
||||
return
|
||||
end
|
||||
setpref('Internet','SMTP_Server',fgetl(fid));
|
||||
setpref('Internet','SMTP_Username',fgetl(fid));
|
||||
setpref('Internet','E_mail',fgetl(fid));
|
||||
setpref('Internet','SMTP_Passeword',fgetl(fid));
|
||||
fclose(fid);
|
||||
STR = [deblank(str(1,:))];
|
||||
for i=2:size(str,1)
|
||||
STR = [STR 10 deblank(str(i,:)) ];
|
||||
end
|
||||
sendmail(mailto,'Dynare/Matlab unitary tests',STR);
|
||||
end
|
|
@ -1,84 +0,0 @@
|
|||
function dynTest(fun,dynare_path)
|
||||
|
||||
%@info:
|
||||
%! @deftypefn {Function File} dynTest (@var{fun})
|
||||
%! @anchor{dynTest}
|
||||
%! @sp 1
|
||||
%! Tests matlab/octave routine @var{fun}.m.
|
||||
%! @sp 2
|
||||
%!
|
||||
%! @strong{Inputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item fun
|
||||
%! string, name of the matlab/octave routine to be tested.
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%!
|
||||
%! @strong{Outputs}
|
||||
%! @sp 1
|
||||
%! None
|
||||
%! @sp 2
|
||||
%!
|
||||
%! @strong{This function is called by:}
|
||||
%! @sp 1
|
||||
%! @ref{internals}, @ref{mroutines}
|
||||
%! @sp 2
|
||||
%!
|
||||
%! @strong{This function calls:}
|
||||
%! @sp 1
|
||||
%! @ref{mtest}
|
||||
%!
|
||||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2011-2012 Dynare Team
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
|
||||
|
||||
original_directory = pwd();
|
||||
|
||||
[pathstr1, name1, ext1] = fileparts(fun);
|
||||
|
||||
pathstr1 = [original_directory filesep pathstr1];
|
||||
|
||||
cd([dynare_path filesep '..' filesep 'tests']);
|
||||
|
||||
mex_flag = 0;
|
||||
if exist(name1)==3
|
||||
mex_flag = 1;
|
||||
end
|
||||
|
||||
class_flag = 0;
|
||||
if ~isempty(strfind(fun,'@')) || ~isempty(strfind(which(name1),'@'))
|
||||
class_flag = 1;
|
||||
end
|
||||
|
||||
check = mtest(name1,pathstr1);
|
||||
|
||||
if check
|
||||
if mex_flag
|
||||
disp(['Succesfull test(s) for ' name1 ' mex file!'])
|
||||
elseif class_flag
|
||||
disp(['Succesfull test(s) for ' name1 ' method!'])
|
||||
else
|
||||
disp(['Succesfull test(s) for ' name1 ' routine!'])
|
||||
end
|
||||
end
|
||||
|
||||
cd(original_directory);
|
|
@ -1,63 +0,0 @@
|
|||
function t = dyn_assert(A,B,tol)
|
||||
% This function tests the equality of two objects.
|
||||
|
||||
% Copyright (C) 2011-2012 Dynare Team
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
|
||||
|
||||
if ( (nargin<3) || isempty(tol) )
|
||||
use_isequal_matlab_builtin = 1;
|
||||
else
|
||||
use_isequal_matlab_builtin = 0;
|
||||
end
|
||||
|
||||
[nA,mA] = size(A);
|
||||
[nB,mB] = size(B);
|
||||
|
||||
if nA-nB
|
||||
error('assert:: Dimensions of compared objects A and B don''t match!')
|
||||
end
|
||||
|
||||
if mA-mB
|
||||
error('assert:: Dimensions of compared objects A and B don''t match!')
|
||||
end
|
||||
|
||||
if isstruct(B) && ~isstruct(A)
|
||||
error('assert:: Compared objects are not of the same type!')
|
||||
end
|
||||
|
||||
if iscell(B) && ~iscell(A)
|
||||
error('assert:: Compared objects are not of the same type!')
|
||||
end
|
||||
|
||||
if use_isequal_matlab_builtin
|
||||
t = isequal(A,B);
|
||||
if ~t
|
||||
t = isequalwithequalnans(A,B);
|
||||
end
|
||||
else
|
||||
t = 1;
|
||||
if ~(isstruct(B) || iscell(B))
|
||||
if max(abs(A(:)-B(:)))>tol
|
||||
t = 0;
|
||||
end
|
||||
else
|
||||
% not yet implemented
|
||||
t = NaN;
|
||||
end
|
||||
end
|
|
@ -1,34 +0,0 @@
|
|||
function flist = get_directory_description(basedir)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
dd = dir(basedir);
|
||||
flist = {};
|
||||
file = 1;
|
||||
|
||||
for f=1:length(dd)
|
||||
if ~(isequal(dd(f).name,'.') || isequal(dd(f).name,'..'))
|
||||
if dd(f).isdir
|
||||
r = get_directory_description([ basedir filesep dd(f).name]);
|
||||
flist = { flist{:} r{:} };
|
||||
else
|
||||
flist{length(flist)+1} = [basedir filesep dd(f).name];
|
||||
end
|
||||
file = file + 1;
|
||||
end
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
function info = is_unitary_test_available(fun)
|
||||
|
||||
%@info:
|
||||
%! @deftypefn {Function File} {@var{info} =} is_unitary_test_available (@var{fun})
|
||||
%! @anchor{is_unitary_test_available}
|
||||
%! @sp 1
|
||||
%! Tests if matlab/octave routine @var{fun} has unitary tests.
|
||||
%! @sp 2
|
||||
%! @strong{Inputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item fun
|
||||
%! string, name of the matlab/octave routine to be tested.
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @strong{Outputs}
|
||||
%! @sp 1
|
||||
%! @table @ @var
|
||||
%! @item info
|
||||
%! Integer scalar equal to one if unitary tests are available, zero otherwise.
|
||||
%! @end table
|
||||
%! @sp 2
|
||||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
info = 0;
|
||||
|
||||
fid = fopen(fun,'r');
|
||||
first_line = fgetl(fid);
|
||||
fclose(fid);
|
||||
|
||||
if strfind(first_line,'% --*-- Unitary tests --*--')
|
||||
info = 1;
|
||||
end
|
|
@ -1,137 +0,0 @@
|
|||
function [check, info] = mtest(fname, fpath)
|
||||
% Extract test sections from matlab's routine executes the test and report errors.
|
||||
|
||||
% Copyright (C) 2011-2013 Dynare Team
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
|
||||
|
||||
% Default answer (no problem).
|
||||
check = 1;
|
||||
|
||||
% Open the matlab file.
|
||||
if nargin<2 || isempty(fpath)
|
||||
if nargout<2
|
||||
error('mtest:: Wrong calling sequence!')
|
||||
end
|
||||
% The full path to the matlab routine (with extension) is given.
|
||||
fid = fopen(fname,'r');
|
||||
[junk, FNAME, vessel] = fileparts(fname);
|
||||
else
|
||||
fid = fopen([fpath '/' fname '.m'],'r');
|
||||
FNAME = fname;
|
||||
end
|
||||
|
||||
% Read the matlab file.
|
||||
file = textscan(fid,'%s','delimiter','\n');
|
||||
file = file{1};
|
||||
|
||||
% Close the matlab file.
|
||||
fclose(fid);
|
||||
|
||||
% Locate the test blocks.
|
||||
b1 = find(strncmp(file,'%@test:',7))+1;
|
||||
b2 = find(strncmp(file,'%@eof:',6))-1;
|
||||
nn = length(b2);
|
||||
|
||||
if length(b1)-length(b2)
|
||||
error('test:: There is a problem with the test blocks definition!')
|
||||
end
|
||||
|
||||
% Initialize the second output if necessary.
|
||||
if nargout>1
|
||||
% First column name of the tested routine.
|
||||
% Second column number of the unitary test.
|
||||
% Third column status of the unitary test (0 if the test fails, 1 otherwise)
|
||||
% Fourth column details about the failure (vector of integers)
|
||||
% Fifth column elapsed time in seconds (cpu time).
|
||||
info = cell(nn,5);
|
||||
end
|
||||
|
||||
% Perform the tests.
|
||||
for i=1:nn
|
||||
if nargout>1
|
||||
info(i,1) = {fname};
|
||||
info(i,2) = {i};
|
||||
end
|
||||
% Write the temporary test routine.
|
||||
tid = fopen([FNAME '_test_' int2str(i) '.m'],'w');
|
||||
fprintf(tid,['function [T,t,LOG] = ' FNAME '_test_' int2str(i) '()\n']);
|
||||
fprintf(tid,['try\n']);
|
||||
for j=b1(i):b2(i)
|
||||
str = sprintf('%s \n',file{j}(4:end));
|
||||
str = regexprep(str, '%', '%%');
|
||||
fprintf(tid,str);
|
||||
end
|
||||
fprintf(tid,['LOG = NaN;\n']);
|
||||
if isoctave
|
||||
fprintf(tid,'catch\n');
|
||||
fprintf(tid,'exception = lasterror;\n');
|
||||
fprintf(tid, 'LOG = ''%s'';\n','The Log output is not available with Octave!');
|
||||
else
|
||||
fprintf(tid,'catch exception\n');
|
||||
fprintf(tid,['LOG = getReport(exception,''extended'');\n']);
|
||||
end
|
||||
fprintf(tid,['T = NaN;\n']);
|
||||
fprintf(tid,['t = NaN;\n']);
|
||||
fprintf(tid,['end\n']);
|
||||
fclose(tid);
|
||||
% Call the temporary test routine.
|
||||
init = cputime;
|
||||
[TestFlag,TestDetails,LOG] = feval([FNAME '_test_' int2str(i)]);
|
||||
time = cputime-init;
|
||||
if isnan(TestFlag)
|
||||
fprintf(['\n'])
|
||||
fprintf(['Call to ' FNAME ' test routine n°' int2str(i) ' failed (' datestr(now) ')!\n'])
|
||||
fprintf(['\n'])
|
||||
if ~isoctave
|
||||
disp(LOG)
|
||||
end
|
||||
check = 0;
|
||||
if nargout>1
|
||||
info(i,3) = {0};
|
||||
end
|
||||
continue
|
||||
end
|
||||
if ~TestFlag
|
||||
if nargout>1
|
||||
info(i,3) = {0};
|
||||
tmp = ones(length(TestDetails),1);
|
||||
end
|
||||
fprintf(['Test n°' int2str(i) ' for routine ' FNAME ' failed (' datestr(now) ')!\n']);
|
||||
for j=1:length(TestDetails)
|
||||
if ~TestDetails(j)
|
||||
if nargout>1
|
||||
tmp(j) = 0;
|
||||
end
|
||||
fprintf(['Output argument n°' int2str(j) ' didn''t give the expected result.\n']);
|
||||
end
|
||||
end
|
||||
if nargout>1
|
||||
info(i,4) = {tmp};
|
||||
info(i,5) = {NaN};
|
||||
end
|
||||
check = 0;
|
||||
else
|
||||
if nargout>1
|
||||
info(i,3) = {1};
|
||||
info(i,4) = {ones(length(TestDetails),1)};
|
||||
info(i,5) = {time};
|
||||
end
|
||||
delete([FNAME '_test_' int2str(i) '.m'])
|
||||
end
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
function [report, time] = run_unitary_tests(listoffiles)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% 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 = {};
|
||||
|
||||
for f=1:length(listoffiles)
|
||||
if isequal(listoffiles{f}(end-1:end),'.m') && isempty(strfind(listoffiles{f},'.#'))
|
||||
if is_unitary_test_available(listoffiles{f})
|
||||
disp(['***** Process unitary tests in ' listoffiles{f}])
|
||||
[check, info] = mtest(listoffiles{f});
|
||||
report = [report; info];
|
||||
else
|
||||
disp(['Booh! No unitary tests available in ' listoffiles{f}])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if nargout>1
|
||||
time = clock;
|
||||
end
|
|
@ -1,47 +0,0 @@
|
|||
function report = run_unitary_tests_in_directory(dirname,savereport,printreport,sendreport)
|
||||
|
||||
% Copyright (C) 2013 Dynare Team
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
system('git show --pretty=format:"Last commit %H by %an, %ar %n-> %s" HEAD > git.info');
|
||||
system('git rev-parse HEAD > git.last-commit-hash');
|
||||
|
||||
fid = fopen('git.info');
|
||||
gitinfo = fgetl(fid);
|
||||
gitinfo = char(gitinfo,fgetl(fid));
|
||||
fclose(fid);
|
||||
|
||||
fid = fopen('git.last-commit-hash');
|
||||
gitlastcommithash = fgetl(fid);
|
||||
fclose(fid);
|
||||
|
||||
matlabverion = version;
|
||||
platform = computer;
|
||||
|
||||
listoffiles = get_directory_description(dirname);
|
||||
|
||||
diary(['report-' gitlastcommithash '.log'] )
|
||||
[report, time] = run_unitary_tests(listoffiles)
|
||||
diary off
|
||||
|
||||
if nargin>1 && savereport>0
|
||||
save(['report-' gitlastcommithash '.mat'],'report','time','gitinfo','gitlastcommithash','matlabverion','platform');
|
||||
end
|
||||
|
||||
if nargin>2
|
||||
build_report_summary(['report-' gitlastcommithash '.mat'], printreport, sendreport);
|
||||
end
|
Loading…
Reference in New Issue