From c7f688249d3c21e9e861ecf5262a96187dbde964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 3 Jul 2013 17:03:00 +0200 Subject: [PATCH 01/34] Added new routine that returns all the files available in a folder and its subfolders. --- .../tests/get_directory_description.m | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 matlab/utilities/tests/get_directory_description.m diff --git a/matlab/utilities/tests/get_directory_description.m b/matlab/utilities/tests/get_directory_description.m new file mode 100644 index 000000000..790cde771 --- /dev/null +++ b/matlab/utilities/tests/get_directory_description.m @@ -0,0 +1,33 @@ +function files = 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 . + +dd = dir(basedir); +filelist = {}; +file = 1; + +for f=1:length(dd) + if ~(isequal(dd(f).name,'.') || isequal(dd(f).name,'..')) + if dd(f).isdir + filelist(file) = { get_directory_description([ basedir filesep dd(f).name]) }; + else + filelist(file) = { [basedir filesep dd(f).name] }; + end + file = file + 1; + end +end \ No newline at end of file From 71e9081d24b03aefd91df83e9fbeb0d7f730057b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 3 Jul 2013 17:04:29 +0200 Subject: [PATCH 02/34] Added a routine that tests if unitary tests are available in a matlab routine. --- .../tests/is_unitary_test_available.m | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 matlab/utilities/tests/is_unitary_test_available.m diff --git a/matlab/utilities/tests/is_unitary_test_available.m b/matlab/utilities/tests/is_unitary_test_available.m new file mode 100644 index 000000000..e4e34e08d --- /dev/null +++ b/matlab/utilities/tests/is_unitary_test_available.m @@ -0,0 +1,52 @@ +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 . + +info = 0; + +fid = fopen(fun,'r'); +first_line = fgetl(fid); + +if strcmp(first_line,'% --*-- Unitary tests --*--') + info = 1; +end + +fclose(fid); \ No newline at end of file From a6043ee628badaf775abbf5e8ce6d964279296ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 3 Jul 2013 18:14:11 +0200 Subject: [PATCH 03/34] Fixed typo. --- matlab/utilities/tests/get_directory_description.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/matlab/utilities/tests/get_directory_description.m b/matlab/utilities/tests/get_directory_description.m index 790cde771..674af2f8a 100644 --- a/matlab/utilities/tests/get_directory_description.m +++ b/matlab/utilities/tests/get_directory_description.m @@ -1,4 +1,4 @@ -function files = get_directory_description(basedir) +function flist = get_directory_description(basedir) % Copyright (C) 2013 Dynare Team % @@ -18,15 +18,15 @@ function files = get_directory_description(basedir) % along with Dynare. If not, see . dd = dir(basedir); -filelist = {}; +flist = {}; file = 1; for f=1:length(dd) if ~(isequal(dd(f).name,'.') || isequal(dd(f).name,'..')) if dd(f).isdir - filelist(file) = { get_directory_description([ basedir filesep dd(f).name]) }; + flist(file) = { get_directory_description([ basedir filesep dd(f).name]) }; else - filelist(file) = { [basedir filesep dd(f).name] }; + flist(file) = { [basedir filesep dd(f).name] }; end file = file + 1; end From b4a8155f5bfda1a20becad1cf22a856883d7eea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 11:52:07 +0200 Subject: [PATCH 04/34] Adapted mtest routine so that it can be used in the matlab routines test suite. mtest can now return more informations about the unitary tests. --- matlab/utilities/tests/mtest.m | 43 +++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/matlab/utilities/tests/mtest.m b/matlab/utilities/tests/mtest.m index f12e4d9ff..9a51c6746 100644 --- a/matlab/utilities/tests/mtest.m +++ b/matlab/utilities/tests/mtest.m @@ -1,7 +1,7 @@ -function check = mtest(fname,fpath) +function [check, info] = mtest(fname, fpath) % Extract test sections from matlab's routine executes the test and report errors. -% Copyright (C) 2011-2012 Dynare Team +% Copyright (C) 2011-2013 Dynare Team % % This file is part of Dynare. % @@ -24,7 +24,12 @@ function check = mtest(fname,fpath) check = 1; % Open the matlab file. -fid = fopen([fpath '/' fname '.m'],'r'); +if isempty(fpath) + % The full path to the matlab routine (with extension) is given. + fid = fopen(fname,'r'); +else + fid = fopen([fpath '/' fname '.m'],'r'); +end % Read the matlab file. file = textscan(fid,'%s','delimiter','\n'); @@ -42,8 +47,22 @@ 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,4); +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']); @@ -60,24 +79,42 @@ for i=1:nn 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']) disp(LOG) 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 + info(i,4) = {tmp}; 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 \ No newline at end of file From c83b047aa0479c809938adc784d01ffab8a07b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 11:54:27 +0200 Subject: [PATCH 05/34] If mtest is called with one input then it must return two arguments (with detailed information about unitary tests). --- matlab/utilities/tests/mtest.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matlab/utilities/tests/mtest.m b/matlab/utilities/tests/mtest.m index 9a51c6746..f447365bb 100644 --- a/matlab/utilities/tests/mtest.m +++ b/matlab/utilities/tests/mtest.m @@ -24,7 +24,10 @@ function [check, info] = mtest(fname, fpath) check = 1; % Open the matlab file. -if isempty(fpath) +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'); else From fcef6e83b537cd9cb44dc6198ed3acba0239f748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 14:10:17 +0200 Subject: [PATCH 06/34] Fixed bug related to the name of the tested matlab routine. --- matlab/utilities/tests/mtest.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/matlab/utilities/tests/mtest.m b/matlab/utilities/tests/mtest.m index f447365bb..3cd153c0c 100644 --- a/matlab/utilities/tests/mtest.m +++ b/matlab/utilities/tests/mtest.m @@ -30,8 +30,10 @@ if nargin<2 || isempty(fpath) 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. @@ -67,8 +69,8 @@ for i=1:nn 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']); + 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 = file{j}; @@ -83,11 +85,11 @@ for i=1:nn fclose(tid); % Call the temporary test routine. init = cputime; - [TestFlag,TestDetails,LOG] = feval([fname '_test_' int2str(i)]); + [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(['Call to ' FNAME ' test routine n°' int2str(i) ' failed (' datestr(now) ')!\n']) fprintf(['\n']) disp(LOG) check = 0; @@ -101,7 +103,7 @@ for i=1:nn info(i,3) = {0}; tmp = ones(length(TestDetails),1); end - fprintf(['Test n°' int2str(i) ' for routine ' fname ' failed (' datestr(now) ')!\n']); + fprintf(['Test n°' int2str(i) ' for routine ' FNAME ' failed (' datestr(now) ')!\n']); for j=1:length(TestDetails) if ~TestDetails(j) if nargout>1 @@ -118,6 +120,6 @@ for i=1:nn info(i,4) = {ones(length(TestDetails),1)}; info(i,5) = {time}; end - delete([fname '_test_' int2str(i) '.m']) + delete([FNAME '_test_' int2str(i) '.m']) end end \ No newline at end of file From 479cf5bf8b0fed731f259db806b317b9fd9dd6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 14:36:31 +0200 Subject: [PATCH 07/34] Added routines to run matlab's unitary tests. --- matlab/utilities/tests/run_unitary_tests.m | 38 +++++++++++++++++++ .../tests/run_unitary_tests_in_directory.m | 21 ++++++++++ 2 files changed, 59 insertions(+) create mode 100644 matlab/utilities/tests/run_unitary_tests.m create mode 100644 matlab/utilities/tests/run_unitary_tests_in_directory.m diff --git a/matlab/utilities/tests/run_unitary_tests.m b/matlab/utilities/tests/run_unitary_tests.m new file mode 100644 index 000000000..ca435fd5f --- /dev/null +++ b/matlab/utilities/tests/run_unitary_tests.m @@ -0,0 +1,38 @@ +function report = 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 . + +report = {}; + +for f=1:length(listoffiles) + if iscell(listoffiles{f}) + info = run_all_unitary_tests(listoffiles{f}); + report = [report; info]; + else + if isequal(listoffiles{f}(end-1:end),'.m') && ~isequal(listoffiles{f}(1:2),'.#') + if is_unitary_test_available(listoffiles{f}) + fprintf(['***** Process unitary tests in ' listoffiles{f} ' ... ']) + [check, info] = mtest(listoffiles{f}); + report = [report; info]; + fprintf(['Done!\n']) + else + disp(['Booh! No unitay tests available in ' listoffiles{f}]) + end + end + end +end \ No newline at end of file diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m new file mode 100644 index 000000000..34c17169c --- /dev/null +++ b/matlab/utilities/tests/run_unitary_tests_in_directory.m @@ -0,0 +1,21 @@ +function report = run_unitary_tests_in_directory(dirname) + +% 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 . + +listoffiles = get_directory_description(dirname); +report = run_unitary_tests(listoffiles); \ No newline at end of file From 45d7568712fe23947f2fe39b07c841535e1a4c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 14:38:22 +0200 Subject: [PATCH 08/34] Fixed typo. --- matlab/@dynSeries/vertcat.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/@dynSeries/vertcat.m b/matlab/@dynSeries/vertcat.m index 53eb4774d..2bd32419d 100644 --- a/matlab/@dynSeries/vertcat.m +++ b/matlab/@dynSeries/vertcat.m @@ -30,7 +30,7 @@ function a = vertcat(varargin) %! @end deftypefn %@eod: -% Copyright (C) 2011-2013 Dynare Team +% Copyright (C) 2013 Dynare Team % % This file is part of Dynare. % From 1657111fa8f247f707ad0c0a8328c53a929ee674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 15:00:24 +0200 Subject: [PATCH 09/34] Added tags for unitary tests. --- matlab/@dynDate/colon.m | 1 + matlab/@dynDate/dynDate.m | 1 + matlab/@dynDate/eq.m | 1 + matlab/@dynDate/format.m | 1 + matlab/@dynDate/ge.m | 1 + matlab/@dynDate/gt.m | 1 + matlab/@dynDate/isempty.m | 1 + matlab/@dynDate/le.m | 1 + matlab/@dynDate/lt.m | 1 + matlab/@dynDate/max.m | 1 + matlab/@dynDate/min.m | 1 + matlab/@dynDate/minus.m | 1 + matlab/@dynDate/ne.m | 1 + matlab/@dynDate/plus.m | 1 + matlab/@dynDate/subsref.m | 1 + matlab/@dynDate/uminus.m | 1 + matlab/@dynDate/uplus.m | 1 + matlab/@dynDates/append.m | 1 + matlab/@dynDates/dynDates.m | 1 + matlab/@dynDates/eq.m | 1 + matlab/@dynDates/intersect.m | 1 + matlab/@dynDates/isempty.m | 1 + matlab/@dynDates/minus.m | 1 + matlab/@dynDates/plus.m | 1 + matlab/@dynDates/pop.m | 1 + matlab/@dynDates/sort.m | 1 + matlab/@dynDates/subsref.m | 1 + matlab/@dynDates/union.m | 1 + matlab/@dynDates/unique.m | 1 + matlab/@dynSeries/align.m | 1 + matlab/@dynSeries/dynSeries.m | 1 + matlab/@dynSeries/eq.m | 1 + matlab/@dynSeries/extract.m | 1 + matlab/@dynSeries/horzcat.m | 1 + matlab/@dynSeries/insert.m | 1 + matlab/@dynSeries/lag.m | 1 + matlab/@dynSeries/merge.m | 1 + matlab/@dynSeries/minus.m | 1 + matlab/@dynSeries/mrdivide.m | 1 + matlab/@dynSeries/mtimes.m | 1 + matlab/@dynSeries/plus.m | 1 + matlab/@dynSeries/pop.m | 1 + matlab/@dynSeries/qdiff.m | 1 + matlab/@dynSeries/qgrowth.m | 1 + matlab/@dynSeries/rename.m | 1 + matlab/@dynSeries/save.m | 1 + matlab/@dynSeries/set_names.m | 1 + matlab/@dynSeries/subsasgn.m | 1 + matlab/@dynSeries/subsref.m | 1 + matlab/@dynSeries/tex_rename.m | 1 + matlab/@dynSeries/uminus.m | 1 + matlab/@dynSeries/vertcat.m | 1 + matlab/@dynSeries/ydiff.m | 2 +- matlab/@dynSeries/ygrowth.m | 1 + 54 files changed, 54 insertions(+), 1 deletion(-) diff --git a/matlab/@dynDate/colon.m b/matlab/@dynDate/colon.m index 5c6e22f66..9f794b1b1 100644 --- a/matlab/@dynDate/colon.m +++ b/matlab/@dynDate/colon.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function sp = colon(a,b) %@info: diff --git a/matlab/@dynDate/dynDate.m b/matlab/@dynDate/dynDate.m index e6af26bb5..22c1f71d2 100644 --- a/matlab/@dynDate/dynDate.m +++ b/matlab/@dynDate/dynDate.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function date = dynDate(a,b) %@info: diff --git a/matlab/@dynDate/eq.m b/matlab/@dynDate/eq.m index 64367e1d9..82edfb527 100644 --- a/matlab/@dynDate/eq.m +++ b/matlab/@dynDate/eq.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = eq(a,b) %@info: diff --git a/matlab/@dynDate/format.m b/matlab/@dynDate/format.m index df403148a..5258ba0ba 100644 --- a/matlab/@dynDate/format.m +++ b/matlab/@dynDate/format.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function p = format(date) %@info: diff --git a/matlab/@dynDate/ge.m b/matlab/@dynDate/ge.m index 05fa1850d..15cec1a6a 100644 --- a/matlab/@dynDate/ge.m +++ b/matlab/@dynDate/ge.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = ge(a,b) %@info: diff --git a/matlab/@dynDate/gt.m b/matlab/@dynDate/gt.m index c881b1942..0f2bde4d9 100644 --- a/matlab/@dynDate/gt.m +++ b/matlab/@dynDate/gt.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = gt(a,b) %@info: diff --git a/matlab/@dynDate/isempty.m b/matlab/@dynDate/isempty.m index ee90a40e3..df8c9adba 100644 --- a/matlab/@dynDate/isempty.m +++ b/matlab/@dynDate/isempty.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function b = isempty(a) %@info: diff --git a/matlab/@dynDate/le.m b/matlab/@dynDate/le.m index 14b198330..63e94d5fb 100644 --- a/matlab/@dynDate/le.m +++ b/matlab/@dynDate/le.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = le(a,b) %@info: diff --git a/matlab/@dynDate/lt.m b/matlab/@dynDate/lt.m index 0aef47153..e48eec784 100644 --- a/matlab/@dynDate/lt.m +++ b/matlab/@dynDate/lt.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = lt(a,b) %@info: diff --git a/matlab/@dynDate/max.m b/matlab/@dynDate/max.m index 451c050f6..196ff3248 100644 --- a/matlab/@dynDate/max.m +++ b/matlab/@dynDate/max.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = max(a,b) %@info: diff --git a/matlab/@dynDate/min.m b/matlab/@dynDate/min.m index 78c7281af..29dea5d74 100644 --- a/matlab/@dynDate/min.m +++ b/matlab/@dynDate/min.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = min(a,b) %@info: diff --git a/matlab/@dynDate/minus.m b/matlab/@dynDate/minus.m index 248cb679c..bebd9f7d1 100644 --- a/matlab/@dynDate/minus.m +++ b/matlab/@dynDate/minus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = minus(a,b) %@info: diff --git a/matlab/@dynDate/ne.m b/matlab/@dynDate/ne.m index d6ae7f1f1..d5b5585a5 100644 --- a/matlab/@dynDate/ne.m +++ b/matlab/@dynDate/ne.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = ne(a,b) %@info: diff --git a/matlab/@dynDate/plus.m b/matlab/@dynDate/plus.m index 51158612d..aaea7c680 100644 --- a/matlab/@dynDate/plus.m +++ b/matlab/@dynDate/plus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function c = plus(a,b) %@info: diff --git a/matlab/@dynDate/subsref.m b/matlab/@dynDate/subsref.m index 6186eb6f0..c70bf12c0 100644 --- a/matlab/@dynDate/subsref.m +++ b/matlab/@dynDate/subsref.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = subsref(A,S) %@info: diff --git a/matlab/@dynDate/uminus.m b/matlab/@dynDate/uminus.m index 814afe12e..02b9bb7db 100644 --- a/matlab/@dynDate/uminus.m +++ b/matlab/@dynDate/uminus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function b = uminus(a) %@info: diff --git a/matlab/@dynDate/uplus.m b/matlab/@dynDate/uplus.m index 054057215..c056d265b 100644 --- a/matlab/@dynDate/uplus.m +++ b/matlab/@dynDate/uplus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function b = uplus(a) %@info: diff --git a/matlab/@dynDates/append.m b/matlab/@dynDates/append.m index 651b95e0a..df0d52fa6 100644 --- a/matlab/@dynDates/append.m +++ b/matlab/@dynDates/append.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = append(dd,a) % append method for dynDates class. diff --git a/matlab/@dynDates/dynDates.m b/matlab/@dynDates/dynDates.m index 826b10fde..ceb5b521c 100644 --- a/matlab/@dynDates/dynDates.m +++ b/matlab/@dynDates/dynDates.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = dynDates(varargin) %@info: diff --git a/matlab/@dynDates/eq.m b/matlab/@dynDates/eq.m index 7639ca1a2..567c087f0 100644 --- a/matlab/@dynDates/eq.m +++ b/matlab/@dynDates/eq.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = eq(A,B) %@info: diff --git a/matlab/@dynDates/intersect.m b/matlab/@dynDates/intersect.m index b61eee2a7..8e70ebab6 100644 --- a/matlab/@dynDates/intersect.m +++ b/matlab/@dynDates/intersect.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = intersect(A,B) %@info: diff --git a/matlab/@dynDates/isempty.m b/matlab/@dynDates/isempty.m index ea76bd968..e8be87b26 100644 --- a/matlab/@dynDates/isempty.m +++ b/matlab/@dynDates/isempty.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = isempty(A) %@info: diff --git a/matlab/@dynDates/minus.m b/matlab/@dynDates/minus.m index 693c8a3f6..fd209b0c5 100644 --- a/matlab/@dynDates/minus.m +++ b/matlab/@dynDates/minus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = minus(A,B) %@info: diff --git a/matlab/@dynDates/plus.m b/matlab/@dynDates/plus.m index 626e46daa..f1a769617 100644 --- a/matlab/@dynDates/plus.m +++ b/matlab/@dynDates/plus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = plus(A,B) %@info: diff --git a/matlab/@dynDates/pop.m b/matlab/@dynDates/pop.m index 3013c876b..83448580c 100644 --- a/matlab/@dynDates/pop.m +++ b/matlab/@dynDates/pop.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = pop(dd,a) % pop method for dynDates class (removes a date)). diff --git a/matlab/@dynDates/sort.m b/matlab/@dynDates/sort.m index 52467bfc4..32b2abe71 100644 --- a/matlab/@dynDates/sort.m +++ b/matlab/@dynDates/sort.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = sort(dd) % sort method for dynDates class. diff --git a/matlab/@dynDates/subsref.m b/matlab/@dynDates/subsref.m index d15a17f2e..b1ac3a4b0 100644 --- a/matlab/@dynDates/subsref.m +++ b/matlab/@dynDates/subsref.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = subsref(A,S) %@info: diff --git a/matlab/@dynDates/union.m b/matlab/@dynDates/union.m index e0799d834..54e596d9c 100644 --- a/matlab/@dynDates/union.m +++ b/matlab/@dynDates/union.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = union(A,varargin) %@info: diff --git a/matlab/@dynDates/unique.m b/matlab/@dynDates/unique.m index b37292fb8..06c1515ec 100644 --- a/matlab/@dynDates/unique.m +++ b/matlab/@dynDates/unique.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function dd = unique(dd) % unique method for dynDates class. diff --git a/matlab/@dynSeries/align.m b/matlab/@dynSeries/align.m index 6096b5fa9..63b983da3 100644 --- a/matlab/@dynSeries/align.m +++ b/matlab/@dynSeries/align.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function [a,b] = align(a, b) %@info: diff --git a/matlab/@dynSeries/dynSeries.m b/matlab/@dynSeries/dynSeries.m index 58454cfa6..09e4eee2d 100644 --- a/matlab/@dynSeries/dynSeries.m +++ b/matlab/@dynSeries/dynSeries.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = dynSeries(varargin) %@info: diff --git a/matlab/@dynSeries/eq.m b/matlab/@dynSeries/eq.m index 1850f3e52..d8d2f7ee4 100644 --- a/matlab/@dynSeries/eq.m +++ b/matlab/@dynSeries/eq.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function C = eq(A,B) %@info: diff --git a/matlab/@dynSeries/extract.m b/matlab/@dynSeries/extract.m index 185c20c56..feabd0547 100644 --- a/matlab/@dynSeries/extract.m +++ b/matlab/@dynSeries/extract.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = extract(B,varargin) % Extract some variables from a database. diff --git a/matlab/@dynSeries/horzcat.m b/matlab/@dynSeries/horzcat.m index 97ea8ebc6..798ad2657 100644 --- a/matlab/@dynSeries/horzcat.m +++ b/matlab/@dynSeries/horzcat.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function a = horzcat(varargin) %@info: diff --git a/matlab/@dynSeries/insert.m b/matlab/@dynSeries/insert.m index 7b6307deb..9dba32239 100644 --- a/matlab/@dynSeries/insert.m +++ b/matlab/@dynSeries/insert.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = insert(ts,us,id) % Add a variable in a dynSeries object. diff --git a/matlab/@dynSeries/lag.m b/matlab/@dynSeries/lag.m index 918510af1..c82e26e03 100644 --- a/matlab/@dynSeries/lag.m +++ b/matlab/@dynSeries/lag.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = lag(ts,p) %@info: diff --git a/matlab/@dynSeries/merge.m b/matlab/@dynSeries/merge.m index e9f29611a..436a67aa8 100644 --- a/matlab/@dynSeries/merge.m +++ b/matlab/@dynSeries/merge.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = merge(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} merge (@var{B},@var{C}) diff --git a/matlab/@dynSeries/minus.m b/matlab/@dynSeries/minus.m index c7e4736db..3154a9f32 100644 --- a/matlab/@dynSeries/minus.m +++ b/matlab/@dynSeries/minus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = minus(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} minus (@var{B},@var{C}) diff --git a/matlab/@dynSeries/mrdivide.m b/matlab/@dynSeries/mrdivide.m index cabc91636..f05dc6eea 100644 --- a/matlab/@dynSeries/mrdivide.m +++ b/matlab/@dynSeries/mrdivide.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = mrdivide(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} mrdivide (@var{B},@var{C}) diff --git a/matlab/@dynSeries/mtimes.m b/matlab/@dynSeries/mtimes.m index b81cd4145..758342c72 100644 --- a/matlab/@dynSeries/mtimes.m +++ b/matlab/@dynSeries/mtimes.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = mtimes(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} mtimes (@var{B},@var{C}) diff --git a/matlab/@dynSeries/plus.m b/matlab/@dynSeries/plus.m index 10767f2e9..165039fc0 100644 --- a/matlab/@dynSeries/plus.m +++ b/matlab/@dynSeries/plus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = plus(B,C) %@info: %! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C}) diff --git a/matlab/@dynSeries/pop.m b/matlab/@dynSeries/pop.m index b6c178ed0..c242af042 100644 --- a/matlab/@dynSeries/pop.m +++ b/matlab/@dynSeries/pop.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function [ts,id] = pop(ts,a) % Removes a variable from a dynSeries object. diff --git a/matlab/@dynSeries/qdiff.m b/matlab/@dynSeries/qdiff.m index e11dd3b5f..528cbd95b 100644 --- a/matlab/@dynSeries/qdiff.m +++ b/matlab/@dynSeries/qdiff.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = qdiff(ts) %@info: diff --git a/matlab/@dynSeries/qgrowth.m b/matlab/@dynSeries/qgrowth.m index 8823e70ca..6ed395efc 100644 --- a/matlab/@dynSeries/qgrowth.m +++ b/matlab/@dynSeries/qgrowth.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = qgrowth(ts) %@info: diff --git a/matlab/@dynSeries/rename.m b/matlab/@dynSeries/rename.m index 80b391d63..005cc1985 100644 --- a/matlab/@dynSeries/rename.m +++ b/matlab/@dynSeries/rename.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = rename(ts,old,new) % Copyright (C) 2013 Dynare Team diff --git a/matlab/@dynSeries/save.m b/matlab/@dynSeries/save.m index a399a8a95..ff3269a96 100644 --- a/matlab/@dynSeries/save.m +++ b/matlab/@dynSeries/save.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function save(A,basename,format) % Saves a dynSeries object on disk. diff --git a/matlab/@dynSeries/set_names.m b/matlab/@dynSeries/set_names.m index bee843788..b316c090e 100644 --- a/matlab/@dynSeries/set_names.m +++ b/matlab/@dynSeries/set_names.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = set_names(B,varargin) %@info: diff --git a/matlab/@dynSeries/subsasgn.m b/matlab/@dynSeries/subsasgn.m index b91ee5e77..fbc4d09c9 100644 --- a/matlab/@dynSeries/subsasgn.m +++ b/matlab/@dynSeries/subsasgn.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = subsasgn(A,S,B) %@info: diff --git a/matlab/@dynSeries/subsref.m b/matlab/@dynSeries/subsref.m index 159bb0f9a..866b20058 100644 --- a/matlab/@dynSeries/subsref.m +++ b/matlab/@dynSeries/subsref.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function B = subsref(A, S) %@info: %! @deftypefn {Function File} {@var{us} =} subsref (@var{ts},S) diff --git a/matlab/@dynSeries/tex_rename.m b/matlab/@dynSeries/tex_rename.m index 1a8a569cb..7b3da171f 100644 --- a/matlab/@dynSeries/tex_rename.m +++ b/matlab/@dynSeries/tex_rename.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function ts = tex_rename(ts, varargin) % Copyright (C) 2013 Dynare Team diff --git a/matlab/@dynSeries/uminus.m b/matlab/@dynSeries/uminus.m index a8a6100f8..3a4b0a8b0 100644 --- a/matlab/@dynSeries/uminus.m +++ b/matlab/@dynSeries/uminus.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function A = uminus(B) %@info: %! @deftypefn {Function File} {@var{A} =} plus (@var{B},@var{C}) diff --git a/matlab/@dynSeries/vertcat.m b/matlab/@dynSeries/vertcat.m index 2bd32419d..a2a909479 100644 --- a/matlab/@dynSeries/vertcat.m +++ b/matlab/@dynSeries/vertcat.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function a = vertcat(varargin) %@info: diff --git a/matlab/@dynSeries/ydiff.m b/matlab/@dynSeries/ydiff.m index fbaa0489c..d4ac43d04 100644 --- a/matlab/@dynSeries/ydiff.m +++ b/matlab/@dynSeries/ydiff.m @@ -1,4 +1,4 @@ - +% --*-- Unitary tests --*-- function us = ydiff(ts) %@info: diff --git a/matlab/@dynSeries/ygrowth.m b/matlab/@dynSeries/ygrowth.m index 32a7161ef..78df1d1cc 100644 --- a/matlab/@dynSeries/ygrowth.m +++ b/matlab/@dynSeries/ygrowth.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function us = ygrowth(ts) %@info: From bbfe68a09dbbecb1c524e37b7b251cd94a84f360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 15:06:05 +0200 Subject: [PATCH 10/34] Fixed bug + Cosmetic change. --- matlab/utilities/tests/run_unitary_tests.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/matlab/utilities/tests/run_unitary_tests.m b/matlab/utilities/tests/run_unitary_tests.m index ca435fd5f..1a7408ffb 100644 --- a/matlab/utilities/tests/run_unitary_tests.m +++ b/matlab/utilities/tests/run_unitary_tests.m @@ -21,15 +21,14 @@ report = {}; for f=1:length(listoffiles) if iscell(listoffiles{f}) - info = run_all_unitary_tests(listoffiles{f}); + info = run_unitary_tests(listoffiles{f}); report = [report; info]; else if isequal(listoffiles{f}(end-1:end),'.m') && ~isequal(listoffiles{f}(1:2),'.#') if is_unitary_test_available(listoffiles{f}) - fprintf(['***** Process unitary tests in ' listoffiles{f} ' ... ']) + disp(['***** Process unitary tests in ' listoffiles{f}]) [check, info] = mtest(listoffiles{f}); report = [report; info]; - fprintf(['Done!\n']) else disp(['Booh! No unitay tests available in ' listoffiles{f}]) end From 4913413896490f1e714160d9b61b3938ccc59d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 15:34:50 +0200 Subject: [PATCH 11/34] Fixed bug. Set elapsed time to NaN if the unitary test fails. --- matlab/utilities/tests/mtest.m | 1 + 1 file changed, 1 insertion(+) diff --git a/matlab/utilities/tests/mtest.m b/matlab/utilities/tests/mtest.m index 3cd153c0c..ef325b99c 100644 --- a/matlab/utilities/tests/mtest.m +++ b/matlab/utilities/tests/mtest.m @@ -113,6 +113,7 @@ for i=1:nn end end info(i,4) = {tmp}; + info(i,5) = {NaN}; check = 0; else if nargout>1 From 6bfda327b3355607a89130c7b0803ddcb0c5de85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 15:35:55 +0200 Subject: [PATCH 12/34] Fixed bug related to the presence of temporary files (begining with .#) in a folder. --- matlab/utilities/tests/run_unitary_tests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/utilities/tests/run_unitary_tests.m b/matlab/utilities/tests/run_unitary_tests.m index 1a7408ffb..2218ed00e 100644 --- a/matlab/utilities/tests/run_unitary_tests.m +++ b/matlab/utilities/tests/run_unitary_tests.m @@ -24,7 +24,7 @@ for f=1:length(listoffiles) info = run_unitary_tests(listoffiles{f}); report = [report; info]; else - if isequal(listoffiles{f}(end-1:end),'.m') && ~isequal(listoffiles{f}(1:2),'.#') + 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}); From 42ed03048badcf9c2e62d648d732755d4d8cd014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 15:57:31 +0200 Subject: [PATCH 13/34] Added option for saving the produced detailed report about unitary tests. --- matlab/utilities/tests/run_unitary_tests_in_directory.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m index 34c17169c..46e165a0b 100644 --- a/matlab/utilities/tests/run_unitary_tests_in_directory.m +++ b/matlab/utilities/tests/run_unitary_tests_in_directory.m @@ -1,4 +1,4 @@ -function report = run_unitary_tests_in_directory(dirname) +function report = run_unitary_tests_in_directory(dirname,savereport) % Copyright (C) 2013 Dynare Team % @@ -18,4 +18,9 @@ function report = run_unitary_tests_in_directory(dirname) % along with Dynare. If not, see . listoffiles = get_directory_description(dirname); -report = run_unitary_tests(listoffiles); \ No newline at end of file +report = run_unitary_tests(listoffiles); + +if nargin>1 && savereport>0 + d = clock; + save(['report-' num2str(d(1)) '-' num2str(d(2)) '-' num2str(d(3)) '-' num2str(d(4)) '-' num2str(d(5)) '-' num2str(round(d(6))) '.mat' ],'report'); +end \ No newline at end of file From fb5c5d4ea645c40b4946eb81f6c6fc5028e8fcef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 18:06:12 +0200 Subject: [PATCH 14/34] Added a routine to produce and send a summary report about unitary tests. --- matlab/utilities/tests/build_report_summary.m | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 matlab/utilities/tests/build_report_summary.m diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m new file mode 100644 index 000000000..184bf2fda --- /dev/null +++ b/matlab/utilities/tests/build_report_summary.m @@ -0,0 +1,89 @@ +function str = build_report_summary(report, 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 . + +if isequal(nargin,1) + printonscreen = 1; +end + +if nargin<3 + mailreport = 0; +else + if ischar(mailreport) + mailto = mailreport; + mailreport = 1; + else + error('build_report_summary:: Third argument must be an adress email!') + end + +end + +system('git show --pretty=format:"Last commit %H by %an, %ar %n-> %s" HEAD > git.info'); + +str = 'Hi,'; +str = char(str,''); +str = char(str,'This is a summary report for the unitary tests in Dynare.'); +str = char(str,''); + +fid = fopen('git.info'); +str = char(str,fgetl(fid)); +str = char(str,fgetl(fid)); +fclose(fid); + +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(report,1))]); +str = char(str,['| PASS: ' int2str(length(find(cell2mat(report(:,3)))))]); +str = char(str,['| FAIL: ' int2str(length(find(~cell2mat(report(:,3)))))]); +str = char(str,'|'); +str = char(str,'| LIST OF FAILED TESTS:'); +for i=1:size(report,1) + if ~report{i,3} + str = char(str,['| * ' report{i,1} ' (test #' int2str(report{i,2}) '{' strrep(int2str(transpose(find(~report{i,4}))),' ',',') '})']); + end +end + +if printonscreen + fprintf('\n\n') + disp(str) + fprintf('\n\n') +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 \ No newline at end of file From 11bda09860ba1dc67f1f1f1dfb087de351fb8f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 21:17:54 +0200 Subject: [PATCH 15/34] Fixed typo. --- matlab/utilities/tests/run_unitary_tests.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matlab/utilities/tests/run_unitary_tests.m b/matlab/utilities/tests/run_unitary_tests.m index 2218ed00e..58a6dba92 100644 --- a/matlab/utilities/tests/run_unitary_tests.m +++ b/matlab/utilities/tests/run_unitary_tests.m @@ -26,11 +26,11 @@ for f=1:length(listoffiles) else 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}]) + disp(['***** Process unitary tests in ' listoffiles{f}]) [check, info] = mtest(listoffiles{f}); report = [report; info]; else - disp(['Booh! No unitay tests available in ' listoffiles{f}]) + disp(['Booh! No unitary tests available in ' listoffiles{f}]) end end end From 71e8cb569dba72b472d52e307b6050206ac856b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 21:21:45 +0200 Subject: [PATCH 16/34] Added one output argument (return the output of clock). --- matlab/utilities/tests/run_unitary_tests.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matlab/utilities/tests/run_unitary_tests.m b/matlab/utilities/tests/run_unitary_tests.m index 58a6dba92..86885f880 100644 --- a/matlab/utilities/tests/run_unitary_tests.m +++ b/matlab/utilities/tests/run_unitary_tests.m @@ -1,4 +1,4 @@ -function report = run_unitary_tests(listoffiles) +function [report, time] = run_unitary_tests(listoffiles) % Copyright (C) 2013 Dynare Team % @@ -34,4 +34,8 @@ for f=1:length(listoffiles) end end end +end + +if nargout>1 + time = clock; end \ No newline at end of file From 89474d5e4457514d00a0f3bbdc502172ad1d9183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 21:28:08 +0200 Subject: [PATCH 17/34] Reorganization of the code with respect to the production of the summary report. --- matlab/utilities/tests/build_report_summary.m | 31 ++++++++++--------- .../tests/run_unitary_tests_in_directory.m | 23 +++++++++++--- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index 184bf2fda..c0adc5516 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -1,4 +1,4 @@ -function str = build_report_summary(report, printonscreen, mailreport) +function str = build_report_summary(reportfile, printonscreen, mailreport) % Copyright (C) 2013 Dynare Team % @@ -19,6 +19,7 @@ function str = build_report_summary(report, printonscreen, mailreport) if isequal(nargin,1) printonscreen = 1; + mailreport = 0; end if nargin<3 @@ -28,22 +29,24 @@ else mailto = mailreport; mailreport = 1; else - error('build_report_summary:: Third argument must be an adress email!') + if ~isequal(mailreport,0) + error('build_report_summary:: Third argument must be an adress email!') + end end - end -system('git show --pretty=format:"Last commit %H by %an, %ar %n-> %s" HEAD > git.info'); +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.'); str = char(str,''); -fid = fopen('git.info'); -str = char(str,fgetl(fid)); -str = char(str,fgetl(fid)); -fclose(fid); +str = char(str,gitinfo(1,:)); +str = char(str,gitinfo(2,:)); str = char(str,''); str = char(str,''); @@ -51,14 +54,14 @@ str = char(str,''); str = char(str,['===========================']); str = char(str,'DYNARE/MATLAB UNITARY TESTS'); str = char(str,'==========================='); -str = char(str,['| TOTAL: ' int2str(size(report,1))]); -str = char(str,['| PASS: ' int2str(length(find(cell2mat(report(:,3)))))]); -str = char(str,['| FAIL: ' int2str(length(find(~cell2mat(report(:,3)))))]); +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(report,1) - if ~report{i,3} - str = char(str,['| * ' report{i,1} ' (test #' int2str(report{i,2}) '{' strrep(int2str(transpose(find(~report{i,4}))),' ',',') '})']); +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 diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m index 46e165a0b..bdd32569b 100644 --- a/matlab/utilities/tests/run_unitary_tests_in_directory.m +++ b/matlab/utilities/tests/run_unitary_tests_in_directory.m @@ -1,4 +1,4 @@ -function report = run_unitary_tests_in_directory(dirname,savereport) +function report = run_unitary_tests_in_directory(dirname,savereport,printreport,sendreport) % Copyright (C) 2013 Dynare Team % @@ -17,10 +17,25 @@ function report = run_unitary_tests_in_directory(dirname,savereport) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . +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); + listoffiles = get_directory_description(dirname); -report = run_unitary_tests(listoffiles); +[report, time] = run_unitary_tests(listoffiles); if nargin>1 && savereport>0 - d = clock; - save(['report-' num2str(d(1)) '-' num2str(d(2)) '-' num2str(d(3)) '-' num2str(d(4)) '-' num2str(d(5)) '-' num2str(round(d(6))) '.mat' ],'report'); + save(['report-' gitlastcommithash '.mat'],'report','time','gitinfo','gitlastcommithash'); +end + +if nargin>2 + build_report_summary(['report-' gitlastcommithash '.mat'], printreport, sendreport); end \ No newline at end of file From d428124ac9afbee34aac565643fde6f9a01d95a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Thu, 4 Jul 2013 22:12:04 +0200 Subject: [PATCH 18/34] Send the report on the web. --- matlab/utilities/tests/build_report_summary.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index c0adc5516..1b3285050 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -28,6 +28,9 @@ else if ischar(mailreport) mailto = mailreport; mailreport = 1; + fid = fopen('~/.matlab-send-report'); + system(['scp ' fgetl(fid) reportfile]) + fclose(fid); else if ~isequal(mailreport,0) error('build_report_summary:: Third argument must be an adress email!') @@ -42,7 +45,8 @@ gitlastcommithash = reportfilecontent.gitlastcommithash; str = 'Hi,'; str = char(str,''); -str = char(str,'This is a summary report for the unitary tests in Dynare.'); +str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be'); +str = char(str,['found at http://www.dynare.org/stepan/dynare/tests/' reportfile]); str = char(str,''); str = char(str,gitinfo(1,:)); From 1b35bfb211762ccd7d9d302b7b8d960abe1d00e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 00:02:15 +0200 Subject: [PATCH 19/34] Fixed bug (wrong syntax for scp). --- matlab/utilities/tests/build_report_summary.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index 1b3285050..ba81a4a33 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -29,7 +29,7 @@ else mailto = mailreport; mailreport = 1; fid = fopen('~/.matlab-send-report'); - system(['scp ' fgetl(fid) reportfile]) + system(['scp ' reportfile ' ' fgetl(fid)]); fclose(fid); else if ~isequal(mailreport,0) From f8e5cc7b49d7d19c6c2be3beba5d50d7df30b7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 00:24:17 +0200 Subject: [PATCH 20/34] Cosmetic change. --- matlab/utilities/tests/build_report_summary.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index ba81a4a33..2af532beb 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -45,8 +45,8 @@ 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'); -str = char(str,['found at http://www.dynare.org/stepan/dynare/tests/' reportfile]); +str = char(str,'This is a summary report for the unitary tests in Dynare. Full report can be found at'); +str = char(str,['http://www.dynare.org/stepan/dynare/tests/' reportfile]); str = char(str,''); str = char(str,gitinfo(1,:)); From 35c4debfc564f74bc5dab6f40c207a16c40d02db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 00:30:01 +0200 Subject: [PATCH 21/34] Cosmetic change. --- matlab/utilities/tests/build_report_summary.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index 2af532beb..aa98d71d3 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -29,6 +29,8 @@ else mailto = mailreport; mailreport = 1; fid = fopen('~/.matlab-send-report'); + fprintf('\n\n'); + disp('Send report...') system(['scp ' reportfile ' ' fgetl(fid)]); fclose(fid); else From 38cc6add5fbd708a9944976138b581f523d5f4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 10:12:56 +0200 Subject: [PATCH 22/34] Added a loop in name2tex so that the first argument can be a cell of string. --- matlab/name2tex.m | 82 ++++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/matlab/name2tex.m b/matlab/name2tex.m index ed8b259e5..00cbde688 100644 --- a/matlab/name2tex.m +++ b/matlab/name2tex.m @@ -27,40 +27,56 @@ if isempty(id) tex = name; return end - -if info - tex = name; - n = length(id); - if id(1)==1 - tex = ['\_', tex(2:end)]; - if n>1 - id = id(2:end)+1; - n = n-1; - else - return - end - end - if id(end)==length(tex) - tex = [tex(1:end-1) '\_']; - if n>1 - id = id(1:end-1); - n = n-1; - else - return - end - end - if n==1 - tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ]; - return - else - for i=1:n-1 - tex = [tex(1:id(1)-1) '\_' tex((id(1)+1):end)]; - id = id(2:end)+1; - end - tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}']; - end + +if iscell(name) + nn = length(name); else - tex = strrep(name, '_', '\_'); + nn = 1; +end + +for i=1:nn + if info + if iscell(name) + tex = name{i}; + else + tex = name; + end + n = length(id); + if id(1)==1 + tex = ['\_', tex(2:end)]; + if n>1 + id = id(2:end)+1; + n = n-1; + else + return + end + end + if id(end)==length(tex) + tex = [tex(1:end-1) '\_']; + if n>1 + id = id(1:end-1); + n = n-1; + else + return + end + end + if n==1 + tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ]; + return + else + for i=1:n-1 + tex = [tex(1:id(1)-1) '\_' tex((id(1)+1):end)]; + id = id(2:end)+1; + end + tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}']; + end + else + if iscell(name) + tex = strrep(name{i}, '_', '\_'); + else + tex = strrep(name, '_', '\_'); + end + end end %@test:1 From c93f972ee5a5f571587d4cefbe0bdddf6f70e3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 12:37:44 +0200 Subject: [PATCH 23/34] Fixed bug introduced in 72a02846a810c3968040fd900e9f2b5a5fe9b432 and other bugs. --- matlab/name2tex.m | 64 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/matlab/name2tex.m b/matlab/name2tex.m index 00cbde688..426520001 100644 --- a/matlab/name2tex.m +++ b/matlab/name2tex.m @@ -22,57 +22,87 @@ if nargin<2 info = 0; end -id = findstr('_',name); +if iscell(name) + nn = length(name); + id = findstr(cell2mat(transpose(name)),'_'); +else + nn = 1; + id = findstr(name,'_'); +end + if isempty(id) tex = name; return end if iscell(name) - nn = length(name); -else - nn = 1; + tex = cell(nn,1); end for i=1:nn if info if iscell(name) - tex = name{i}; + tex(i) = {name{i}}; + id = findstr(name{i},'_'); + len = length(tex{i}); else tex = name; + id = findstr(name,'_'); + len = length(tex); end n = length(id); if id(1)==1 - tex = ['\_', tex(2:end)]; + if iscell(name) + tex(i) = {['\_', tex{i}(2:end)]}; + else + tex = ['\_', tex(2:end)]; + end if n>1 id = id(2:end)+1; n = n-1; + len = len+1; else - return + continue end end - if id(end)==length(tex) - tex = [tex(1:end-1) '\_']; + if id(end)==len + if iscell(name) + tex(i) = {[tex{i}(1:end-1) '\_']}; + else + tex = [tex(1:end-1) '\_']; + end if n>1 id = id(1:end-1); n = n-1; else - return + continue end end if n==1 - tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ]; - return + if iscell(name) + tex(i) = {[ tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}' ]}; + else + tex = [ tex(1:(id-1)) '_{' tex((id+1):end) '}' ]; + end + continue else - for i=1:n-1 - tex = [tex(1:id(1)-1) '\_' tex((id(1)+1):end)]; + for j=1:n-1 + if iscell(name) + tex(i) = {[tex{i}(1:id(j)-1) '\_' tex{i}((id(j)+1):end)]}; + else + tex = [tex(1:id(j)-1) '\_' tex((id(j)+1):end)]; + end id = id(2:end)+1; end - tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}']; + if iscell(name) + tex(i) = {[tex{i}(1:(id-1)) '_{' tex{i}((id+1):end) '}']}; + else + tex = [tex(1:(id-1)) '_{' tex((id+1):end) '}']; + end end else if iscell(name) - tex = strrep(name{i}, '_', '\_'); + tex(i) = {strrep(name{i}, '_', '\_')}; else tex = strrep(name, '_', '\_'); end @@ -108,7 +138,7 @@ end %$ t(8) = dyn_assert(strcmp(t8,'\\_azert\\_uiop\\_qsdfg\\_'),1); %$ t(9) = dyn_assert(strcmp(t11,'\\_azert'),1); %$ t(10) = dyn_assert(strcmp(t12,'azert\\_'),1); -%$ t(11) = dyn_assert(strcmp(t13,'\\_azert\\_'),1); +%$ t(11) = dyn_assert(strcmp(t13,'\\_azert\\_'),1); %$ t(12) = dyn_assert(strcmp(t14,'azert_{uiop}'),1); %$ t(13) = dyn_assert(strcmp(t15,'azert\\_uiop_{qsdfg}'),1); %$ t(14) = dyn_assert(strcmp(t16,'azert\\_uiop_{qsdfg\\_}'),1); From e75df484e9ae59aa1e473a81d00b17a3e52393bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 12:38:32 +0200 Subject: [PATCH 24/34] Code factorization. --- matlab/@dynSeries/dynSeries.m | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/matlab/@dynSeries/dynSeries.m b/matlab/@dynSeries/dynSeries.m index 58454cfa6..72d5253ab 100644 --- a/matlab/@dynSeries/dynSeries.m +++ b/matlab/@dynSeries/dynSeries.m @@ -124,13 +124,18 @@ switch nargin ts.vobs = length(varlist); ts.nobs = size(data,1); if isempty(tex) - ts.tex = cell(ts.vobs,1); - for i=1:ts.vobs - ts.tex(i) = {name2tex(varlist{i})}; - end + ts.tex = name2tex(varlist); else - ts.tex = tex; + ts.tex = tex; end + elseif isnumeric(varargin{1}) && isequal(ndims(varargin{1}),2) + ts.data = varargin{1}; + [ts.nobs, ts.vobs] = size(ts.data); + ts.freq = 1; + ts.init = dynDate(1); + ts.time = ts.init:ts.init+ts.nobs; + ts.name = default_name(ts.vobs); + ts.tex = name2tex(ts.name); end case {2,3,4} a = varargin{1}; @@ -177,9 +182,7 @@ switch nargin error('dynSeries::dynSeries: The number of declared names does not match the number of variables!') end else - for i=1:ts.vobs - ts.name = vertcat(ts.name, {['Variable_' int2str(i)]}); - end + ts.name = default_name(ts.vobs); end if ~isempty(d) if ts.vobs==length(d) @@ -190,9 +193,7 @@ switch nargin error('dynSeries::dynSeries: The number of declared tex names does not match the number of variables!') end else - for i=1:ts.vobs - ts.tex = vertcat(ts.tex, {name2tex(ts.name{i})}); - end + ts.tex = name2tex(ts.name); end otherwise error('dynSeries::dynSeries: Can''t instantiate the class, wrong calling sequence!') From e9dca040a6a661a8150f2692ccbb53b5167b5be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 12:39:21 +0200 Subject: [PATCH 25/34] Added missing routine in commit c19905725fd91e91a7fb42437ff8155921a5b8bd. --- matlab/@dynSeries/private/default_name.m | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 matlab/@dynSeries/private/default_name.m diff --git a/matlab/@dynSeries/private/default_name.m b/matlab/@dynSeries/private/default_name.m new file mode 100644 index 000000000..c5093ccf4 --- /dev/null +++ b/matlab/@dynSeries/private/default_name.m @@ -0,0 +1,27 @@ +function names = default_name(dim) + +% 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 . + + +names = {}; +for i=1:dim + names = vertcat(names, {['Variable_' int2str(i)]}); +end + + + From 141d720b7720982e311f94e3a9e746888db7f075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 12:40:12 +0200 Subject: [PATCH 26/34] Fixed error in copyright. --- matlab/@dynSeries/private/default_name.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/@dynSeries/private/default_name.m b/matlab/@dynSeries/private/default_name.m index c5093ccf4..1711195c4 100644 --- a/matlab/@dynSeries/private/default_name.m +++ b/matlab/@dynSeries/private/default_name.m @@ -1,6 +1,6 @@ function names = default_name(dim) -% Copyright (C) 2011-2013 Dynare Team +% Copyright (C) 2013 Dynare Team % % This file is part of Dynare. % From 67ee48cddc40172ce2f56ceb673dc669729e22fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 13:34:13 +0200 Subject: [PATCH 27/34] Added unitary tests. --- matlab/name2tex.m | 70 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/matlab/name2tex.m b/matlab/name2tex.m index 426520001..082828fe7 100644 --- a/matlab/name2tex.m +++ b/matlab/name2tex.m @@ -146,4 +146,72 @@ end %$ t(16) = dyn_assert(strcmp(t18,'\\_azert\\_uiop_{qsdfg\\_}'),1); %$ %$ T = all(t); -%@eof:1 \ No newline at end of file +%@eof:1 + +%@test:2 +%$ t = zeros(16,1); +%$ t1 = name2tex({'_azert'}); +%$ t2 = name2tex({'azert_'}); +%$ t3 = name2tex({'_azert_'}); +%$ t4 = name2tex({'azert_uiop'}); +%$ t5 = name2tex({'azert_uiop_qsdfg'}); +%$ t6 = name2tex({'azert_uiop_qsdfg_'}); +%$ t7 = name2tex({'_azert_uiop_qsdfg'}); +%$ t8 = name2tex({'_azert_uiop_qsdfg_'}); +%$ t11 = name2tex({'_azert'},1); +%$ t12 = name2tex({'azert_'},1); +%$ t13 = name2tex({'_azert_'},1); +%$ t14 = name2tex({'azert_uiop'},1); +%$ t15 = name2tex({'azert_uiop_qsdfg'},1); +%$ t16 = name2tex({'azert_uiop_qsdfg_'},1); +%$ t17 = name2tex({'_azert_uiop_qsdfg'},1); +%$ t18 = name2tex({'_azert_uiop_qsdfg_'},1); +%$ +%$ t(1) = dyn_assert(t1,{'\\_azert'}); +%$ t(2) = dyn_assert(t2,{'azert\\_'}); +%$ t(3) = dyn_assert(t3,{'\\_azert\\_'}); +%$ t(4) = dyn_assert(t4,{'azert\\_uiop'}); +%$ t(5) = dyn_assert(t5,{'azert\\_uiop\\_qsdfg'}); +%$ t(6) = dyn_assert(t6,{'azert\\_uiop\\_qsdfg\\_'}); +%$ t(7) = dyn_assert(t7,{'\\_azert\\_uiop\\_qsdfg'}); +%$ t(8) = dyn_assert(t8,{'\\_azert\\_uiop\\_qsdfg\\_'}); +%$ t(9) = dyn_assert(t11,{'\\_azert'}); +%$ t(10) = dyn_assert(t12,{'azert\\_'}); +%$ t(11) = dyn_assert(t13,{'\\_azert\\_'}); +%$ t(12) = dyn_assert(t14,{'azert_{uiop}'}); +%$ t(13) = dyn_assert(t15,{'azert\\_uiop_{qsdfg}'}); +%$ t(14) = dyn_assert(t16,{'azert\\_uiop_{qsdfg\\_}'}); +%$ t(15) = dyn_assert(t17,{'\\_azert\\_uiop_{qsdfg}'}); +%$ t(16) = dyn_assert(t18,{'\\_azert\\_uiop_{qsdfg\\_}'}); +%$ +%$ T = all(t); +%@eof:2 + +%@test:3 +%$ t = zeros(4,1); +%$ try +%$ t1 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'}); +%$ t(1) = 1; +%$ catch +%$ % Nothing to do here. +%$ end +%$ +%$ if t(1) +%$ try +%$ t2 = name2tex({'_azert';'azert_';'_azert_';'azert_uiop';'azert_uiop_qsdfg';'azert_uiop_qsdfg_'},1); +%$ t(2) = 1; +%$ catch +%$ % Nothing to do here. +%$ end +%$ end +%$ +%$ if t(1) +%$ t(3) = dyn_assert(t1,{'\\_azert';'azert\\_';'\\_azert\\_';'azert\\_uiop';'azert\\_uiop\\_qsdfg';'azert\\_uiop\\_qsdfg\\_'}); +%$ end +%$ +%$ if t(2) +%$ t(4) = dyn_assert(t2,{'\\_azert';'azert\\_';'\\_azert\\_';'azert_{uiop}';'azert\\_uiop_{qsdfg}';'azert\\_uiop_{qsdfg\\_}'}); +%$ end +%$ +%$ T = all(t); +%@eof:3 \ No newline at end of file From a80ed38f5b716603141353c6ef17fdcea275f154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 13:36:44 +0200 Subject: [PATCH 28/34] Moved name2tex in matlab/utilities/general --- matlab/{ => utilities/general}/name2tex.m | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename matlab/{ => utilities/general}/name2tex.m (100%) diff --git a/matlab/name2tex.m b/matlab/utilities/general/name2tex.m similarity index 100% rename from matlab/name2tex.m rename to matlab/utilities/general/name2tex.m From 0f48674771cb2c7b1a6050fb145ee4905a8a5837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 15:33:46 +0200 Subject: [PATCH 29/34] Added name2tex to the unitary tests suite. --- matlab/utilities/general/name2tex.m | 1 + 1 file changed, 1 insertion(+) diff --git a/matlab/utilities/general/name2tex.m b/matlab/utilities/general/name2tex.m index 082828fe7..b95807e4d 100644 --- a/matlab/utilities/general/name2tex.m +++ b/matlab/utilities/general/name2tex.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function tex = name2tex(name, info) % Converts plain text name into tex name. From dc57706b557d231ec58658f62e7cb30c8006a5ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 15:56:14 +0200 Subject: [PATCH 30/34] Cosmetic change. --- matlab/utilities/tests/build_report_summary.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index aa98d71d3..db04f320c 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -48,9 +48,9 @@ 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,['http://www.dynare.org/stepan/dynare/tests/' reportfile]); str = char(str,''); - str = char(str,gitinfo(1,:)); str = char(str,gitinfo(2,:)); From b997febc9256c74c41288fdbbb4d3efcef1cddb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 16:11:46 +0200 Subject: [PATCH 31/34] Added matlab version and system name in the generated report. --- matlab/utilities/tests/run_unitary_tests_in_directory.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m index bdd32569b..300d599f8 100644 --- a/matlab/utilities/tests/run_unitary_tests_in_directory.m +++ b/matlab/utilities/tests/run_unitary_tests_in_directory.m @@ -29,11 +29,14 @@ fid = fopen('git.last-commit-hash'); gitlastcommithash = fgetl(fid); fclose(fid); +matlabverion = version; +platform = computer; + listoffiles = get_directory_description(dirname); [report, time] = run_unitary_tests(listoffiles); if nargin>1 && savereport>0 - save(['report-' gitlastcommithash '.mat'],'report','time','gitinfo','gitlastcommithash'); + save(['report-' gitlastcommithash '.mat'],'report','time','gitinfo','gitlastcommithash','matlabverion','platform'); end if nargin>2 From cafbab43921128cbed65d0e63bf57363636d40a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 17:28:19 +0200 Subject: [PATCH 32/34] Added cycle reduction routine (and logarithmic reduction routine) in the unitary tests suite. --- matlab/cycle_reduction.m | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/matlab/cycle_reduction.m b/matlab/cycle_reduction.m index 04fca27a7..1449e2a52 100644 --- a/matlab/cycle_reduction.m +++ b/matlab/cycle_reduction.m @@ -1,3 +1,4 @@ +% --*-- Unitary tests --*-- function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch) %@info: @@ -43,7 +44,7 @@ function [X, info] = cycle_reduction(A0, A1, A2, cvg_tol, ch) %! @end deftypefn %@eod: -% Copyright (C) 2012 Dynare Team +% Copyright (C) 2013 Dynare Team % % This file is part of Dynare. % @@ -112,23 +113,39 @@ if (nargin == 5 && ~isempty(ch) ) end %@test:1 -%$ addpath ../matlab %$ -%$ % Set the dimension of the problem to be solved +%$ t = zeros(3,1); +%$ +%$ % Set the dimension of the problem to be solved. %$ n = 2000; +%$ %$ % Set the equation to be solved %$ A = eye(n); %$ B = diag(30*ones(n,1)); B(1,1) = 20; B(end,end) = 20; B = B - diag(10*ones(n-1,1),-1); B = B - diag(10*ones(n-1,1),1); %$ C = diag(15*ones(n,1)); C = C - diag(5*ones(n-1,1),-1); C = C - diag(5*ones(n-1,1),1); %$ %$ % Solve the equation with the cycle reduction algorithm -%$ tic, X1 = cycle_reduction(C,B,A,1e-7); toc +%$ try +%$ t=cputime; X1 = cycle_reduction(C,B,A,1e-7); elapsedtime = cputime-t; +%$ disp(['cputime for cycle reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').']) +%$ t(1) = 1; +%$ catch +%$ % nothing to do here. +%$ end %$ %$ % Solve the equation with the logarithmic reduction algorithm -%$ tic, X2 = logarithmic_reduction(A,B,C,1e-16,100); toc +%$ try +%$ t=cputime; X2 = logarithmic_reduction(A,B,C,1e-16,100); elapsedtime = cputime-t; +%$ disp(['cputime for logarithmic reduction algorithm is: ' num2str(elapsedtime) ' (n=' int2str(n) ').']) +%$ t(2) = 1; +%$ catch +%$ % nothing to do here. +%$ end %$ %$ % Check the results. -%$ t(1) = dyn_assert(X1,X2,1e-12); +%$ if t(1) && t(2) +%$ t(3) = dyn_assert(X1,X2,1e-12); +%$ end %$ %$ T = all(t); %@eof:1 \ No newline at end of file From 6d440fbe56057b9038703824e5c320995c5dc7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 18:02:39 +0200 Subject: [PATCH 33/34] Added a human readable version of the report (log file). --- matlab/utilities/tests/build_report_summary.m | 7 +++++-- matlab/utilities/tests/run_unitary_tests_in_directory.m | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/matlab/utilities/tests/build_report_summary.m b/matlab/utilities/tests/build_report_summary.m index db04f320c..9e2fc0eae 100644 --- a/matlab/utilities/tests/build_report_summary.m +++ b/matlab/utilities/tests/build_report_summary.m @@ -29,10 +29,12 @@ else mailto = mailreport; mailreport = 1; fid = fopen('~/.matlab-send-report'); + server = fgetl(fid); + fclose(fid); fprintf('\n\n'); disp('Send report...') - system(['scp ' reportfile ' ' fgetl(fid)]); - fclose(fid); + 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!') @@ -50,6 +52,7 @@ 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,['http://www.dynare.org/stepan/dynare/tests/' reportfile]); +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,:)); diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m index 300d599f8..196c32a34 100644 --- a/matlab/utilities/tests/run_unitary_tests_in_directory.m +++ b/matlab/utilities/tests/run_unitary_tests_in_directory.m @@ -33,7 +33,10 @@ 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'); From 44961e340892e2e373e545c0a64eb31a94afe376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Fri, 5 Jul 2013 18:07:28 +0200 Subject: [PATCH 34/34] Cosmetic change. Display the cell report in the log file. --- matlab/utilities/tests/run_unitary_tests_in_directory.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matlab/utilities/tests/run_unitary_tests_in_directory.m b/matlab/utilities/tests/run_unitary_tests_in_directory.m index 196c32a34..ef2499eb5 100644 --- a/matlab/utilities/tests/run_unitary_tests_in_directory.m +++ b/matlab/utilities/tests/run_unitary_tests_in_directory.m @@ -35,7 +35,7 @@ platform = computer; listoffiles = get_directory_description(dirname); diary(['report-' gitlastcommithash '.log'] ) -[report, time] = run_unitary_tests(listoffiles); +[report, time] = run_unitary_tests(listoffiles) diary off if nargin>1 && savereport>0