Skip to content

Commit cc75fdf

Browse files
committed
Update qp_validate to point from failing test case to the next.
1 parent ff425a5 commit cc75fdf

File tree

1 file changed

+48
-19
lines changed

1 file changed

+48
-19
lines changed

src/tools_lgpl/matlab/quickplot/progsrc/qp_validate.m

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function qp_validate(varargin)
108108
includes = {};
109109
logid1=-1;
110110
t1=[];
111+
logid_previous_failed_case = [];
111112
logid2=[];
112113
extlog=[];
113114
FAILED = 'FAILED';
@@ -288,14 +289,15 @@ function qp_validate(varargin)
288289
%end
289290
%% loop over validation test cases
290291
for i=1:length(d)
291-
progressbar(acc_dt/tot_dt,Hpb,'title',d(i).name);
292-
ui_message('',['Case: ',d(i).name])
292+
CaseName = d(i).name;
293+
progressbar(acc_dt/tot_dt,Hpb,'title',CaseName);
294+
ui_message('',['Case: ',CaseName])
293295
if teamcity
294-
fprintf('##teamcity[testStarted name=''%s'']\n', d(i).name);
296+
fprintf('##teamcity[testStarted name=''%s'']\n', CaseName);
295297
else
296-
fprintf('----- %s %s\n', d(i).name, repmat('-',1,93 - length(d(i).name)));
298+
fprintf('----- %s %s\n', CaseName, repmat('-',1,93 - length(CaseName)));
297299
end
298-
includes{i,1} = [d(i).name '/'];
300+
includes{i,1} = [CaseName '/'];
299301
includes{i,2} = logname;
300302
NTested=NTested+1;
301303
DiffFound=0;
@@ -311,7 +313,7 @@ function qp_validate(varargin)
311313
dt2_old=0;
312314
Crash = [];
313315
try
314-
cd(fullfile(val_dir,d(i).name));
316+
cd(fullfile(val_dir,CaseName));
315317
CaseInfo='case.ini';
316318
if isempty(dir('data'))
317319
f = dir('*');
@@ -333,7 +335,7 @@ function qp_validate(varargin)
333335
CaseInfo=inifile('open',CaseInfo);
334336
logid2=fopen(logname,'w','n','US-ASCII');
335337
dt2_old = d(i).dt;
336-
t2 = write_header(logid2,d(i).name,Color);
338+
t2 = write_header(logid2,CaseName,Color);
337339
emptyTable2 = true;
338340
%
339341
% check for log files to run ...
@@ -949,10 +951,8 @@ function qp_validate(varargin)
949951
end
950952
end
951953
if ~isempty(t2)
952-
[dt2,dt2_str,slower] = write_footer(logid2,d(i).name,Color,t2,dt2_old);
954+
[dt2,dt2_str,slower] = write_footer(logid2,CaseName,Color,t2,dt2_old);
953955
end
954-
fclose(logid2);
955-
logid2=[];
956956
%
957957
if isnan(dt2_old)
958958
timid = fopen([reference_folder,'timing.txt'],'w','n','US-ASCII');
@@ -978,13 +978,25 @@ function qp_validate(varargin)
978978
CaseScriptFailed = strncmp(FAILED,lgresult,5);
979979
CaseCrashed = strncmp(FAILED,result,5) & ~(CaseReadFailed | CaseScriptFailed);
980980
CaseFailed = CaseReadFailed | CaseScriptFailed | CaseCrashed;
981+
if CaseFailed
982+
if is_fid(logid_previous_failed_case)
983+
write_reference_to_next_failing_case(logid_previous_failed_case,CaseName)
984+
fclose(logid_previous_failed_case);
985+
end
986+
logid_previous_failed_case = logid2;
987+
logid2 = [];
988+
end
989+
if is_fid(logid2)
990+
fclose(logid2);
991+
logid2=[];
992+
end
981993
if teamcity && CaseFailed
982994
if CaseCrashed
983-
fprintf('##teamcity[testFailed name=''%s'' message=''case crashed.'']\n', d(i).name)
995+
fprintf('##teamcity[testFailed name=''%s'' message=''case crashed.'']\n', CaseName)
984996
elseif CaseReadFailed
985-
fprintf('##teamcity[testFailed name=''%s'' message=''differences when checking data.'']\n', d(i).name)
997+
fprintf('##teamcity[testFailed name=''%s'' message=''differences when checking data.'']\n', CaseName)
986998
elseif CaseScriptFailed
987-
fprintf('##teamcity[testFailed name=''%s'' message=''differences when running script.'']\n', d(i).name)
999+
fprintf('##teamcity[testFailed name=''%s'' message=''differences when running script.'']\n', CaseName)
9881000
end
9891001
end
9901002
NReadFailed = NReadFailed + CaseReadFailed;
@@ -1005,25 +1017,22 @@ function qp_validate(varargin)
10051017
UserInterrupt=1;
10061018
end
10071019
if ~isempty(result)
1008-
extlog = write_table1_line(logid1,extlog,Color,CaseReadFailed,CaseScriptFailed,CaseCrashed,Color.Table{TC1},d(i).name,color,result,[],[],logname,dt2_str);
1020+
extlog = write_table1_line(logid1,extlog,Color,CaseReadFailed,CaseScriptFailed,CaseCrashed,Color.Table{TC1},CaseName,color,result,[],[],logname,dt2_str);
10091021
TC1=3-TC1;
10101022
else
1011-
extlog = write_table1_line(logid1,extlog,Color,CaseReadFailed,CaseScriptFailed,CaseCrashed,Color.Table{TC1},d(i).name,frcolor,frresult,lgcolor,lgresult,logname,dt2_str);
1023+
extlog = write_table1_line(logid1,extlog,Color,CaseReadFailed,CaseScriptFailed,CaseCrashed,Color.Table{TC1},CaseName,frcolor,frresult,lgcolor,lgresult,logname,dt2_str);
10121024
TC1=3-TC1;
10131025
end
10141026
flush(logid1);
10151027
if teamcity
1016-
fprintf('##teamcity[testFinished name=''%s'']\n', d(i).name)
1028+
fprintf('##teamcity[testFinished name=''%s'']\n', CaseName)
10171029
end
10181030
if UserInterrupt
10191031
break
10201032
end
10211033
acc_dt = acc_dt + case_dt(i);
10221034
end
10231035
catch err
1024-
if ~isempty(logid2)
1025-
fclose(logid2);
1026-
end
10271036
if logid1>0
10281037
write_table_error(logid1,extlog,Color,err)
10291038
AnyFail=1;
@@ -1037,6 +1046,12 @@ function qp_validate(varargin)
10371046
if ishandle(Hpb)
10381047
delete(Hpb);
10391048
end
1049+
if is_fid(logid2)
1050+
fclose(logid2);
1051+
end
1052+
if is_fid(logid_previous_failed_case)
1053+
fclose(logid_previous_failed_case);
1054+
end
10401055
cd(currdir)
10411056
if ~isempty(current_procdef)
10421057
qp_settings('delwaq_procdef',current_procdef)
@@ -1142,6 +1157,11 @@ function qp_validate(varargin)
11421157
%str = strrep(str,'_','\_');
11431158
end
11441159

1160+
function write_reference_to_next_failing_case(logid,casename)
1161+
switch log_style
1162+
case 'latex'
1163+
fprintf(logid,'Jump to next failing case: %s{Sec:%s}\n','\autoref',makelabel(casename));
1164+
end
11451165

11461166
function t = write_header(logid,casename,Color,extlog)
11471167
stalone='';
@@ -1923,4 +1943,13 @@ function write_messages(message_file,messages)
19231943
if in_list
19241944
reference_files(i) = [];
19251945
end
1946+
end
1947+
1948+
function ok = is_fid(something)
1949+
if isnumeric(something) && ...
1950+
isscalar(something) && ...
1951+
all(something(:) == round(something(:)))
1952+
ok = ~isempty(fopen(something));
1953+
else
1954+
ok = false;
19261955
end

0 commit comments

Comments
 (0)