Skip to content

Commit 1f5a53e

Browse files
committed
test: no longer need init_backend
This allows for Matlab < R2021a to be tested
1 parent 0710bd3 commit 1f5a53e

File tree

2 files changed

+62
-84
lines changed

2 files changed

+62
-84
lines changed

test/TestDisk.m

Lines changed: 62 additions & 68 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', 'impure'}) ...
2+
TestTags = {'R2019b', 'impure'}) ...
33
TestDisk < matlab.unittest.TestCase
44

55
properties
@@ -9,27 +9,9 @@
99
properties (TestParameter)
1010
Ps = {".", "", "/", getenv("SystemDrive"), "not-exist"}
1111
Po = {mfilename("fullpath") + ".m", pwd(), ".", "", "not-exist"}
12-
B_disk
13-
B_is_removable
14-
B_is_mount
15-
B_hard_link_count
16-
B_filesystem_type
17-
B_owner
18-
B_device
19-
B_is_dev_drive
20-
end
21-
22-
methods (TestParameterDefinition, Static)
23-
function [B_disk, B_is_removable, B_is_mount, B_hard_link_count, B_device, B_filesystem_type, B_owner, B_is_dev_drive] = setupBackends()
24-
B_disk = init_backend("disk_available");
25-
B_is_removable = init_backend("is_removable");
26-
B_is_mount = init_backend("is_mount");
27-
B_hard_link_count = init_backend("hard_link_count");
28-
B_device = init_backend('device');
29-
B_filesystem_type = init_backend("filesystem_type");
30-
B_owner = init_backend("get_owner");
31-
B_is_dev_drive = init_backend('is_dev_drive');
32-
end
12+
B_ps = {'python', 'sys'}
13+
B_jps = {'java', 'python', 'sys'}
14+
B_jdps = {'java', 'dotnet', 'python', 'sys'}
3315
end
3416

3517
methods(TestClassSetup)
@@ -40,9 +22,9 @@ function test_dirs(tc)
4022

4123
methods (Test)
4224

43-
function test_disk_available(tc, Ps, B_disk)
44-
[r, b] = stdlib.disk_available(Ps, B_disk);
45-
tc.assertEqual(char(b), B_disk)
25+
function test_disk_available(tc, Ps, B_jdps)
26+
[r, b] = stdlib.disk_available(Ps, B_jdps);
27+
tc.assertEqual(char(b), B_jdps)
4628

4729
tc.verifyClass(r, 'uint64')
4830

@@ -54,9 +36,9 @@ function test_disk_available(tc, Ps, B_disk)
5436
end
5537

5638

57-
function test_disk_capacity(tc, Ps, B_disk)
58-
[r, b] = stdlib.disk_capacity(Ps, B_disk);
59-
tc.assertEqual(char(b), B_disk)
39+
function test_disk_capacity(tc, Ps, B_jdps)
40+
[r, b] = stdlib.disk_capacity(Ps, B_jdps);
41+
tc.assertEqual(char(b), B_jdps)
6042

6143
tc.verifyClass(r, 'uint64')
6244

@@ -68,46 +50,49 @@ function test_disk_capacity(tc, Ps, B_disk)
6850
end
6951

7052

71-
function test_is_removable(tc, B_is_removable)
72-
[y, b] = stdlib.is_removable(pwd(), B_is_removable);
73-
tc.assertEqual(char(b), B_is_removable)
53+
function test_is_removable(tc, B_ps)
54+
[y, b] = stdlib.is_removable(pwd(), B_ps);
55+
tc.assertEqual(char(b), B_ps)
7456
tc.verifyClass(y, 'logical')
7557
end
7658

77-
78-
function test_is_mount(tc, B_is_mount)
79-
y = stdlib.is_mount(pwd(), B_is_mount);
59+
function test_is_mount(tc, B_ps)
60+
y = stdlib.is_mount(pwd(), B_ps);
8061

8162
tc.verifyClass(y, 'logical')
82-
tc.verifyTrue(stdlib.is_mount("/", B_is_mount))
83-
tc.verifyEmpty(stdlib.is_mount(tempname(), B_is_mount))
63+
tc.verifyTrue(stdlib.is_mount("/", B_ps))
64+
tc.verifyEmpty(stdlib.is_mount(tempname(), B_ps))
8465

8566
if ispc()
8667
sd = getenv("SystemDrive");
8768
tc.assertTrue(sd == stdlib.root_name(sd), sd)
88-
tc.verifyFalse(stdlib.is_mount(sd, B_is_mount), sd)
89-
tc.verifyTrue(stdlib.is_mount(sd + "/", B_is_mount), sd)
90-
tc.verifyTrue(stdlib.is_mount(sd + "\", B_is_mount), sd)
69+
tc.verifyFalse(stdlib.is_mount(sd, B_ps), sd)
70+
tc.verifyTrue(stdlib.is_mount(sd + "/", B_ps), sd)
71+
tc.verifyTrue(stdlib.is_mount(sd + "\", B_ps), sd)
9172
end
9273
end
9374

9475

95-
function test_hard_link_count(tc, B_hard_link_count)
76+
function test_hard_link_count(tc, B_jps)
9677
P = mfilename("fullpath") + ".m";
9778

98-
[i, b] = stdlib.hard_link_count(P, B_hard_link_count);
99-
tc.assertEqual(char(b), B_hard_link_count)
79+
[i, b] = stdlib.hard_link_count(P, B_jps);
80+
tc.assertEqual(char(b), B_jps)
10081

101-
tc.verifyGreaterThanOrEqual(i, 1)
82+
if ismember(B_jps, stdlib.Backend().select('hard_link_count'))
83+
tc.verifyGreaterThanOrEqual(i, 1)
84+
else
85+
tc.assertEmpty(i)
86+
end
10287

10388
i = stdlib.hard_link_count('');
10489
tc.verifyEmpty(i)
10590
end
10691

10792

108-
function test_filesystem_type(tc, Ps, B_filesystem_type)
109-
[t, b] = stdlib.filesystem_type(Ps, B_filesystem_type);
110-
tc.assertEqual(char(b), B_filesystem_type)
93+
function test_filesystem_type(tc, Ps, B_jdps)
94+
[t, b] = stdlib.filesystem_type(Ps, B_jdps);
95+
tc.assertEqual(char(b), B_jdps)
11196
tc.verifyClass(t, 'char')
11297

11398
if ~stdlib.exists(Ps)
@@ -120,9 +105,9 @@ function test_filesystem_type(tc, Ps, B_filesystem_type)
120105
end
121106

122107

123-
function test_is_dev_drive(tc, B_is_dev_drive)
124-
[r, b] = stdlib.is_dev_drive(pwd(), B_is_dev_drive);
125-
tc.assertEqual(char(b), B_is_dev_drive)
108+
function test_is_dev_drive(tc, B_ps)
109+
[r, b] = stdlib.is_dev_drive(pwd(), B_ps);
110+
tc.assertEqual(char(b), B_ps)
126111

127112
tc.verifyClass(r, 'logical')
128113
end
@@ -141,38 +126,47 @@ function test_remove_file(tc)
141126
end
142127

143128

144-
function test_device(tc, Po, B_device)
145-
[i, b] = stdlib.device(Po, B_device);
129+
function test_device(tc, Po, B_jps)
130+
[i, b] = stdlib.device(Po, B_jps);
146131
tc.verifyClass(i, 'uint64')
147-
tc.assertEqual(char(b), B_device)
148-
149-
if ~stdlib.exists(Po)
150-
tc.verifyEmpty(i)
132+
tc.assertEqual(char(b), B_jps)
133+
134+
if ismember(B_jps, stdlib.Backend().select('device'))
135+
if ~stdlib.exists(Po)
136+
tc.verifyEmpty(i)
137+
else
138+
tc.assertNotEmpty(i)
139+
tc.assertGreaterThan(i, 0)
140+
end
151141
else
152-
tc.assertNotEmpty(i)
153-
tc.assertGreaterThan(i, 0)
142+
tc.assertEmpty(i)
154143
end
155144
end
156145

157146

158-
function test_inode(tc, Po, B_device)
147+
function test_inode(tc, Po, B_jps)
159148

160-
[i, b] = stdlib.inode(Po, B_device);
149+
[i, b] = stdlib.inode(Po, B_jps);
161150
tc.verifyClass(i, 'uint64')
162-
tc.assertEqual(char(b), B_device)
163-
164-
if ~stdlib.exists(Po)
165-
tc.verifyEmpty(i)
151+
tc.assertEqual(char(b), B_jps)
152+
153+
if ismember(B_jps, stdlib.Backend().select('inode'))
154+
if ~stdlib.exists(Po)
155+
tc.verifyEmpty(i)
156+
else
157+
tc.assertNotEmpty(i)
158+
tc.assertGreaterThan(i, 0)
159+
end
166160
else
167-
tc.assertNotEmpty(i)
168-
tc.assertGreaterThan(i, 0)
161+
tc.assertEmpty(i)
169162
end
163+
170164
end
171165

172166

173-
function test_owner(tc, Po, B_owner)
174-
[o, b] = stdlib.get_owner(Po, B_owner);
175-
tc.assertEqual(char(b), B_owner)
167+
function test_owner(tc, Po, B_jdps)
168+
[o, b] = stdlib.get_owner(Po, B_jdps);
169+
tc.assertEqual(char(b), B_jdps)
176170
tc.verifyClass(o, 'char')
177171

178172
if ~stdlib.exists(Po)

test/private/init_backend.m

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)