File tree Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Expand file tree Collapse file tree 2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change 2727end
2828
2929% path given
30- if isempty(fpath ) || strlength(fpath ) == 0
30+ if isempty(fpath ) || all( strlength(fpath ) == 0 )
3131 fpath = string(getenv(" PATH" ));
3232end
3333
3434if isscalar(fpath )
35- fpath = split(fpath , pathsep );
35+ fpath = split(fpath , pathsep ).' ;
3636end
3737fpath = fpath(strlength(fpath )>0);
3838
39- for p = fpath .'
39+ for p = fpath
4040 e = p + " /" + filename ;
4141 if isfile(e ) && stdlib .is_exe(e )
4242 if find_all
Original file line number Diff line number Diff line change @@ -25,16 +25,15 @@ function test_which_fullpath(tc)
2525import matlab .unittest .constraints .IsFile
2626import matlab .unittest .constraints .EndsWithSubstring
2727
28- n = " matlab" ;
2928%% is_exe test
30- p = matlabroot + " /bin/" + n ;
31- if ispc
32- p = p + " .exe" ;
33- end
29+ p = matlabroot + " /bin/" + matlab_name();
30+
3431tc .assumeTrue(stdlib .is_exe(p ), " Matlab not executable " + p )
3532%% which: test absolute path
3633exe = stdlib .which(p );
3734
35+ tc .verifyNotEmpty(exe , " Matlab not found " + p )
36+
3837if ispc
3938 tc .verifyThat(exe , EndsWithSubstring(" .exe" ))
4039else
@@ -44,6 +43,29 @@ function test_which_fullpath(tc)
4443
4544end
4645
46+ function test_which_multipath(tc )
47+
48+ n = matlab_name();
49+
50+ paths = string(getenv(" PATH" ));
51+ paths = split(paths , pathsep );
52+ paths(end + 1 ) = matlabroot + " /bin" ;
53+
54+ exe = stdlib .which(n , paths );
55+
56+ tc .verifyNotEmpty(exe , " Matlab not found by which()" )
57+
4758end
4859
4960end
61+
62+ end
63+
64+
65+ function n = matlab_name()
66+
67+ n = " matlab" ;
68+ if ispc
69+ n = n + " .exe" ;
70+ end
71+ end
You can’t perform that action at this time.
0 commit comments