@@ -16,7 +16,36 @@ function test_dirs(tc)
1616end
1717
1818
19+ methods (Test , TestTags = " native_exe" )
20+
21+ function test_cwd(tc )
22+
23+ if ispc
24+ c = ' cd' ;
25+ else
26+ c = ' pwd' ;
27+ end
28+
29+ % leave on for debugging.
30+ cmd_echo = true ;
31+
32+ [s , m ] = stdlib .subprocess_run(c , ' echo' , cmd_echo );
33+ tc .assertEqual(s , 0 , " status non-zero" )
34+ tc .verifyGreaterThan(strlength(m ), 0 , " empty directory not expected" )
35+
36+ [s , mc ] = stdlib .subprocess_run(c , ' cwd' , matlabroot , ' echo' , cmd_echo );
37+ tc .assertEqual(s , 0 , " status non-zero" )
38+ tc .verifyNotEqual(m , mc , " expected different directory to have different contents" )
39+
40+ end
41+
42+ end
43+
44+
1945methods (Test , TestTags = {' exe' })
46+ % these tests require the presence of test executables compiled by
47+ % buildtool exe
48+ % The test "buildtool test:exe" automatically builds them
2049
2150function test_stdout_stderr(tc , lang_out )
2251import matlab .unittest .constraints .IsFile
@@ -62,25 +91,6 @@ function test_stdin(tc, lang_in)
6291end
6392
6493
65- function test_cwd(tc )
66-
67- if ispc
68- c = ' dir' ;
69- else
70- c = ' ls -l' ;
71- end
72-
73- [s , m ] = stdlib .subprocess_run(c );
74- tc .assertEqual(s , 0 , " status non-zero" )
75- tc .verifyGreaterThan(strlength(m ), 0 , " empty directory not expected" )
76-
77- [s , mc ] = stdlib .subprocess_run(c , ' cwd' , matlabroot );
78- tc .assertEqual(s , 0 , " status non-zero" )
79- tc .verifyNotEqual(m , mc , " expected different directory to have different contents" )
80-
81- end
82-
83-
8494function test_env_run(tc )
8595
8696cwd = fileparts(mfilename(' fullpath' ));
@@ -154,9 +164,9 @@ function test_java_stdin(tc, lang_in)
154164function test_java_cwd(tc )
155165
156166if ispc
157- c = [" cmd" , " /c" , " dir " ];
167+ c = [" cmd" , " /c" , " cd " ];
158168else
159- c = [ " ls " , " -l " ] ;
169+ c = " pwd " ;
160170end
161171
162172[s , m , e ] = stdlib .java_run(c );
0 commit comments