1010p = {{" not-exist" , false }, ...
1111 {mfilename(" fullpath" ) + " .m" , false }, ...
1212 {" " , false }};
13+ create_symlink_fun = {@stdlib.create_symlink, @stdlib.sys.create_symlink, @stdlib.dotnet.create_symlink, @stdlib.python.create_symlink}
1314is_symlink_fun = {@stdlib.is_symlink, @stdlib.sys.is_symlink, @stdlib.dotnet.is_symlink, @stdlib.java.is_symlink, @stdlib.python.is_symlink}
1415read_symlink_fun = {@stdlib.read_symlink, @stdlib.sys.read_symlink, @stdlib.dotnet.read_symlink, @stdlib.java.read_symlink, @stdlib.python.read_symlink}
1516end
1617
1718
18- methods (TestClassSetup )
19-
20- function set_temp_wd(tc )
21- if isMATLABReleaseOlderThan(' R2022a' )
22- tc.td = tempname();
23- mkdir(tc .td );
24- else
25- tc.td = tc .createTemporaryFolder();
26- end
27- end
19+ methods (TestMethodSetup )
20+ % needs to be per-method because multiple functions are used to make the same files
2821
2922function setup_symlink(tc )
3023
24+ tc .assumeFalse(isMATLABReleaseOlderThan(' R2022a' ))
25+
26+ tc.td = tc .createTemporaryFolder();
27+
3128tc.link = fullfile(tc .td , ' my.lnk' );
3229
3330tc.target = strcat(mfilename(" fullpath" ), ' .m' );
@@ -38,15 +35,6 @@ function setup_symlink(tc)
3835end
3936
4037
41- methods (TestClassTeardown )
42- function remove_temp_wd(tc )
43- if isMATLABReleaseOlderThan(' R2022a' )
44- [s , m , i ] = rmdir(tc .td , ' s' );
45- if ~s , warning(i , " Failed to remove temporary directory %s: %s" , tc .td , m ); end
46- end
47- end
48- end
49-
5038
5139methods (Test , TestTags = [" impure" , "symlink "])
5240
@@ -75,16 +63,16 @@ function test_read_symlink(tc, read_symlink_fun)
7563end
7664
7765
78- function test_create_symlink(tc )
79- fprintf( " create_symlink mex: %d\n " , stdlib .is_mex_fun( " stdlib.create_symlink " ) )
66+ function test_create_symlink(tc , create_symlink_fun )
67+ is_capable( tc , create_symlink_fun )
8068
8169tc .applyFixture(matlab .unittest .fixtures .SuppressedWarningsFixture([" MATLAB:io:filesystem:symlink:TargetNotFound" ," MATLAB:io:filesystem:symlink:FileExists" ]))
8270
83- tc .verifyFalse(stdlib .create_symlink (' ' , tempname()))
84- tc .verifyFalse(stdlib .create_symlink (tc .target , tc .link ), " should fail for existing symlink" )
71+ tc .verifyFalse(create_symlink_fun (' ' , tempname()))
72+ tc .verifyFalse(create_symlink_fun (tc .target , tc .link ), " should fail for existing symlink" )
8573
8674ano = tc .td + " /another.lnk" ;
87- tc .verifyTrue(stdlib .create_symlink (tc .target , ano ))
75+ tc .verifyTrue(create_symlink_fun (tc .target , ano ))
8876tc .verifyTrue(stdlib .is_symlink(ano ))
8977end
9078
0 commit comments