Reorganization of the code with respect to the production of the summary report.

time-shift
Stéphane Adjemian (Charybdis) 2013-07-04 21:28:08 +02:00
parent 71e8cb569d
commit 89474d5e44
2 changed files with 36 additions and 18 deletions

View File

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

View File

@ -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 <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);
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