Skip to content

Commit d3721e0

Browse files
committed
test:is_exe more complete
1 parent d17fa71 commit d3721e0

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

test/TestIsExe.m

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
classdef TestIsExe < matlab.unittest.TestCase
22

33
properties (TestParameter)
4+
% we don't test plain files like Readme.md b/c some systems like Matlab Online
5+
% have permissions like 777 everywhere
46
p = {
5-
{fileparts(mfilename('fullpath')) + "/../Readme.md", false}, ...
67
{"not-exist", false}, ...
78
{'', false}, ...
89
{"", false}, ...
910
{'.', false}, ...
1011
{matlab_path(), true}
1112
}
13+
peb = init_exe_bin()
1214
backend = {'java', 'python', 'native', 'legacy'}
1315
end
1416

@@ -30,18 +32,10 @@ function test_is_exe(tc, p, backend)
3032
end
3133

3234

33-
function test_is_executable_binary(tc)
35+
function test_is_executable_binary(tc, peb)
3436

35-
if ispc()
36-
f = matlab_path();
37-
else
38-
f = '/bin/ls';
39-
end
40-
41-
tc.assumeThat(f, matlab.unittest.constraints.IsFile)
42-
43-
b = stdlib.is_executable_binary(f);
44-
tc.assumeTrue(b, f)
37+
b = stdlib.is_executable_binary(peb{1});
38+
tc.verifyEqual(b, peb{2}, peb{1})
4539

4640
end
4741
end
@@ -56,3 +50,20 @@ function test_is_executable_binary(tc)
5650
f = f + ".exe";
5751
end
5852
end
53+
54+
55+
function peb = init_exe_bin()
56+
57+
peb = {
58+
{fileparts(mfilename('fullpath')) + "/../Readme.md", false}; ...
59+
{matlab_path, false}; ...
60+
{'/bin/ls', true}; ...
61+
{tempname(), false}
62+
};
63+
64+
if ispc
65+
peb{2}{2} = true;
66+
peb{3}{2} = false;
67+
end
68+
69+
end

0 commit comments

Comments
 (0)