1- classdef (TestTags = {' R2019b' , ' impure' }) ...
1+ classdef (SharedTestFixtures = { matlab .unittest .fixtures .PathFixture(" .." )}, ...
2+ TestTags = {' R2019b' , ' impure' }) ...
23 TestDisk < matlab .unittest .TestCase
34
45properties
89properties (TestParameter )
910Ps = {" ." , " " , " /" , getenv(" SystemDrive" ), " not-exist" }
1011Po = {mfilename(" fullpath" ) + " .m" , pwd(), " ." , " " , " not-exist" }
11- backend_jps = init_backend({' sys' , ' java' , ' python' })
12- backend_djps = init_backend({' sys' , ' dotnet' , ' java' , ' python' })
13- backend_ds = init_backend({' dotnet' , ' sys' })
14- backend_ps = init_backend({' python' , ' sys' })
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+ end
20+
21+ methods (TestParameterDefinition , Static )
22+ function [B_disk , B_is_removable , B_is_mount , B_hard_link_count , B_filesystem_type , B_owner , B_device ] = setupBackends()
23+ B_disk = init_backend(" disk_available" );
24+ B_is_removable = init_backend(" is_removable" );
25+ B_is_mount = init_backend(" is_mount" );
26+ B_hard_link_count = init_backend(" hard_link_count" );
27+ B_filesystem_type = init_backend(" filesystem_type" );
28+ B_owner = init_backend(" get_owner" );
29+ B_device = init_backend(" device" );
30+ end
1531end
1632
1733methods (TestClassSetup )
1834function test_dirs(tc )
19- pkg_path(tc )
20-
2135 tc .applyFixture(matlab .unittest .fixtures .WorkingFolderFixture())
2236end
2337end
2438
2539methods (Test )
2640
27- function test_disk_available(tc , Ps , backend_djps )
28- r = stdlib .disk_available(Ps , backend_djps );
41+ function test_disk_available(tc , Ps , B_disk )
42+ r = stdlib .disk_available(Ps , B_disk );
2943
3044tc .verifyClass(r , ' uint64' )
3145
@@ -37,8 +51,8 @@ function test_disk_available(tc, Ps, backend_djps)
3751end
3852
3953
40- function test_disk_capacity(tc , Ps , backend_djps )
41- r = stdlib .disk_capacity(Ps , backend_djps );
54+ function test_disk_capacity(tc , Ps , B_disk )
55+ r = stdlib .disk_capacity(Ps , B_disk );
4256
4357tc .verifyClass(r , ' uint64' )
4458
@@ -50,46 +64,42 @@ function test_disk_capacity(tc, Ps, backend_djps)
5064end
5165
5266
53- function test_is_removable(tc , backend_ds )
54- y = stdlib .is_removable(pwd(), backend_ds );
67+ function test_is_removable(tc , B_is_removable )
68+ y = stdlib .is_removable(pwd(), B_is_removable );
5569tc .verifyClass(y , ' logical' )
5670end
5771
5872
59- function test_is_mount(tc , backend_ps )
60- y = stdlib .is_mount(pwd(), backend_ps );
73+ function test_is_mount(tc , B_is_mount )
74+ y = stdlib .is_mount(pwd(), B_is_mount );
6175
6276tc .verifyClass(y , ' logical' )
63- tc .verifyTrue(stdlib .is_mount(" /" , backend_ps ))
64- tc .verifyEmpty(stdlib .is_mount(tempname(), backend_ps ))
77+ tc .verifyTrue(stdlib .is_mount(" /" , B_is_mount ))
78+ tc .verifyEmpty(stdlib .is_mount(tempname(), B_is_mount ))
6579
6680if ispc()
6781 sd = getenv(" SystemDrive" );
6882 tc .assertTrue(sd == stdlib .root_name(sd ), sd )
69- tc .verifyFalse(stdlib .is_mount(sd , backend_ps ), sd )
70- tc .verifyTrue(stdlib .is_mount(sd + " /" , backend_ps ), sd )
71- tc .verifyTrue(stdlib .is_mount(sd + " \" , backend_ps ), sd )
83+ tc .verifyFalse(stdlib .is_mount(sd , B_is_mount ), sd )
84+ tc .verifyTrue(stdlib .is_mount(sd + " /" , B_is_mount ), sd )
85+ tc .verifyTrue(stdlib .is_mount(sd + " \" , B_is_mount ), sd )
7286end
7387end
7488
7589
76- function test_hard_link_count(tc , backend_jps )
90+ function test_hard_link_count(tc , B_hard_link_count )
7791P = mfilename(" fullpath" ) + " .m" ;
7892
79- r = stdlib .hard_link_count(P , backend_jps );
80- if ispc() && backend_jps == " java"
81- tc .verifyEmpty(r )
82- else
83- tc .verifyGreaterThanOrEqual(r , 1 )
84- end
93+ r = stdlib .hard_link_count(P , B_hard_link_count );
94+ tc .verifyGreaterThanOrEqual(r , 1 )
8595end
8696
8797
88- function test_filesystem_type(tc , Ps , backend_djps )
89- t = stdlib .filesystem_type(Ps , backend_djps );
98+ function test_filesystem_type(tc , Ps , B_filesystem_type )
99+ t = stdlib .filesystem_type(Ps , B_filesystem_type );
90100tc .verifyClass(t , ' char' )
91101
92- if ~stdlib .exists(Ps ) || ( backend_djps == " python " && ~ stdlib . python .has_psutil())
102+ if ~stdlib .exists(Ps )
93103 tc .verifyEmpty(t )
94104else
95105 tc .assumeFalse(isempty(t ) && tc .CI , " Some CI block viewing their filesystem type" )
@@ -112,12 +122,11 @@ function test_remove_file(tc)
112122end
113123
114124
115- function test_device(tc , Po , backend_jps )
116-
117- i = stdlib .device(Po , backend_jps );
125+ function test_device(tc , Po , B_device )
126+ i = stdlib .device(Po , B_device );
118127tc .verifyClass(i , ' uint64' )
119128
120- if ispc() && backend_jps == " java " || ~stdlib .exists(Po )
129+ if ~stdlib .exists(Po )
121130 tc .verifyEmpty(i )
122131else
123132 tc .assertNotEmpty(i )
@@ -126,12 +135,12 @@ function test_device(tc, Po, backend_jps)
126135end
127136
128137
129- function test_inode(tc , Po , backend_jps )
138+ function test_inode(tc , Po , B_device )
130139
131- i = stdlib .inode(Po , backend_jps );
140+ i = stdlib .inode(Po , B_device );
132141tc .verifyClass(i , ' uint64' )
133142
134- if ispc() && backend_jps == " java " || ~stdlib .exists(Po )
143+ if ~stdlib .exists(Po )
135144 tc .verifyEmpty(i )
136145else
137146 tc .assertNotEmpty(i )
@@ -140,13 +149,10 @@ function test_inode(tc, Po, backend_jps)
140149end
141150
142151
143- function test_owner(tc , Po , backend_djps )
144-
145- o = stdlib .get_owner(Po , backend_djps );
152+ function test_owner(tc , Po , B_owner )
153+ o = stdlib .get_owner(Po , B_owner );
146154
147- if ~stdlib .exists(Po ) || ...
148- (backend_djps == " dotnet" && isunix()) || ...
149- (backend_djps == " python" && ispc())
155+ if ~stdlib .exists(Po )
150156 tc .verifyEqual(o , " " )
151157else
152158 tc .verifyGreaterThan(strlength(o ), 0 )
@@ -155,19 +161,14 @@ function test_owner(tc, Po, backend_djps)
155161end
156162
157163
158- function test_owner_array(tc , backend_djps )
164+ function test_owner_array(tc , B_owner )
159165
160- o = stdlib .get_owner([" ." , pwd(), " not-exist" , " " ], backend_djps );
166+ o = stdlib .get_owner([" ." , pwd(), " not-exist" , " " ], B_owner );
161167L = strlength(o );
162168
163169tc .verifyEqual(L(3 : 4 ), [0 , 0 ])
164170
165- if (backend_djps == " dotnet" && isunix()) || ...
166- (backend_djps == " python" && ispc())
167- tc .verifyEqual(L(1 : 2 ), [0 , 0 ])
168- else
169- tc .verifyGreaterThan(L(1 : 2 ), 0 );
170- end
171+ tc .verifyGreaterThan(L(1 : 2 ), 0 );
171172
172173end
173174
0 commit comments