Skip to content

Commit 0f6cc62

Browse files
committed
test: improve mex built detection
1 parent a243ffa commit 0f6cc62

File tree

5 files changed

+24
-30
lines changed

5 files changed

+24
-30
lines changed

test/TestDisk.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
methods (Test)
88

99
function test_disk_available(tc, Ps)
10-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(".."))
11-
tc.assumeEqual(exist("+stdlib/disk_available", "file"), 3)
10+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/disk_available." + mexext))
1211

1312
zero = uint64(0);
1413

@@ -20,8 +19,7 @@ function test_disk_available(tc, Ps)
2019
end
2120

2221
function test_disk_capacity(tc, Ps)
23-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(".."))
24-
tc.assumeEqual(exist("+stdlib/disk_capacity", "file"), 3)
22+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/disk_capacity." + mexext))
2523

2624
zero = uint64(0);
2725

test/TestMex.m

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
methods (Test)
44

55
function test_is_char_device(tc)
6-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(".."))
7-
% matlab exist() doesn't work for MEX detection with ".." leading path
8-
tc.assumeEqual(exist("+stdlib/is_char_device", "file"), 3)
6+
7+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/is_char_device." + mexext))
98

109
% /dev/stdin may not be available on CI systems
1110
if ispc
@@ -19,16 +18,14 @@ function test_is_char_device(tc)
1918

2019

2120
function test_is_admin(tc)
22-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(".."))
23-
tc.assumeEqual(exist("+stdlib/is_admin", "file"), 3)
21+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/is_admin." + mexext))
2422

2523
tc.verifyClass(stdlib.is_admin(), "logical")
2624
end
2725

2826

2927
function test_unlink_file(tc)
30-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(".."))
31-
tc.assumeEqual(exist("+stdlib/unlink", "file"), 3)
28+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/unlink." + mexext))
3229

3330
d = tc.createTemporaryFolder();
3431

@@ -42,8 +39,7 @@ function test_unlink_file(tc)
4239

4340

4441
function test_unlink_empty_dir(tc)
45-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(".."))
46-
tc.assumeEqual(exist("+stdlib/unlink", "file"), 3)
42+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/unlink." + mexext))
4743

4844
d = tc.createTemporaryFolder();
4945

@@ -52,8 +48,7 @@ function test_unlink_empty_dir(tc)
5248

5349

5450
function test_unlink_recursive(tc)
55-
tc.applyFixture(matlab.unittest.fixtures.CurrentFolderFixture(".."))
56-
tc.assumeEqual(exist("+stdlib/unlink", "file"), 3)
51+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/unlink." + mexext))
5752

5853
d = tc.createTemporaryFolder();
5954

test/TestNormalize.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
d = init_drop_slash()
66
end
77

8+
89
methods (Test)
910
function test_normalize(tc, p)
1011
tc.verifyEqual(stdlib.normalize(p{1}), p{2})
@@ -49,15 +50,13 @@ function test_drop_slash(tc, d)
4950
function d = init_drop_slash()
5051
d = {...
5152
{"", ""}, ...
52-
{'a', 'a'}, ...
5353
{"a/", "a"}, ...
5454
{"a/b", "a/b"}, ...
5555
{"a/b/", "a/b"}, ...
5656
{"////", "/"}, ...
5757
{"a////b", "a/b"}, ...
5858
{"a//b//", "a/b"}, ...
59-
{"///", "/"}, ...
60-
{'/', '/'}};
59+
{"///", "/"}};
6160
if ispc()
6261
dd = {...
6362
{"c:/", "c:/"}, ...
@@ -67,4 +66,15 @@ function test_drop_slash(tc, d)
6766
};
6867
d = [d, dd];
6968
end
69+
70+
if ~isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/drop_slash." + mexext)
71+
72+
dd = {...
73+
{'a', 'a'}, ...
74+
{'/', '/'}
75+
};
76+
d = [d, dd];
77+
78+
end
79+
7080
end

test/TestPermissions.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ function test_get_permissions(tc, Ps)
2525
function test_set_permissions(tc)
2626

2727
import matlab.unittest.constraints.StartsWithSubstring
28-
import matlab.unittest.fixtures.CurrentFolderFixture
2928

30-
tc.applyFixture(CurrentFolderFixture(".."))
31-
% matlab exist() doesn't work for MEX detection with ".." leading path
32-
33-
tc.assumeEqual(exist("+stdlib/set_permissions", "file"), 3)
29+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/set_permissions." + mexext))
3430

3531
tf = tc.createTemporaryFolder();
3632

test/TestRelative.m

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

88
methods(TestClassSetup)
99
function mex_required(tc)
10-
import matlab.unittest.fixtures.CurrentFolderFixture
11-
12-
tc.applyFixture(CurrentFolderFixture(".."))
13-
% matlab exist() doesn't work for MEX detection with ".." leading path
14-
15-
tc.assumeEqual(exist("+stdlib/relative_to", "file"), 3)
16-
tc.assumeEqual(exist("+stdlib/proximate_to", "file"), 3)
10+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/relative_to." + mexext))
11+
tc.assumeTrue(isfile(fileparts(mfilename("fullpath")) + "/../+stdlib/proximate_to." + mexext))
1712
end
1813
end
1914

0 commit comments

Comments
 (0)