Skip to content

Commit bac9b3c

Browse files
committed
buildfile: checkout Matlab Test if available
1 parent 5e39d4c commit bac9b3c

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

+stdlib/checkout_license.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
name = addons.Name(strcmpi(installedPackages, packageName));
2121

2222
if isempty(name)
23-
warning('stdlib:checkout_license:ValueError', 'Did not find an installed package %s.\nInstalled packages:\n%s', packageName, join(installedPackages, newline))
23+
msg = sprintf('Did not find an installed package %s.\n', packageName);
24+
if ~ismissing(installedPackages)
25+
msg = sprintf('Installed packages:\n%s', join(installedPackages, newline));
26+
end
27+
warning('stdlib:checkout_license:ValueError', msg)
2428
return
2529
end
2630

.github/workflows/composite-check/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ runs:
1818
uses: actions/upload-artifact@v4
1919
with:
2020
name: ${{ matrix.release }}-${{ runner.os }}-codeissues
21-
path: release/CodeIssues.sarif
21+
path: .buildtool/CodeIssues.sarif

buildfile.m

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,10 @@
1010
cnomex = cnomex & ~HasTag("windows");
1111
end
1212

13+
reportDir = fullfile(plan.RootFolder, ".buildtool");
1314
pkg_root = fullfile(plan.RootFolder, "+stdlib");
1415
test_root = fullfile(plan.RootFolder, "test");
1516

16-
if isMATLABReleaseOlderThan('R2025a')
17-
mt_ok = false;
18-
else
19-
addons = matlab.addons.installedAddons;
20-
% license name obtained by
21-
% com.mathworks.product.util.ProductIdentifier.get("MATLAB Test").getFlexName
22-
mt_ok = any(ismember(addons.Name, "MATLAB Test")) && license('checkout', 'MATLAB_Test') == 1;
23-
end
24-
2517
if ~isMATLABReleaseOlderThan("R2023b")
2618
plan("clean") = matlab.buildtool.tasks.CleanTask;
2719
end
@@ -38,16 +30,19 @@
3830
plan("test_exe") = matlab.buildtool.tasks.TestTask(test_root, Tag="exe", Dependencies="exe");
3931

4032
elseif isMATLABReleaseOlderThan("R2025a")
41-
33+
% Matlab == R2024b
4234
plan("test:main") = matlab.buildtool.Task(Actions=@(context) test_main(context, cnomex));
4335

4436
else
45-
37+
% Matlab >= R2025a
4638
plan("test:main") = matlab.buildtool.tasks.TestTask(...
47-
test_root, Description="Test non-MEX targets",...
39+
test_root, Description="Test non-MEX targets", ...
4840
Selector=cnomex, ...
49-
SourceFiles=pkg_root, RunOnlyImpactedTests=mt_ok,...
50-
TestResults="release/TestResults_nomex.xml", Strict=true);
41+
SourceFiles=pkg_root, ...
42+
RunOnlyImpactedTests=stdlib.checkout_license("MATLAB Test"), ...
43+
TestResults=reportDir + "/TestResults_nomex.xml", Strict=true);
44+
45+
plan("test").Description = "Run all self-tests";
5146

5247
end
5348

@@ -58,27 +53,24 @@
5853

5954
plan("test:python") = matlab.buildtool.tasks.TestTask(...
6055
test_root, Description="test Python targets", ...
61-
Tag = "python", ...
62-
TestResults="release/TestResults_java.xml", Strict=true);
56+
Tag = "python", Strict=true);
6357

6458
plan("test:java") = matlab.buildtool.tasks.TestTask(...
6559
test_root, Description="test Java targets", ...
66-
Tag = "java", ...
67-
TestResults="release/TestResults_java.xml", Strict=true);
60+
Tag = "java", Strict=true);
6861

6962
plan("test:java_exe") = matlab.buildtool.tasks.TestTask(...
7063
test_root, Description="test Java exe targets", ...
71-
Tag = "java_exe", Dependencies="exe", ...
72-
TestResults="release/TestResults_java_exe.xml", Strict=true);
64+
Tag = "java_exe", Dependencies="exe", Strict=true);
7365

7466

75-
if mt_ok
67+
if ~isempty(license('inuse', 'MATLAB_Test'))
7668
plan("coverage") = matlab.buildtool.tasks.TestTask(test_root, ...
77-
Description="code coverage", ...
69+
Description="Run code coverage", ...
7870
Dependencies="exe", ...
7971
SourceFiles=pkg_root, ...
8072
Strict=false).addCodeCoverage(...
81-
matlabtest.plugins.codecoverage.StandaloneReport("release/coverage-report.html"));
73+
matlabtest.plugins.codecoverage.StandaloneReport(reportDir + "/coverage-report.html"));
8274
end
8375

8476
end
@@ -99,7 +91,7 @@
9991
if ~isMATLABReleaseOlderThan("R2024a")
10092
plan("check") = matlab.buildtool.tasks.CodeIssuesTask(plan.RootFolder, ...
10193
IncludeSubfolders=true, ...
102-
WarningThreshold=0, Results="release/CodeIssues.sarif");
94+
WarningThreshold=0, Results=reportDir + "/CodeIssues.sarif");
10395
end
10496

10597
end

0 commit comments

Comments
 (0)