Skip to content

Commit 1b631ce

Browse files
committed
consistent output type
1 parent 553a325 commit 1b631ce

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

+stdlib/+python/is_mount.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@
44

55
function y = is_mount(filepath)
66

7-
y = logical.empty;
87

9-
10-
try %#ok<TRYNC>
8+
try
9+
y = false;
1110

1211
p = py.pathlib.Path(filepath);
13-
if ~p.exists(), return, end
12+
if ~p.exists()
13+
return
14+
end
1415

1516
% some Python on CI needs this. Didn't replicate on local Windows PC.
1617
if ispc() && strcmp(filepath, string(p.drive)) && ~endsWith(filepath, ["/", filesep])
17-
y = false;
1818
return
1919
end
2020

2121
y = py.os.path.ismount(p);
22+
catch e
23+
pythonException(e)
24+
y = logical.empty;
2225
end
2326

2427
end

+stdlib/+sys/get_owner.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
cmd = sprintf('stat -c %%U "%s"', file);
1414
end
1515

16+
% Windows needs exists() rather than just ~strempty()
1617
if stdlib.exists(file)
1718
[s, m] = system(cmd);
1819
if s == 0

+stdlib/+sys/is_mount.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
end
55

66
cmd = '';
7-
y = logical.empty;
8-
if ~stdlib.exists(filepath), return, end
7+
if ~stdlib.exists(filepath)
8+
y = false;
9+
return
10+
end
911

1012
if ispc()
1113
if ismember(filepath, ["/", "\"]) || ...

+stdlib/get_owner.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
backend (1,:) string = ["java", "dotnet", "python", "sys"]
1414
end
1515

16-
r = string.empty;
16+
r = '';
1717

1818
for b = backend
1919
switch b

test/TestDisk.m

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,23 @@ function test_is_removable(tc, B_ps)
6767
end
6868

6969
function test_is_mount(tc, B_ps)
70-
y = stdlib.is_mount(pwd(), B_ps);
71-
70+
[y,b] = stdlib.is_mount(pwd(), B_ps);
71+
tc.assertEqual(char(b), B_ps)
7272
tc.verifyClass(y, 'logical')
73-
tc.verifyTrue(stdlib.is_mount("/", B_ps))
74-
tc.verifyEmpty(stdlib.is_mount(tempname(), B_ps))
7573

76-
if ispc()
77-
sd = getenv("SystemDrive");
78-
tc.assertTrue(sd == stdlib.root_name(sd), sd)
79-
tc.verifyFalse(stdlib.is_mount(sd, B_ps), sd)
80-
tc.verifyTrue(stdlib.is_mount(sd + "/", B_ps), sd)
81-
tc.verifyTrue(stdlib.is_mount(sd + "\", B_ps), sd)
74+
if ismember(B_ps, stdlib.Backend().select('is_mount'))
75+
tc.verifyTrue(stdlib.is_mount("/", B_ps))
76+
tc.verifyFalse(stdlib.is_mount(tempname(), B_ps))
77+
78+
if ispc()
79+
sd = getenv("SystemDrive");
80+
tc.assertTrue(sd == stdlib.root_name(sd), sd)
81+
tc.verifyFalse(stdlib.is_mount(sd, B_ps), sd)
82+
tc.verifyTrue(stdlib.is_mount(sd + "/", B_ps), sd)
83+
tc.verifyTrue(stdlib.is_mount(sd + "\", B_ps), sd)
84+
end
85+
else
86+
tc.verifyEmpty(y)
8287
end
8388
end
8489

@@ -105,12 +110,16 @@ function test_filesystem_type(tc, Ps, B_jdps)
105110
tc.assertEqual(char(b), B_jdps)
106111
tc.verifyClass(t, 'char')
107112

108-
if ~stdlib.exists(Ps)
109-
tc.verifyEmpty(t)
113+
if ismember(B_jdps, stdlib.Backend().select('filesystem_type'))
114+
if ~stdlib.exists(Ps)
115+
tc.verifyEmpty(t)
116+
else
117+
tc.assumeFalse(isempty(t) && tc.CI, "Some CI block viewing their filesystem type")
118+
tc.assertNotEmpty(t)
119+
tc.verifyGreaterThan(strlength(t), 0)
120+
end
110121
else
111-
tc.assumeFalse(isempty(t) && tc.CI, "Some CI block viewing their filesystem type")
112-
tc.assertNotEmpty(t)
113-
tc.verifyGreaterThan(strlength(t), 0)
122+
tc.verifyEmpty(t)
114123
end
115124
end
116125

0 commit comments

Comments
 (0)