44td
55end
66
7+ properties (TestParameter )
8+ set_modtime_fun = {@stdlib.set_modtime, @stdlib.sys.set_modtime, @stdlib.java.set_modtime, @stdlib.python.set_modtime}
9+ end
10+
711methods (TestClassSetup )
12+ function pkg_path(tc )
13+ p = matlab .unittest .fixtures .PathFixture(fileparts(fileparts(mfilename(' fullpath' ))));
14+ tc .applyFixture(p )
15+ end
16+ end
17+
18+ % per-method to avoid race conditions creating and modifying files
19+ methods (TestMethodSetup )
20+
821function set_temp_wd(tc )
922if isMATLABReleaseOlderThan(' R2022a' )
1023 tc.td = tempname();
@@ -15,7 +28,7 @@ function set_temp_wd(tc)
1528end
1629end
1730
18- methods (TestClassTeardown )
31+ methods (TestMethodTeardown )
1932function remove_temp_wd(tc )
2033if isMATLABReleaseOlderThan(' R2022a' )
2134 [s , m , i ] = rmdir(tc .td , ' s' );
@@ -31,33 +44,18 @@ function test_get_modtime(tc)
3144end
3245
3346
34- function test_touch_modtime(tc )
35- fn = tc .td + " /modtime.txt" ;
36-
37- tc .verifyTrue(stdlib .touch(fn , datetime(" yesterday" )))
38- t0 = stdlib .get_modtime(fn );
39-
40- tc .verifyTrue(stdlib .set_modtime(fn , datetime(" now" )))
41- t1 = stdlib .get_modtime(fn );
42-
43- tc .verifyGreaterThanOrEqual(t1 , t0 )
44- end
45-
46- end
47-
47+ function test_touch_modtime(tc , set_modtime_fun )
48+ is_capable(tc , set_modtime_fun )
4849
49- methods (Test , TestTags = " shell" )
50-
51- function test_set_modtime_sys(tc )
5250fn = tc .td + " /modtime.txt" ;
5351
5452tc .verifyTrue(stdlib .touch(fn , datetime(" yesterday" )))
5553t0 = stdlib .get_modtime(fn );
5654
57- tc .verifyTrue(stdlib .set_modtime (fn , datetime(" now" )))
55+ tc .verifyTrue(set_modtime_fun (fn , datetime(" now" )))
5856t1 = stdlib .get_modtime(fn );
5957
60- tc .verifyGreaterThanOrEqual(t1 , t0 );
58+ tc .verifyGreaterThanOrEqual(t1 , t0 )
6159end
6260
6361end
0 commit comments