Skip to content

Commit eca696c

Browse files
committed
test: native_exe for test finery
1 parent c1dce42 commit eca696c

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

buildfile.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
plan = buildplan(localfunctions);
55

6-
sel = ~HasTag("exe") & ~HasTag("java") & ~HasTag("java_exe") & ~HasTag("python");
6+
sel = HasTag('native_exe') | (~HasTag("exe") & ~HasTag("java") & ~HasTag("java_exe") & ~HasTag("python"));
77
if ispc()
88
sel = sel & ~HasTag("unix");
99
else

test/TestSubprocess.m

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,36 @@ function test_dirs(tc)
1616
end
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+
1945
methods (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

2150
function test_stdout_stderr(tc, lang_out)
2251
import matlab.unittest.constraints.IsFile
@@ -62,25 +91,6 @@ function test_stdin(tc, lang_in)
6291
end
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-
8494
function test_env_run(tc)
8595

8696
cwd = fileparts(mfilename('fullpath'));
@@ -154,9 +164,9 @@ function test_java_stdin(tc, lang_in)
154164
function test_java_cwd(tc)
155165

156166
if ispc
157-
c = ["cmd", "/c", "dir"];
167+
c = ["cmd", "/c", "cd"];
158168
else
159-
c = ["ls", "-l"];
169+
c = "pwd";
160170
end
161171

162172
[s, m, e] = stdlib.java_run(c);

test_main.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function test_main(context, sel)
1414
end
1515
test_root = fullfile(cwd, "test");
1616

17-
tags = releaseTestTags();
17+
tags = ["native_exe", releaseTestTags()];
1818

1919
if ~exist('isMATLABReleaseOlderThan', 'builtin') || isMATLABReleaseOlderThan('R2022b')
2020
suite = testsuite(test_root, 'Tag', tags);

0 commit comments

Comments
 (0)