Skip to content

Commit e20632f

Browse files
committed
test: use fixture
1 parent 376b437 commit e20632f

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

test/TestDisk.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ function test_hard_link_count(tc, java_python_sys)
9494

9595

9696
function test_filesystem_type(tc, Ps, all_fun)
97-
tc.assertNotEmpty(which("stdlib." + all_fun + ".filesystem_type"))
9897
try
9998
t = stdlib.filesystem_type(Ps, all_fun);
10099
catch e

test/TestHDF5.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function test_dirs(tc)
3838
function setup_file(tc)
3939
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture())
4040

41-
tc.file = fullfile(pwd(), class(tc));
41+
tc.file = fullfile(pwd(), class(tc) + ".h5");
4242

4343
% create test data first, so that parallel tests works
4444
stdlib.h5save(tc.file, '/A0', tc.A0)

test/TestNetCDF.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function test_dirs(tc)
2121

2222

2323
function setup_file(tc)
24+
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture())
2425

2526
tc.A0 = 42.;
2627
tc.A1 = [42.; 43.];
@@ -32,8 +33,7 @@ function setup_file(tc)
3233
tc.utf1 = [tc.utf0; ""];
3334
tc.utf2 = [tc.utf0, ""; "📞", "👋"];
3435

35-
td = createTempdir(tc);
36-
tc.file = td + "/basic.nc";
36+
tc.file = fullfile(pwd(), class(tc) + ".nc");
3737

3838
% create test data first, so that parallel tests works
3939
stdlib.ncsave(tc.file, 'A0', tc.A0)

test/TestSubprocess.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
methods(TestClassSetup)
1111
function test_dirs(tc)
1212
pkg_path(tc)
13+
14+
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture())
1315
end
1416
end
1517

@@ -150,6 +152,7 @@ function test_java_stdin(tc, lang_in)
150152

151153

152154
function test_java_cwd(tc)
155+
% distinct from the working directory
153156
td = createTempdir(tc);
154157

155158
if ispc

test/private/createTempdir.m

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@
33
tc (1,1) matlab.unittest.TestCase
44
end
55

6-
try
7-
td = tc.createTemporaryFolder();
8-
catch e
9-
if e.identifier ~= "MATLAB:noSuchMethodOrField"
10-
rethrow(e)
11-
end
6+
fx = matlab.unittest.fixtures.WorkingFolderFixture();
127

13-
td = tempname();
14-
[ok, err] = mkdir(td);
15-
tc.assumeTrue(ok, err)
16-
tc.addTeardown(@() rmdir(td, 's'))
17-
end
8+
tc.applyFixture(fx);
9+
10+
td = fx.Folder;
1811

1912
assert(nargout == 1, "use this function to set a test Property or variable directly")
2013

test_main.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function test_main(context, sel)
3737
assert(Lf == 0, sprintf("%d / %d tests failed", Lf, Lt))
3838

3939
if Lk
40-
fprintf("%d / %d tests skipped", Lk, Lt);
40+
fprintf("%d / %d tests skipped\n", Lk, Lt);
4141
end
4242

4343
fprintf("%d / %d tests succeeded\n", Lok, Lt);

0 commit comments

Comments
 (0)