Skip to content

Commit d14087d

Browse files
committed
test selection
1 parent 33e5b10 commit d14087d

39 files changed

+259
-350
lines changed

private/releaseTestTags.m

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
%% RELEASETESTTAGS generate test tags based on MATLAB release version
2+
% this avoids cluttering test results with Incomplete due to assumeFalse(isMATLABReleaseOlderThan)
3+
4+
function tags = releaseTestTags()
5+
6+
try
7+
r = matlabRelease().Release;
8+
catch
9+
r = "R" + version('-release');
10+
end
11+
12+
releasesKnown = [
13+
"R2019b", "R2020a", "R2020b", "R2021a", "R2021b", ...
14+
"R2022a", "R2022b", "R2023a", "R2023b", "R2024a", ...
15+
"R2024b", "R2025a", "R2025b"];
16+
17+
% takes releases not newer than this release
18+
idx = find(releasesKnown >= r, 1, 'first');
19+
if ~isempty(idx)
20+
tags = releasesKnown(1:idx);
21+
end
22+
23+
end

test/TestAbsolute.m

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,16 @@
1111

1212

1313
methods(TestClassSetup)
14-
function pkg_path(tc)
15-
p = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
16-
tc.applyFixture(p)
17-
end
18-
19-
function set_temp_wd(tc)
20-
if isMATLABReleaseOlderThan('R2022a')
21-
tc.td = tempname();
22-
mkdir(tc.td);
23-
else
24-
tc.td = tc.createTemporaryFolder();
25-
end
26-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(tc.td))
27-
end
28-
end
14+
function test_dirs(tc)
15+
tc.td = createTempdir(tc);
16+
pkg_path(tc)
2917

30-
methods(TestClassTeardown)
31-
function remove_temp_wd(tc)
32-
if isMATLABReleaseOlderThan('R2022a')
33-
[s, m, i] = rmdir(tc.td, 's');
34-
if ~s, warning(i, "Failed to remove temporary directory %s: %s", tc.td, m); end
35-
end
18+
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(tc.td))
3619
end
3720
end
3821

3922

40-
methods(Test, TestTags="pure")
23+
methods(Test, TestTags=["R2019b", "pure"])
4124

4225
function test_absolute1arg(tc, p1)
4326

test/TestCanonical.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
end
1414

1515
methods(TestClassSetup)
16-
function pkg_path(tc)
17-
fsp = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
18-
tc.applyFixture(fsp)
16+
function test_dirs(tc)
17+
pkg_path(tc)
1918
end
2019
end
2120

2221

23-
methods(Test, TestTags="impure")
22+
methods(Test, TestTags=["R2019b", "impure"])
2423

2524
function test_canonical(tc, p, backend)
2625
try

test/TestDisk.m

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
end
1717

1818
methods(TestClassSetup)
19-
function pkg_path(tc)
20-
p = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
21-
tc.applyFixture(p)
19+
function test_dirs(tc)
20+
pkg_path(tc)
2221
end
2322
end
2423

25-
methods (Test)
24+
methods (Test, TestTags=["R2019b", "impure"])
2625

2726
function test_disk_ac(tc, Ps, all_fun, disk_ac_name)
2827
n = "stdlib." + all_fun + "." + disk_ac_name;
@@ -113,10 +112,7 @@ function test_filesystem_type(tc, Ps, all_fun)
113112

114113
function test_remove_file(tc)
115114

116-
tc.assumeFalse(isMATLABReleaseOlderThan('R2022a'))
117-
d = tc.createTemporaryFolder();
118-
119-
f = tempname(d);
115+
f = tempname();
120116

121117
tc.verifyFalse(stdlib.remove(f), "should not succeed at removing non-existant path")
122118

test/TestExists.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
end
1717

1818
methods(TestClassSetup)
19-
function pkg_path(tc)
20-
p = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
21-
tc.applyFixture(p)
19+
function test_dirs(tc)
20+
pkg_path(tc)
2221
end
2322
end
2423

25-
methods (Test, TestTags="impure")
24+
methods (Test, TestTags=["R2019b", "impure"])
2625

2726
function test_exists(tc, Ps)
2827
ok = stdlib.exists(Ps{1});
@@ -74,6 +73,5 @@ function test_is_char_device(tc, icm)
7473
tc.verifyTrue(y)
7574
end
7675

77-
7876
end
7977
end

test/TestExpanduser.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
end
66

77
methods(TestClassSetup)
8-
function pkg_path(tc)
9-
fsp = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
10-
tc.applyFixture(fsp)
8+
function test_dirs(tc)
9+
pkg_path(tc)
1110
end
1211
end
1312

14-
methods(Test, TestTags="impure")
13+
methods(Test, TestTags=["R2019b", "impure"])
1514

1615
function test_expanduser(tc, p)
1716
tc.verifyEqual(stdlib.expanduser(p{1}), p{2})

test/TestFileImpure.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99

1010
methods(TestClassSetup)
11-
function pkg_path(tc)
12-
p = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
13-
tc.applyFixture(p)
11+
function test_dirs(tc)
12+
pkg_path(tc)
1413
end
1514
end
1615

1716

18-
methods (Test, TestTags="impure")
17+
methods (Test, TestTags=["R2019b", "impure"])
1918

2019
function test_file_size(tc, p_file_size)
2120
s = stdlib.file_size(p_file_size);

test/TestFilePure.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
classdef TestFilePure < matlab.unittest.TestCase
22

33
methods(TestClassSetup)
4-
function pkg_path(tc)
5-
fsp = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
6-
tc.applyFixture(fsp)
4+
function test_dirs(tc)
5+
pkg_path(tc)
76
end
87
end
98

109

11-
methods (Test, TestTags="pure")
10+
methods (Test, TestTags=["R2019b", "pure"])
1211

1312
function test_posix(tc)
1413

test/TestFilename.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
end
88

99
methods(TestClassSetup)
10-
function pkg_path(tc)
11-
msp = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
12-
tc.applyFixture(msp)
10+
function test_dirs(tc)
11+
pkg_path(tc)
1312
end
1413
end
1514

16-
methods (Test, TestTags="pure")
15+
methods (Test, TestTags=["R2019b", "pure"])
1716

1817
function test_filename(tc, p, backend)
1918
fn = stdlib.filename(p{1}, backend);

test/TestHDF4.m

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ function setup_file(tc)
99
import matlab.unittest.constraints.IsFile
1010
tc.file = fullfile(matlabroot, "toolbox/matlab/demos/example.hdf");
1111
tc.assumeThat(tc.file, IsFile)
12-
end
1312

14-
function pkg_path(tc)
15-
msp = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
16-
tc.applyFixture(msp)
13+
pkg_path(tc)
1714
end
1815
end
1916

20-
methods (Test, TestTags="hdf4")
17+
methods (Test, TestTags=["R2019b", "hdf4"])
2118

2219
function test_exists(tc)
2320
import matlab.unittest.constraints.IsScalar

0 commit comments

Comments
 (0)