Skip to content

Commit 155ca83

Browse files
committed
testing more rigorous by having selectable sets of tags
1 parent 1424cf6 commit 155ca83

File tree

15 files changed

+133
-88
lines changed

15 files changed

+133
-88
lines changed

.github/workflows/ci-nojvm.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- "**.h"
88
- "**.cpp"
99
- ".github/workflows/ci-nojvm.yml"
10+
- ".github/workflows/*/action.yml"
1011
- "!private/publish_gen_index_html.m"
1112
- "!octave_build.m"
1213
- "!scripts/**"
@@ -41,6 +42,3 @@ jobs:
4142

4243
- name: No Java, no Mex tests
4344
uses: ./.github/workflows/composite-nomex
44-
45-
- name: No Java, with MEX tests
46-
uses: ./.github/workflows/composite-mex

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- "**.h"
88
- "**.cpp"
99
- ".github/workflows/ci.yml"
10+
- ".github/workflows/*/action.yml"
1011
- "!private/publish_gen_index_html.m"
1112
- "!octave_build.m"
1213
- "!scripts/**"
@@ -37,7 +38,7 @@ jobs:
3738
- os: windows-latest
3839
release: R2025a
3940
- os: windows-latest
40-
release: R2023a
41+
release: R2023b
4142

4243

4344
steps:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ runs:
77
steps:
88

99
- name: Mex Test
10-
if: ${{ matrix.release >= 'R2023a' || startsWith(matrix.release, 'latest') }}
10+
if: ${{ matrix.release >= 'R2023b' || startsWith(matrix.release, 'latest') }}
1111
uses: matlab-actions/run-build@v2
1212
with:
1313
startup-options: ${{ matrix.startup-options }} -logfile ${{ matrix.release }}-${{ runner.os }}-test.log
14-
tasks: mex test
14+
tasks: ${{ matrix.release < 'R2024b' && !startsWith(matrix.release, 'latest') && 'test_mex test_exe' || 'test:mex test:exe' }}

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,29 @@ runs:
77
steps:
88

99
- name: Non-Mex Test
10-
if: ${{ matrix.release >= 'R2023a' || startsWith(matrix.release, 'latest') }}
10+
if: ${{ matrix.release >= 'R2024b' || startsWith(matrix.release, 'latest') }}
1111
uses: matlab-actions/run-build@v2
1212
with:
1313
startup-options: ${{ matrix.startup-options }}
14-
tasks: test
14+
tasks: ${{ contains(matrix.startup-options, '-nojvm') && 'test:nojavamex' || 'test:nomex' }}
15+
16+
17+
- name: Non-Mex Test (< R2024b)
18+
if: ${{ matrix.release >= 'R2023b' && matrix.release < 'R2024b' && !startsWith(matrix.release, 'latest') }}
19+
uses: matlab-actions/run-build@v2
20+
with:
21+
startup-options: ${{ matrix.startup-options }}
22+
tasks: test_nomex
23+
1524

1625
# note: "source-folder" is necessary, but watch out as it adds all subfolders to path too
1726
# https://github.com/matlab-actions/run-tests?tab=readme-ov-file#run-matlab-tests
18-
- name: Run tests (manual)
19-
if: ${{ matrix.release < 'R2023a' && !startsWith(matrix.release, 'latest') }}
20-
uses: matlab-actions/run-tests@v2
27+
- name: Non-mex tests (< R2023b)
28+
if: ${{ matrix.release < 'R2023b' && !startsWith(matrix.release, 'latest') }}
29+
uses: matlab-actions/run-command@v2
2130
with:
22-
source-folder: ${{ github.workspace }}
23-
select-by-folder: test
24-
strict: false
25-
startup-options: -logfile ${{ matrix.release }}-${{ runner.os }}-test.log
31+
command: addpath("${{ github.workspace }}"), test_nomex
32+
startup-options: -sd ./test -logfile ${{ matrix.release }}-${{ runner.os }}-test.log
2633

2734

2835
- name: upload logfile

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Filesystem.class
22
CodeIssues.sarif
3-
TestResults.xml
4-
code-coverage.xml
3+
*.xml
54

65
resources/
76
.buildtool/

buildfile.m

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function plan = buildfile
2-
assert(~isMATLABReleaseOlderThan("R2023a"), "MATLAB R2023a or newer is required for this buildfile")
2+
import matlab.unittest.selectors.HasTag
3+
assert(~isMATLABReleaseOlderThan("R2023b"), "MATLAB R2023b or newer is required for this buildfile")
34

45
plan = buildplan(localfunctions);
56

@@ -8,14 +9,49 @@
89
addpath(plan.RootFolder)
910

1011
%% Self-test setup
11-
if isMATLABReleaseOlderThan("R2023b")
12-
plan("test") = matlab.buildtool.Task(Actions=@legacy_test);
13-
elseif isMATLABReleaseOlderThan("R2024a")
14-
plan("test") = matlab.buildtool.tasks.TestTask("test", Strict=false);
12+
plan("clean") = matlab.buildtool.tasks.CleanTask;
13+
14+
cnomex = ~HasTag("exe") & ~HasTag("mex");
15+
if isMATLABReleaseOlderThan("R2024b")
16+
cnomex = cnomex & ~HasTag("symlink");
17+
end
18+
19+
cmex = ~HasTag("exe") & HasTag("mex");
20+
cnojavamex = ~HasTag("java") & cnomex;
21+
22+
23+
if isMATLABReleaseOlderThan("R2024b")
24+
25+
plan("test_exe") = matlab.buildtool.tasks.TestTask("test", Tag="exe", Dependencies="exe");
26+
plan("test_nomex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cnomex), Dependencies="clean");
27+
plan("test_mex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cmex), Dependencies="mex");
28+
plan("test_nojavamex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cnojavamex), Dependencies="clean");
29+
30+
elseif isMATLABReleaseOlderThan("R2025a")
31+
32+
plan("test:exe") = matlab.buildtool.tasks.TestTask("test", Tag="exe", Dependencies="exe");
33+
plan("test:nomex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cnomex), Dependencies="clean");
34+
plan("test:mex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cmex), Dependencies="mex");
35+
plan("test:nojavamex") = matlab.buildtool.Task(Actions=@(context) legacy_test(context, cnojavamex), Dependencies="clean");
36+
1537
else
1638
% can't use SourceFiles= if "mex" Task was run, even if plan("test").DisableIncremental = true;
1739
% this means incremental tests can't be used with MEX files (as of R2024b)
18-
plan("test") = matlab.buildtool.tasks.TestTask("test", Strict=false, TestResults="TestResults.xml");
40+
plan("test:exe") = matlab.buildtool.tasks.TestTask("test", Tag="exe", ...
41+
Dependencies="exe", TestResults="TestResults_exe.xml", Strict=false);
42+
43+
plan("test:nomex") = matlab.buildtool.tasks.TestTask("test", ...
44+
Selector=cnomex, ...
45+
Dependencies="clean", TestResults="TestResults_nomex.xml", Strict=false);
46+
47+
plan("test:mex") = matlab.buildtool.tasks.TestTask("test", ...
48+
Selector=cmex, ...
49+
Dependencies="mex", TestResults="TestResults_mex.xml", Strict=false);
50+
51+
plan("test:nojavamex") = matlab.buildtool.tasks.TestTask("test", ...
52+
Selector=cnojavamex, ...
53+
Dependencies="clean", TestResults="TestResults_nojavamex.xml", Strict=false);
54+
1955
end
2056

2157
td = plan.RootFolder + "/test";
@@ -26,11 +62,6 @@
2662
exes = [exes, td+"/stdout_stderr_fortran.exe", td+"/stdin_fortran.exe"];
2763
end
2864
plan("exe") = matlab.buildtool.Task(Inputs=srcs, Outputs=exes, Actions=@build_exe);
29-
plan("test").Dependencies = "exe";
30-
31-
if ~isMATLABReleaseOlderThan("R2023b")
32-
plan("clean") = matlab.buildtool.tasks.CleanTask;
33-
end
3465

3566
if ~isMATLABReleaseOlderThan("R2024a")
3667
plan("check") = matlab.buildtool.tasks.CodeIssuesTask(pkg_name, IncludeSubfolders=true, ...
@@ -82,9 +113,15 @@ function legacy_mex(context, compiler_opt, linker_opt)
82113
end
83114

84115

85-
function legacy_test(context)
86-
r = runtests(context.Plan.RootFolder + "/test", Strict=false);
87-
% Parallel Computing Toolbox takes more time to startup than is worth it for this task
116+
function legacy_test(context, sel)
117+
import matlab.unittest.TestSuite
118+
119+
suite = TestSuite.fromFolder(context.Plan.RootFolder + "/test");
120+
suite = suite.selectIf(sel);
121+
122+
runner = testrunner();
123+
124+
r = run(runner, suite);
88125

89126
assert(~isempty(r), "No tests were run")
90127
assertSuccess(r)
@@ -256,10 +293,6 @@ function build_exe(context)
256293
if msvc
257294
std = "/std:c++17";
258295
% on Windows, Matlab doesn't register unsupported MSVC or oneAPI
259-
elseif cxx.Name == "Xcode Clang++"
260-
if isMATLABReleaseOlderThan("R2023b") && stdlib.version_atleast(cxx.Version, "15.0")
261-
warning("Xcode Clang++ " + cxx.Version + " may not support this Matlab version")
262-
end
263296
elseif ~strlength(compiler_id) && cxx.ShortName == "g++"
264297
if ~stdlib.version_atleast(cxx.Version, "8")
265298
warning("g++ 8 or newer is required for MEX, detected g++" + cxx.Version)

test/TestDisk.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,23 @@
44
Ps = {".", "", "not-exist"}
55
end
66

7-
methods (Test)
7+
methods(Test, TestTags = "mex")
8+
9+
function test_mex_disk_available(tc)
10+
import matlab.unittest.constraints.IsFile
11+
tc.assertThat(fileparts(mfilename("fullpath")) + "/../+stdlib/disk_available." + mexext, IsFile)
12+
end
13+
14+
function test_mex_disk_capacity(tc)
15+
import matlab.unittest.constraints.IsFile
16+
tc.assertThat(fileparts(mfilename("fullpath")) + "/../+stdlib/disk_capacity." + mexext, IsFile)
17+
end
18+
19+
end
20+
21+
methods (Test, TestTags = "java")
822

923
function test_disk_available(tc, Ps)
10-
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/disk_available." + mexext))
1124

1225
zero = uint64(0);
1326

@@ -19,7 +32,6 @@ function test_disk_available(tc, Ps)
1932
end
2033

2134
function test_disk_capacity(tc, Ps)
22-
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/disk_capacity." + mexext))
2335

2436
zero = uint64(0);
2537

test/TestHash.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@
55
{'sha-256', '2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'}}
66
end
77

8-
methods(TestClassSetup)
9-
function java_required(tc)
10-
tc.assumeTrue(stdlib.has_java())
11-
end
12-
end
13-
148

15-
methods (Test)
9+
methods (Test, TestTags="java")
1610

1711

1812
function test_hash_text(tc, Ph)

test/TestJava.m

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@
44
Ps = {"."}
55
end
66

7-
methods(TestClassSetup)
8-
function java_required(tc)
9-
tc.assumeTrue(stdlib.has_java())
10-
end
11-
end
12-
137

14-
methods(Test)
8+
methods(Test, TestTags="java")
159

1610
function test_inode(tc)
1711
tc.assumeFalse(ispc(), "not for Windows")

test/TestMex.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
classdef TestMex < matlab.unittest.TestCase
22

3-
methods (Test)
3+
methods (Test, TestTags = "mex")
44

55
function test_is_char_device(tc)
6-
7-
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/is_char_device." + mexext))
8-
96
% /dev/stdin may not be available on CI systems
107
if ispc
118
n = "NUL";
@@ -18,14 +15,13 @@ function test_is_char_device(tc)
1815

1916

2017
function test_is_admin(tc)
21-
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/is_admin." + mexext))
22-
2318
tc.verifyClass(stdlib.is_admin(), "logical")
2419
end
2520

2621

2722
function test_remove_file(tc)
28-
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/remove." + mexext))
23+
import matlab.unittest.constraints.IsFile
24+
tc.assertThat(fileparts(mfilename("fullpath")) + "/../+stdlib/remove." + mexext, IsFile)
2925

3026
d = tc.createTemporaryFolder();
3127

@@ -39,7 +35,8 @@ function test_remove_file(tc)
3935

4036

4137
function test_remove_empty_dir(tc)
42-
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/remove." + mexext))
38+
import matlab.unittest.constraints.IsFile
39+
tc.assertThat(fileparts(mfilename("fullpath")) + "/../+stdlib/remove." + mexext, IsFile)
4340

4441
d = tc.createTemporaryFolder();
4542

@@ -48,7 +45,8 @@ function test_remove_empty_dir(tc)
4845

4946

5047
function test_remove_recursive(tc)
51-
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/remove." + mexext))
48+
import matlab.unittest.constraints.IsFile
49+
tc.assertThat(fileparts(mfilename("fullpath")) + "/../+stdlib/remove." + mexext, IsFile)
5250

5351
d = tc.createTemporaryFolder();
5452

0 commit comments

Comments
 (0)