Skip to content

Commit 138a8eb

Browse files
committed
test permission: use own test file
1 parent f4c7c8d commit 138a8eb

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

test/TestPermissions.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}) ...
22
TestPermissions < matlab.unittest.TestCase
33

4+
properties
5+
file = 'perm.txt'
6+
end
7+
48
properties (TestParameter)
5-
Ps = {".", pwd(), "", tempname(), mfilename('fullpath') + ".m"}
9+
Ps = {".", pwd(), "", tempname(), 'perm.txt'}
610
end
711

812

9-
methods(TestMethodSetup)
13+
methods(TestClassSetup)
1014
function w_dirs(tc)
1115
tc.applyFixture(matlab.unittest.fixtures.WorkingFolderFixture());
16+
tc.assertTrue(stdlib.touch(tc.file))
1217
end
1318
end
1419

1520

16-
methods (Test, TestTags={'R2017b'})
21+
methods (Test, TestTags={'R2017a'})
1722

1823
function test_get_permissions(tc, Ps)
1924
import matlab.unittest.constraints.StartsWithSubstring
2025

2126
[p, b] = stdlib.get_permissions(Ps);
22-
tc.verifyClass(p, "char")
27+
tc.verifyClass(p, 'char')
2328

2429
if ~stdlib.exists(Ps)
2530
tc.verifyEmpty(p)
@@ -30,8 +35,8 @@ function test_get_permissions(tc, Ps)
3035
tc.assertEqual(b, 'native')
3136
end
3237

33-
tc.verifyThat(p, StartsWithSubstring("r"))
34-
if isfile(p) && strcmp(stdlib.suffix(p), '.m')
38+
tc.verifyThat(p, StartsWithSubstring('r'))
39+
if strcmp(Ps, tc.file)
3540
tc.verifyEqual(p(3), '-')
3641
end
3742
end
@@ -44,7 +49,6 @@ function test_get_permissions_exe(tc)
4449
matlab_exe = [matlab_exe, '.exe'];
4550
end
4651

47-
tc.assertTrue(isfile(matlab_exe))
4852
p = stdlib.get_permissions(matlab_exe);
4953

5054
tc.assertNotEmpty(p)

test/TestWhich.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function test_which_name(tc)
2525
% stdlib.which()
2626
% virus scanners may block stdlib.which("cmd.exe") on Windows
2727
for n = names
28-
exe = stdlib.which(n);
28+
exe = stdlib.which(char(n)); % char() for Matlab < R2017b
2929
tc.verifyNotEmpty(exe, "Executable not found: " + n)
3030
tc.verifyTrue(stdlib.is_exe(exe), "Executable is not executable: " + n)
3131
end

0 commit comments

Comments
 (0)