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] 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