Skip to content

Commit d7a4480

Browse files
committed
test: improve tempdir efficiency
1 parent d8bfdc2 commit d7a4480

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

test/TestAbsolute.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
methods(TestClassSetup)
1414
function test_dirs(tc)
15-
tc.td = createTempdir(tc);
1615
pkg_path(tc)
16+
tc.td = createTempdir(tc);
1717

1818
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(tc.td))
1919
end

test/private/createTempdir.m

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

6-
if stdlib.matlabOlderThan('R2022a')
6+
try
7+
td = tc.createTemporaryFolder();
8+
catch e
9+
if e.identifier ~= "MATLAB:UndefinedFunction"
10+
rethrow(e)
11+
end
12+
713
td = tempname();
814
[ok, err] = mkdir(td);
915
tc.assumeTrue(ok, err)
1016
tc.addTeardown(@() rmdir(td, 's'))
11-
else
12-
td = tc.createTemporaryFolder();
1317
end
1418

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

0 commit comments

Comments
 (0)