Skip to content

Commit 123fcba

Browse files
committed
test: setup path first to avoid race
1 parent abf74b0 commit 123fcba

File tree

7 files changed

+38
-15
lines changed

7 files changed

+38
-15
lines changed

+stdlib/exists.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use_java (1,1) logical = false
1313
end
1414

15+
1516
if use_java
1617

1718
% https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#exists(java.nio.file.Path,java.nio.file.LinkOption...)

test/TestHDF4.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
end
66

77
methods (TestClassSetup)
8+
89
function setup_path(tc)
10+
import matlab.unittest.fixtures.PathFixture
11+
cwd = fileparts(mfilename("fullpath"));
12+
top = fullfile(cwd, "..");
13+
tc.applyFixture(PathFixture(top))
14+
end
15+
16+
function setup_file(tc)
917
import matlab.unittest.constraints.IsFile
1018
tc.TestData.basic = fullfile(matlabroot, "toolbox/matlab/demos/example.hdf");
1119
tc.assumeThat(tc.TestData.basic, IsFile)

test/TestHash.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@
77

88
methods(TestClassSetup)
99

10-
function has_java(tc)
11-
tc.assumeTrue(stdlib.has_java)
12-
end
13-
1410
function setup_path(tc)
1511
import matlab.unittest.fixtures.PathFixture
1612
cwd = fileparts(mfilename("fullpath"));
1713
top = fullfile(cwd, "..");
1814
tc.applyFixture(PathFixture(top))
15+
16+
tc.assumeTrue(stdlib.has_java)
1917
end
18+
2019
end
2120

2221
methods (Test, ParameterCombination = 'sequential')

test/TestJava.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
methods(TestClassSetup)
44

5-
function has_java(tc)
6-
tc.assumeTrue(stdlib.has_java)
5+
function setup_path(tc)
6+
import matlab.unittest.fixtures.PathFixture
7+
cwd = fileparts(mfilename("fullpath"));
8+
top = fullfile(cwd, "..");
9+
tc.applyFixture(PathFixture(top))
10+
11+
tc.assumeTrue(stdlib.has_java)
712
end
813

914
end

test/TestSubprocess.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
methods (TestClassSetup)
44

5-
function has_java(tc)
6-
tc.assumeTrue(stdlib.has_java)
7-
end
8-
95
function setup_path(tc)
106
import matlab.unittest.fixtures.PathFixture
117
cwd = fileparts(mfilename("fullpath"));
128
top = fullfile(cwd, "..");
139
tc.applyFixture(PathFixture(top))
10+
11+
tc.assumeTrue(stdlib.has_java)
1412
end
13+
1514
end
1615

1716
methods (Test)

test/TestWSL.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
methods (TestClassSetup)
44

5-
function has_java(tc)
6-
tc.assumeTrue(stdlib.has_java)
7-
end
8-
95
function setup_path(tc)
106
import matlab.unittest.fixtures.PathFixture
117
cwd = fileparts(mfilename("fullpath"));
128
top = fullfile(cwd, "..");
139
tc.applyFixture(PathFixture(top))
10+
11+
tc.assumeTrue(stdlib.has_java)
1412
end
13+
1514
end
1615

1716
methods (Test)

test/TestWhich.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
classdef TestWhich < matlab.unittest.TestCase
22

3+
methods(TestClassSetup)
4+
5+
function setup_path(tc)
6+
import matlab.unittest.fixtures.PathFixture
7+
cwd = fileparts(mfilename("fullpath"));
8+
top = fullfile(cwd, "..");
9+
tc.applyFixture(PathFixture(top))
10+
end
11+
12+
end
13+
14+
315
methods (Test)
416

517
function test_which_name(tc)
@@ -51,4 +63,4 @@ function test_is_exe_which_fullpath(tc)
5163

5264
end
5365

54-
end
66+
end

0 commit comments

Comments
 (0)