Skip to content

Commit 774b26f

Browse files
committed
test:coverage: use Coverage plugin
1 parent b170dfe commit 774b26f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

buildfile.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
function plan = buildfile
22
import matlab.unittest.selectors.HasTag
3+
import matlab.buildtool.tasks.TestTask
4+
import matlabtest.plugins.codecoverage.StandaloneReport
5+
36
assert(~isMATLABReleaseOlderThan("R2022b"), "MATLAB R2022b or newer is required for this buildfile")
47

58
plan = buildplan(localfunctions);
@@ -27,7 +30,7 @@
2730
if isMATLABReleaseOlderThan("R2023b")
2831
plan("test_exe") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, HasTag("exe")), Dependencies="exe");
2932
elseif isMATLABReleaseOlderThan("R2024b")
30-
plan("test_exe") = matlab.buildtool.tasks.TestTask(test_root, Tag="exe", Dependencies="exe");
33+
plan("test_exe") = TestTask(test_root, Tag="exe", Dependencies="exe");
3134
end
3235

3336
if isMATLABReleaseOlderThan("R2024b")
@@ -39,44 +42,43 @@
3942
elseif isMATLABReleaseOlderThan("R2025a")
4043
% Matlab == R2024b
4144
plan("test:java") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cjava));
42-
plan("test:exe") = matlab.buildtool.tasks.TestTask(test_root, Tag="exe", Dependencies="exe");
45+
plan("test:exe") = TestTask(test_root, Tag="exe", Dependencies="exe");
4346
plan("test:nomex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cnomex), Dependencies="clean");
4447
plan("test:mex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cmex), Dependencies="mex");
4548

4649
else
4750
% Matlab >= R2025a
48-
plan("test:exe") = matlab.buildtool.tasks.TestTask(test_root, Tag="exe", Description="test subprocess",...
51+
plan("test:exe") = TestTask(test_root, Tag="exe", Description="test subprocess",...
4952
SourceFiles=[pkg_root, test_root + ["/*.cpp", "/*.c", "/*.f90"]], ...
5053
RunOnlyImpactedTests=true,...
5154
Dependencies="exe", TestResults="TestResults_exe.xml", Strict=true);
5255

53-
plan("test:nomex") = matlab.buildtool.tasks.TestTask(test_root, Description="Test non-MEX targets",...
56+
plan("test:nomex") = TestTask(test_root, Description="Test non-MEX targets",...
5457
Selector=cnomex, ...
5558
SourceFiles=pkg_root, RunOnlyImpactedTests=true,...
5659
dependencies="clean_mex", TestResults="TestResults_nomex.xml", Strict=true);
5760

58-
plan("test:mex") = matlab.buildtool.tasks.TestTask(test_root, Description="Test mex targts",...
61+
plan("test:mex") = TestTask(test_root, Description="Test mex targts",...
5962
Selector=cmex, ...
6063
SourceFiles=[pkg_root, plan.RootFolder + "/src"], RunOnlyImpactedTests=true,...
6164
Dependencies="mex", TestResults="TestResults_mex.xml", Strict=true);
6265

63-
plan("test:java") = matlab.buildtool.tasks.TestTask(test_root, Description="test Java targets", ...
66+
plan("test:java") = TestTask(test_root, Description="test Java targets", ...
6467
Selector=cjava, ...
6568
SourceFiles=pkg_root, RunOnlyImpactedTests=true,...
6669
TestResults="TestResults_java.xml", Strict=true);
6770

68-
plan("test:python") = matlab.buildtool.tasks.TestTask(test_root, Description="test Python targets", ...
71+
plan("test:python") = TestTask(test_root, Description="test Python targets", ...
6972
Tag="python", ...
7073
SourceFiles=pkg_root, RunOnlyImpactedTests=true,...
7174
TestResults="TestResults_python.xml", Strict=true);
72-
73-
plan("coverage") = matlab.buildtool.tasks.TestTask(test_root, ...
75+
76+
plan("coverage") = TestTask(test_root, ...
7477
Description="code coverage", ...
75-
Dependencies=["clean", "exe"], ...
78+
Dependencies=["clean_mex", "exe"], ...
7679
SourceFiles=pkg_root, ...
7780
Selector=cnomex | HasTag("java") | HasTag("exe") | HasTag("python"), ...
78-
Strict=false, ...
79-
CodeCoverageResults=["code-coverage.xml", "code-coverage.html"]);
81+
Strict=false).addCodeCoverage(StandaloneReport("coverage-report.html"));
8082

8183
plan("clean_mex") = matlab.buildtool.Task(Actions=@clean_mex, Description="Clean only MEX files to enable incremental tests");
8284
end

0 commit comments

Comments
 (0)