File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1919 p = p(: );
2020 i = isfile(p );
2121 ok(size(p )) = false ;
22+
23+ if ispc()
24+ pe = split(string(getenv(" PATHEXT" )), pathsep );
25+ i = i & endsWith(stdlib .suffix(p(i )), pe , ' IgnoreCase' , true );
26+ end
27+
2228 if ~any(i ), return , end
2329
2430 t(i , : ) = getPermissions(filePermissions(p(i )), props );
2531
2632 ok(i ) = isfile(p(i )) & any(t{i ,: }, 2 );
2733
2834catch e
35+ ok = false ;
36+ if ~isfile(p ), return , end
37+
2938 switch e .identifier
3039 case {' MATLAB:UndefinedFunction' , ' Octave:undefined-function' }
3140 a = file_attributes_legacy(p );
32- ok = isfile( p ) && ( a .UserExecute || a .GroupExecute || a .OtherExecute ) ;
41+ ok = a .UserExecute || a .GroupExecute || a .OtherExecute ;
3342 otherwise , rethrow(e )
3443 end
3544end
Original file line number Diff line number Diff line change 11classdef TestIsExe < matlab .unittest .TestCase
22
33properties (TestParameter )
4- p = {{" . " , false }}
4+ p = {{fileparts(mfilename( ' fullpath ' )) + " /../Readme.md " , false }}
55end
66
77methods (Test , TestTags = " impure" )
8+
89function test_is_exe(tc , p )
10+ tc .assumeThat(p{1 }, matlab .unittest .constraints .IsFile )
11+
912tc .verifyEqual(stdlib .is_exe(p{1 }), p{2 })
1013end
1114
15+
16+ function test_is_exe_dir(tc )
17+ tc .verifyFalse(stdlib .is_exe(' .' ))
18+ end
19+
20+
1221function test_matlab_exe(tc )
1322
1423f = fullfile(matlabroot , " bin/matlab" );
1524if ispc()
1625 f = f + " .exe" ;
1726end
1827
19- tc .verifyEqual (stdlib .is_exe(f ), true )
28+ tc .verifyTrue (stdlib .is_exe(f ))
2029end
2130
2231end
You can’t perform that action at this time.
0 commit comments