33
44plan = buildplan(localfunctions );
55
6- if isMATLABReleaseOlderThan(" R2023b" )
7- plan(" clean" ) = matlab .buildtool .Task();
8- else
9- plan(" clean" ) = matlab .buildtool .tasks .CleanTask ;
10- end
11-
12- cnomex = ~HasTag(" exe" ) & ~HasTag(" mex" ) & ~HasTag(" java" ) & ~HasTag(" python" );
6+ cnomex = ~HasTag(" exe" ) & ~HasTag(" mex" ) & ~HasTag(" java" ) & ~HasTag(" java_exe" ) & ~HasTag(" python" );
137if ispc()
148 cnomex = cnomex & ~HasTag(" unix" );
159else
1610 cnomex = cnomex & ~HasTag(" windows" );
1711end
1812
19- % cmex = HasTag("mex");
20-
21- cjava = HasTag(" java" ) & ~HasTag(" exe" );
22-
2313pkg_root = fullfile(plan .RootFolder , " +stdlib" );
2414test_root = fullfile(plan .RootFolder , " test" );
2515
26- if isMATLABReleaseOlderThan(" R2023b" )
27- plan(" test_exe" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , HasTag(" exe" )), Dependencies= " exe" );
28- elseif isMATLABReleaseOlderThan(" R2024b" )
29- plan(" test_exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Dependencies= " exe" );
16+
17+ if ~isMATLABReleaseOlderThan(" R2023b" )
18+ plan(" clean" ) = matlab .buildtool .tasks .CleanTask ;
3019end
3120
3221if isMATLABReleaseOlderThan(" R2024b" )
3322
34- plan(" test_java" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , cjava ));
35- plan(" test_main" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , cnomex ));
23+ plan(" test_main" ) = matlab .buildtool .Task(Actions = @(context ) test_main(context , cnomex ));
24+
25+ if isMATLABReleaseOlderThan(' R2023b' )
26+ return
27+ end
28+
29+ plan(" test_java" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " java" );
30+ plan(" test_exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Dependencies= " exe" );
3631
3732elseif isMATLABReleaseOlderThan(" R2025a" )
38- % Matlab == R2024b
39- plan(" test:java" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , cjava ));
40- plan(" test:exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Dependencies= " exe" );
41- plan(" test:main" ) = matlab .buildtool .Task(Actions = @(context ) legacy_test(context , cnomex ));
42- % plan("test:mex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cmex), Dependencies="mex");
33+
34+ plan(" test:main" ) = matlab .buildtool .Task(Actions = @(context ) test_main(context , cnomex ));
4335
4436else
45- % Matlab >= R2025a
46- plan(" test:exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Description= " test subprocess" ,...
47- SourceFiles= [pkg_root , test_root + [" /*.cpp" , " /*.c" , " /*.f90" ]], ...
48- RunOnlyImpactedTests= true ,...
49- Dependencies= " exe" , TestResults= " TestResults_exe.xml" , Strict= true );
50-
51- plan(" test:main" ) = matlab .buildtool .tasks .TestTask(test_root , Description= " Test non-MEX targets" ,...
52- Selector= cnomex , ...
53- SourceFiles= pkg_root , RunOnlyImpactedTests= true ,...
54- TestResults= " TestResults_nomex.xml" , Strict= true );
55-
56- % plan("test:mex") = matlab.buildtool.tasks.TestTask(test_root, Description="Test mex targts",...
57- % Selector=cmex, ...
58- % SourceFiles=[pkg_root, plan.RootFolder + "/src"], RunOnlyImpactedTests=true,...
59- % Dependencies="mex", TestResults="TestResults_mex.xml", Strict=true);
60-
61- plan(" test:java" ) = matlab .buildtool .tasks .TestTask(test_root , Description= " test Java targets" , ...
62- Selector= cjava , ...
63- SourceFiles= pkg_root , RunOnlyImpactedTests= true ,...
64- TestResults= " TestResults_java.xml" , Strict= true );
37+
38+ plan(" test:main" ) = matlab .buildtool .tasks .TestTask(...
39+ test_root , Description= " Test non-MEX targets" ,...
40+ Selector= cnomex , ...
41+ SourceFiles= pkg_root , RunOnlyImpactedTests= true ,...
42+ TestResults= " release/TestResults_nomex.xml" , Strict= true );
43+
44+ end
45+
46+
47+ if ~isMATLABReleaseOlderThan(' R2024b' )
48+
49+ plan(" test:exe" ) = matlab .buildtool .tasks .TestTask(test_root , Tag= " exe" , Dependencies= " exe" );
50+
51+ plan(" test:python" ) = matlab .buildtool .tasks .TestTask(...
52+ test_root , Description= " test Python targets" , ...
53+ Tag = " python" , ...
54+ TestResults= " release/TestResults_java.xml" , Strict= true );
55+
56+ plan(" test:java" ) = matlab .buildtool .tasks .TestTask(...
57+ test_root , Description= " test Java targets" , ...
58+ Tag = " java" , ...
59+ TestResults= " release/TestResults_java.xml" , Strict= true );
60+
61+ plan(" test:java_exe" ) = matlab .buildtool .tasks .TestTask(...
62+ test_root , Description= " test Java exe targets" , ...
63+ Tag = " java_exe" , Dependencies= " exe" , ...
64+ TestResults= " release/TestResults_java_exe.xml" , Strict= true );
6565
6666 addons = matlab .addons .installedAddons ;
67- if contains( addons .Name , " Matlab Test" )
67+ if any(ismember( addons .Name , " MATLAB Test" ) )
6868 plan(" coverage" ) = matlab .buildtool .tasks .TestTask(test_root , ...
6969 Description= " code coverage" , ...
7070 Dependencies= " exe" , ...
7171 SourceFiles= pkg_root , ...
72- Selector = cnomex | HasTag( " java " ) | HasTag( " exe " ) | HasTag( " python " ), ...
73- Strict = false ).addCodeCoverage( matlabtest .plugins .codecoverage .StandaloneReport(" coverage-report.html" ));
72+ Strict = false ).addCodeCoverage( ...
73+ matlabtest .plugins .codecoverage .StandaloneReport(" release/ coverage-report.html" ));
7474 end
7575
76- % plan("clean_mex") = matlab.buildtool.Task(Actions=@clean_mex, Description="Clean only MEX files to enable incremental tests");
7776end
7877
79- if isMATLABReleaseOlderThan(" R2023a" ), return , end
80-
8178srcs = [" stdout_stderr_c.c" , " stdin_cpp.cpp" , " printenv.cpp" , " sleep.cpp" ];
82- exes = [" stdout_stderr_c.exe" , " stdin_cpp.exe" , " printenv.exe" , " sleep.exe" ];
8379if ~isempty(get_compiler(" fortran" ))
8480 srcs = [srcs , " stdout_stderr_fortran.f90" , " stdin_fortran.f90" ];
85- exes = [exes , " stdout_stderr_fortran.exe" , " stdin_fortran.exe" ];
8681end
82+ [~ , exes ] = fileparts(srcs );
83+ exes = exes + " .exe" ;
8784
8885srcs = fullfile(test_root , srcs );
8986exes = fullfile(test_root , exes );
9087
9188plan(" exe" ) = matlab .buildtool .Task(Inputs = srcs , Outputs= exes , Actions= @build_exe , ...
92- Description= " build test exe's for test subprocess " );
89+ Description= " build demo executables for testing java_run " );
9390
9491if ~isMATLABReleaseOlderThan(" R2024a" )
9592 plan(" check" ) = matlab .buildtool .tasks .CodeIssuesTask(plan .RootFolder , ...
9693 IncludeSubfolders= true , ...
97- WarningThreshold= 0 , Results= " CodeIssues.sarif" );
98- end
99-
100-
101- %% MexTask
102- if ~isMATLABReleaseOlderThan(" R2024b" )
103- % for s = get_mex_sources()
104- % src = s{1};
105- % [~, name] = fileparts(src(1));
106- %
107- % % name of MEX target function is name of first source file
108- % plan("mex:" + name) = matlab.buildtool.tasks.MexTask(src, pkg_root, ...
109- % Description="Build MEX target " + name, ...
110- % Options=get_compiler_options());
111- % end
94+ WarningThreshold= 0 , Results= " release/CodeIssues.sarif" );
11295end
11396
11497end
11598
11699
117- % function clean_mex(context)
118- % run(context.Plan, "clean", {"mex"});
119- % end
120-
121-
122- function legacy_test(context , sel )
123- import matlab .unittest .TestSuite
124-
125- suite = TestSuite .fromFolder(fullfile(context .Plan .RootFolder , ' test' ));
126- suite = suite .selectIf(sel );
127-
128- runner = testrunner();
129-
130- r = run(runner , suite );
131-
132- assert(~isempty(r ), " No tests were run" )
133- assertSuccess(r )
134- end
135-
136-
137100function publishTask(context )
138101% publish HTML inline documentation strings to individual HTML files
139102outdir = fullfile(context .Plan .RootFolder , ' docs' );
@@ -143,27 +106,3 @@ function publishTask(context)
143106 " https://github.com/geospace-code/matlab-stdlib" , ...
144107 outdir )
145108end
146-
147-
148- function srcs = get_mex_sources(build_all )
149- arguments (Input )
150- build_all (1 ,1 ) logical = false
151- end
152- arguments (Output )
153- srcs cell
154- end
155-
156- srcs = {
157- % "src/remove.cpp", ...
158- % ["src/normalize.cpp", "src/normalize_fs.cpp", "src/pure.cpp"], ...
159- % "src/set_permissions.cpp"
160- };
161-
162- if ~stdlib .has_python() || build_all
163- srcs{end + 1 } = " src/is_char_device.cpp" ;
164- srcs{end + 1 } = [" src/is_admin.cpp" , " src/admin_fs.cpp" ];
165- % srcs{end+1} = "src/disk_available.cpp";
166- % srcs{end+1} = "src/disk_capacity.cpp";
167- end
168-
169- end
0 commit comments