Skip to content

Commit 65708dd

Browse files
committed
test samepath: more robust cwd case
1 parent b81683e commit 65708dd

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

+stdlib/perl_exe.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
rethrow(e)
2424
end
2525

26-
if s == 0 && isfile(r)
26+
if s == 0 && stdlib.is_file(r)
2727
exe = r;
2828
perle = r;
2929
end
3030

3131
end
3232

33-
%!assert (isfile(stdlib.perl_exe()))
33+
%!assert (isfile(stdlib.perl_exe()))

test/TestHDF4.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2017b', 'hdf4'}) ...
2+
TestTags = {'R2017a', 'hdf4'}) ...
33
TestHDF4 < matlab.unittest.TestCase
44

55
properties
@@ -8,7 +8,7 @@
88

99
methods (TestClassSetup)
1010
function check_file(tc)
11-
tc.assumeTrue(isfile(tc.file), "HDF4 file not found: " + tc.file)
11+
tc.assumeTrue(stdlib.is_file(tc.file), "HDF4 file not found: " + tc.file)
1212
end
1313
end
1414

test/TestSame.m

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,56 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2017b', 'impure'}) ...
2+
TestTags = {'R2017a'}) ...
33
TestSame < matlab.unittest.TestCase
44

5+
properties
6+
file = 'same.txt'
7+
cwd
8+
end
9+
510
properties (TestParameter)
6-
p_same = {...
7-
{".", pwd()}, ...
8-
{"..", "./.."}, ...
9-
{"..", pwd() + "/.."}, ...
10-
{pwd(), pwd() + "/."}}
11+
p = {...
12+
{'..', './..'}, ...
13+
{'same.txt', './same.txt'}}
1114

1215
backend = {'python', 'java', 'perl', 'sys', 'native'}
1316
end
1417

1518

19+
methods(TestClassSetup)
20+
function w_dirs(tc)
21+
f = matlab.unittest.fixtures.WorkingFolderFixture();
22+
tc.applyFixture(f);
23+
tc.cwd = f.Folder;
24+
tc.assertTrue(stdlib.touch(tc.file))
25+
end
26+
end
27+
28+
1629
methods(Test)
1730

18-
function test_samepath(tc, p_same, backend)
19-
[r, b] = stdlib.samepath(p_same{:}, backend);
31+
function test_samepath(tc, p, backend)
32+
[r, b] = stdlib.samepath(p{:}, backend);
2033
tc.assertEqual(char(b), backend)
2134
tc.verifyClass(r, 'logical')
2235

2336
if ismember(backend, stdlib.Backend().select('samepath'))
24-
tc.verifyTrue(r)
37+
tc.verifyTrue(r, [p{1} ' ' p{2}])
2538
else
2639
tc.assertEmpty(r)
2740
end
2841
end
2942

3043

44+
function test_samepath_cwd(tc, backend)
45+
r = stdlib.samepath('.', tc.cwd, backend);
46+
if ismember(backend, stdlib.Backend().select('samepath'))
47+
tc.verifyTrue(r)
48+
else
49+
tc.verifyEmpty(r)
50+
end
51+
end
52+
53+
3154
function test_samepath_notexist(tc, backend)
3255

3356
t = tempname();

test/TestSymlink.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
classdef (SharedTestFixtures={ matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))))}, ...
2-
TestTags = {'R2017b', 'symlink'}) ...
2+
TestTags = {'R2017a', 'symlink'}) ...
33
TestSymlink < matlab.unittest.TestCase
44

55
properties
@@ -74,7 +74,6 @@ function test_create_symlink(tc, B_create_symlink)
7474
["MATLAB:io:filesystem:symlink:TargetNotFound","MATLAB:io:filesystem:symlink:FileExists"]));
7575

7676
ano = fullfile(pwd(), 'another.lnk');
77-
tc.assertFalse(isfile(ano))
7877
tc.assertFalse(stdlib.is_symlink(ano))
7978

8079
r = stdlib.create_symlink(tc.target, ano, B_create_symlink);

0 commit comments

Comments
 (0)