Skip to content

Commit 9363da4

Browse files
committed
update warnings
1 parent 9b0927f commit 9363da4

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

plugins/+testframework/CodeCoverageSummaryPlugin.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ function runSession(plugin, pluginData)
2323

2424
% Now extract and save coverage data
2525
if isempty(plugin.CoverageFormat.Result)
26-
warning('CodeCoverageSummaryPlugin:NoCoverageData', ...
27-
'No coverage data collected. Ensure CodeCoveragePlugin is added with the same format object.');
26+
warning("testframework:CodeCoverageSummaryPlugin:NoCoverageData", "No coverage data collected.");
2827
return;
2928
end
3029

@@ -67,17 +66,20 @@ function runSession(plugin, pluginData)
6766
% Local environment
6867
coverageArtifactFile = fullfile(pwd, "matlabCoverageResults.json");
6968
end
70-
7169
coverageResults = {coverageDetails};
72-
73-
JsonCoverageResults = jsonencode(coverageResults, "PrettyPrint", true);
74-
[fID, msg] = fopen(coverageArtifactFile, "w");
75-
if fID == -1
76-
warning("codecoverage:CodeCoverageSummaryPlugin:UnableToOpenFile",...
77-
"Could not open a file for GitHub coverage result table due to: %s", msg);
78-
else
79-
closeFile = onCleanup(@()fclose(fID));
80-
fprintf(fID, '%s', JsonCoverageResults);
70+
71+
try
72+
JsonCoverageResults = jsonencode(coverageResults, "PrettyPrint", true);
73+
74+
[fID, msg] = fopen(coverageArtifactFile, "w");
75+
if fID == -1
76+
warning("testframework:CodeCoverageSummaryPlugin:UnableToOpenFile","Unable to open a file required to create the table of code coverage. (Cause: %s)", msg);
77+
else
78+
closeFile = onCleanup(@()fclose(fID));
79+
fprintf(fID, '%s', JsonCoverageResults);
80+
end
81+
catch e
82+
warning("testframework:TestResultsSummaryPlugin:UnableToJsonEncode","Unable to jsonencode test results data. (Cause: %s)", e.message);
8183
end
8284
end
8385
end

0 commit comments

Comments
 (0)