Skip to content

Commit 1374222

Browse files
committed
incremntal test and build for R2025a+
1 parent 155ca83 commit 1374222

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

buildfile.m

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
%% Self-test setup
1212
plan("clean") = matlab.buildtool.tasks.CleanTask;
1313

14+
1415
cnomex = ~HasTag("exe") & ~HasTag("mex");
1516
if isMATLABReleaseOlderThan("R2024b")
1617
cnomex = cnomex & ~HasTag("symlink");
@@ -35,23 +36,24 @@
3536
plan("test:nojavamex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cnojavamex), Dependencies="clean");
3637

3738
else
38-
% can't use SourceFiles= if "mex" Task was run, even if plan("test").DisableIncremental = true;
39-
% this means incremental tests can't be used with MEX files (as of R2024b)
40-
plan("test:exe") = matlab.buildtool.tasks.TestTask("test", Tag="exe", ...
39+
plan("test:exe") = matlab.buildtool.tasks.TestTask("test", Tag="exe", Description="test subprocess",...
40+
SourceFiles=["+stdlib/", "test/*.cpp", "test/*.c", "test/*.f90"], ...
41+
RunOnlyImpactedTests=true,...
4142
Dependencies="exe", TestResults="TestResults_exe.xml", Strict=false);
4243

43-
plan("test:nomex") = matlab.buildtool.tasks.TestTask("test", ...
44-
Selector=cnomex, ...
45-
Dependencies="clean", TestResults="TestResults_nomex.xml", Strict=false);
44+
plan("test:nomex") = matlab.buildtool.tasks.TestTask("test", Description="Test non-MEX targets",...
45+
Selector=cnomex, SourceFiles="+stdlib/", RunOnlyImpactedTests=true,...
46+
dependencies="clean_mex", TestResults="TestResults_nomex.xml", Strict=false);
4647

47-
plan("test:mex") = matlab.buildtool.tasks.TestTask("test", ...
48-
Selector=cmex, ...
48+
plan("test:mex") = matlab.buildtool.tasks.TestTask("test", Description="Test mex targts",...
49+
Selector=cmex, SourceFiles=["+stdlib/", "src/"], RunOnlyImpactedTests=true,...
4950
Dependencies="mex", TestResults="TestResults_mex.xml", Strict=false);
5051

51-
plan("test:nojavamex") = matlab.buildtool.tasks.TestTask("test", ...
52-
Selector=cnojavamex, ...
53-
Dependencies="clean", TestResults="TestResults_nojavamex.xml", Strict=false);
52+
plan("test:nojavamex") = matlab.buildtool.tasks.TestTask("test", Description="test non-Java targets", ...
53+
Selector=cnojavamex, SourceFiles="+stdlib/", RunOnlyImpactedTests=true,...
54+
Dependencies="clean_mex", TestResults="TestResults_nojavamex.xml", Strict=false);
5455

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

5759
td = plan.RootFolder + "/test";
@@ -61,7 +63,8 @@
6163
srcs = [srcs, td + "/stdout_stderr_fortran.f90", td + "/stdin_fortran.f90"];
6264
exes = [exes, td+"/stdout_stderr_fortran.exe", td+"/stdin_fortran.exe"];
6365
end
64-
plan("exe") = matlab.buildtool.Task(Inputs=srcs, Outputs=exes, Actions=@build_exe);
66+
plan("exe") = matlab.buildtool.Task(Inputs=srcs, Outputs=exes, Actions=@build_exe, ...
67+
Description="build test exe's for test subprocess");
6568

6669
if ~isMATLABReleaseOlderThan("R2024a")
6770
plan("check") = matlab.buildtool.tasks.CodeIssuesTask(pkg_name, IncludeSubfolders=true, ...
@@ -96,6 +99,7 @@
9699
mex_deps(end+1) = mex_name; %#ok<AGROW>
97100
else
98101
plan("mex:" + name) = matlab.buildtool.tasks.MexTask(src, bindir, ...
102+
Description="Build MEX target " + name, ...
99103
Options=[compiler_opt, linker_opt]);
100104
end
101105
end
@@ -107,6 +111,11 @@
107111
end
108112

109113

114+
function clean_mex(context)
115+
run(context.Plan, "clean", {"mex"});
116+
end
117+
118+
110119
function legacy_mex(context, compiler_opt, linker_opt)
111120
bindir = fileparts(context.Task.Outputs.Path);
112121
mex(context.Task.Inputs.Path, "-outdir", bindir, compiler_opt{:}, linker_opt)

0 commit comments

Comments
 (0)