Skip to content

Commit 9ffaf4c

Browse files
committed
testSymlink < R2021a
1 parent a378fb7 commit 9ffaf4c

File tree

2 files changed

+58
-29
lines changed

2 files changed

+58
-29
lines changed

+stdlib/+dotnet/private/dotnetException.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function dotnetException(e)
77
% pass
88
case {'MATLAB:undefinedVarOrClass', 'MATLAB:NET:NETInterfaceUnsupported'}
99
% .NET not enabled
10-
case 'MATLAB:subscripting:classHasNoPropertyOrMethod'
10+
case {'MATLAB:NET:INVALIDMEMBER', 'MATLAB:subscripting:classHasNoPropertyOrMethod', 'MATLAB:NET:CLRException:MethodInvoke'}
1111
% .NET too old or not supported on this platform
1212
otherwise
1313
rethrow(e)
@@ -21,4 +21,4 @@ function dotnetException(e)
2121
end
2222
end
2323

24-
end
24+
end

test/TestSymlink.m

Lines changed: 56 additions & 27 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 = {'R2021a', 'symlink', 'impure'}) ...
2+
TestTags = {'R2019b', 'symlink', 'impure'}) ...
33
TestSymlink < matlab.unittest.TestCase
44

55
properties
@@ -12,18 +12,8 @@
1212
{mfilename("fullpath") + ".m", false}, ...
1313
{"", false}};
1414
Pre = {'', "", tempname()}
15-
B_create_symlink
16-
B_read_symlink
17-
B_is_symlink
18-
end
19-
20-
21-
methods (TestParameterDefinition, Static)
22-
function [B_create_symlink, B_read_symlink, B_is_symlink] = setupBackends()
23-
B_create_symlink = init_backend("create_symlink");
24-
B_read_symlink = init_backend("read_symlink");
25-
B_is_symlink = init_backend("is_symlink");
26-
end
15+
B_create_symlink = {'native', 'dotnet', 'python', 'sys'}
16+
B_is_symlink = {'native', 'java', 'python', 'dotnet', 'sys'}
2717
end
2818

2919

@@ -50,46 +40,85 @@ function test_is_symlink(tc, p, B_is_symlink)
5040
[i, b] = stdlib.is_symlink(tc.link, B_is_symlink);
5141

5242
tc.assertEqual(char(b), B_is_symlink)
43+
44+
if ismember(B_is_symlink, stdlib.Backend().select('is_symlink'))
5345
tc.assertTrue(i, "failed to detect own link " + tc.link)
5446

5547
tc.verifyEqual(stdlib.is_symlink(p{1}, B_is_symlink), p{2}, p{1})
48+
else
49+
tc.verifyEmpty(i)
50+
end
5651
end
5752

5853

59-
function test_read_symlink_empty(tc, Pre, B_read_symlink)
60-
[r, b] = stdlib.read_symlink(Pre, B_read_symlink);
61-
tc.assertEqual(char(b), B_read_symlink)
54+
function test_read_symlink_empty(tc, Pre, B_is_symlink)
55+
[r, b] = stdlib.read_symlink(Pre, B_is_symlink);
56+
tc.assertEqual(char(b), B_is_symlink)
6257

6358
tc.verifyEqual(r, string.empty)
6459
end
6560

6661

67-
function test_read_symlink(tc, B_read_symlink)
68-
r = stdlib.read_symlink(tc.link, B_read_symlink);
62+
function test_read_symlink(tc, B_is_symlink)
63+
r = stdlib.read_symlink(tc.link, B_is_symlink);
6964
tc.verifyClass(r, 'string')
70-
tc.verifyEqual(r, string(tc.target))
65+
66+
if ismember(B_is_symlink, stdlib.Backend().select('read_symlink'))
67+
tc.verifyEqual(r, string(tc.target))
68+
else
69+
tc.verifyEmpty(r)
70+
end
7171
end
7272

7373

7474
function test_create_symlink(tc, B_create_symlink)
7575
tc.applyFixture(matlab.unittest.fixtures.SuppressedWarningsFixture(["MATLAB:io:filesystem:symlink:TargetNotFound","MATLAB:io:filesystem:symlink:FileExists"]))
7676

7777
ano = fullfile(pwd(), 'another.lnk');
78+
tc.assertThat(ano, ~matlab.unittest.constraints.IsFile)
79+
tc.assertFalse(stdlib.is_symlink(ano))
7880

79-
h = @stdlib.create_symlink;
81+
r = stdlib.create_symlink(tc.target, ano, B_create_symlink);
8082

81-
[i, b] = h('', tempname(), B_create_symlink);
83+
if ismember(B_create_symlink, stdlib.Backend().select('create_symlink'))
84+
tc.verifyTrue(r)
85+
elseif ispc() && B_create_symlink == "native"
86+
tc.verifyTrue(r || isempty(r))
87+
else
88+
tc.verifyEmpty(r)
89+
end
90+
end
91+
92+
93+
function test_create_symlink_empty(tc, B_create_symlink)
94+
[i, b] = stdlib.create_symlink('', tempname(), B_create_symlink);
8295
tc.assertEqual(char(b), B_create_symlink)
8396

84-
tc.verifyFalse(i)
85-
tc.verifyFalse(h(tc.target, tc.link, B_create_symlink), "should fail for existing symlink")
97+
if ismember(B_create_symlink, stdlib.Backend().select('create_symlink'))
98+
if ispc() && B_create_symlink == "native"
99+
tc.verifyTrue( isempty(i) || ~i )
100+
else
101+
tc.verifyFalse(i)
102+
end
103+
else
104+
tc.verifyTrue( isempty(i) || ~i )
105+
end
106+
end
107+
86108

87-
exp = true;
109+
function test_create_symlink_exist(tc, B_create_symlink)
110+
i = stdlib.create_symlink(tc.target, tc.link, B_create_symlink);
88111

89-
tc.assertThat(ano, ~matlab.unittest.constraints.IsFile)
90-
tc.assertFalse(stdlib.is_symlink(ano))
112+
if ismember(B_create_symlink, stdlib.Backend().select('create_symlink'))
113+
if ispc() && B_create_symlink == "native"
114+
tc.verifyTrue( isempty(i) || ~i )
115+
else
116+
tc.verifyFalse(i, "should fail for existing symlink")
117+
end
118+
else
119+
tc.verifyTrue( isempty(i) || ~i )
120+
end
91121

92-
tc.verifyEqual(h(tc.target, ano, B_create_symlink), exp)
93122
end
94123

95124
end

0 commit comments

Comments
 (0)