Skip to content

Commit 102ff19

Browse files
committed
buildtool coverage works again, more effectively
1 parent 4255db1 commit 102ff19

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

buildfile.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,19 @@
7474

7575
if ~isMATLABReleaseOlderThan('R2024a')
7676

77-
plan('coverage') = matlab.buildtool.tasks.TestTask(test_root, ...
77+
ct = matlab.buildtool.tasks.TestTask(test_root, ...
7878
Description="Run code coverage", ...
7979
Dependencies='exe', ...
8080
SourceFiles=pkg_root, ...
8181
Strict=false);
82-
plan('coverage').DisableIncremental = true;
82+
ct.DisableIncremental = true;
8383

84+
% https://www.mathworks.com/help/releases/R2025b/matlab/ref/matlab.buildtool.tasks.testtask.addcodecoverage.html
8485
coverageReport = fullfile(reportDir, 'coverage-report.html');
85-
if ~isMATLABReleaseOlderThan('R2024b') && stdlib.checkout_license("MATLAB Test")
86-
plan("coverage").addCodeCoverage(matlabtest.plugins.codecoverage.StandaloneReport(coverageReport));
87-
else
88-
plan("coverage").addCodeCoverage(coverageReport);
86+
try
87+
plan("coverage") = ct.addCodeCoverage(matlabtest.plugins.codecoverage.StandaloneReport(coverageReport));
88+
catch
89+
plan("coverage") = ct.addCodeCoverage(coverageReport);
8990
end
9091
end
9192

0 commit comments

Comments
 (0)