Skip to content

Commit fc5a2ca

Browse files
committed
test:subprocess:windows:gcc skip if GCC DLL missing
1 parent c89dc72 commit fc5a2ca

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

test/TestSubprocess.m

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,20 @@
11
classdef TestSubprocess < matlab.unittest.TestCase
22

3-
properties
4-
td
5-
end
6-
73
properties (TestParameter)
84
lang_out = {"c", "fortran"}
95
lang_in = {"cpp", "fortran"}
106
end
117

8+
129
methods(TestClassSetup)
1310

1411
function pkg_path(tc)
1512
p = matlab.unittest.fixtures.PathFixture(fileparts(fileparts(mfilename('fullpath'))));
1613
tc.applyFixture(p)
1714
end
1815

19-
function set_temp_wd(tc)
20-
if isMATLABReleaseOlderThan('R2022a')
21-
tc.td = tempname();
22-
mkdir(tc.td);
23-
else
24-
tc.td = tc.createTemporaryFolder();
25-
end
26-
end
2716
end
2817

29-
methods(TestClassTeardown)
30-
function remove_temp_wd(tc)
31-
if isMATLABReleaseOlderThan('R2022a')
32-
[s, m, i] = rmdir(tc.td, 's');
33-
if ~s, warning(i, "Failed to remove temporary directory %s: %s", tc.td, m); end
34-
end
35-
end
36-
end
3718

3819
methods (Test, TestTags=["exe"])
3920

@@ -45,6 +26,11 @@ function test_stdout_stderr(tc, lang_out)
4526
tc.assumeThat(exe, IsFile)
4627

4728
[status, msg] = stdlib.subprocess_run(exe);
29+
30+
if ispc()
31+
tc.assumeNotEqual(status, -1073741515, "GCC DLLs probably not on PATH")
32+
end
33+
4834
tc.assertEqual(status, 0)
4935
tc.verifySubstring(msg, 'stderr')
5036
tc.verifySubstring(msg, 'stdout')
@@ -67,6 +53,10 @@ function test_stdin(tc, lang_in)
6753

6854
[status, msg] = stdlib.subprocess_run(exe, stdin="1 2");
6955

56+
if ispc()
57+
tc.assumeNotEqual(status, -1073741515, "GCC DLLs probably not on PATH")
58+
end
59+
7060
tc.assertEqual(status, 0)
7161
tc.verifyEqual(msg, '3')
7262
end
@@ -126,6 +116,11 @@ function test_Java_stdout_stderr(tc, lang_out)
126116
end
127117

128118
[status, msg, err] = stdlib.java_run(exe);
119+
120+
if ispc()
121+
tc.assumeNotEqual(status, -1073741515, "GCC DLLs probably not on PATH")
122+
end
123+
129124
tc.assertEqual(status, 0, err)
130125
tc.verifySubstring(msg, "stdout")
131126
tc.verifyEqual(err, "stderr")
@@ -146,6 +141,10 @@ function test_java_stdin(tc, lang_in)
146141

147142
[status, msg, err] = stdlib.java_run(exe, stdin="1 2");
148143

144+
if ispc()
145+
tc.assumeNotEqual(status, -1073741515, "GCC DLLs probably not on PATH")
146+
end
147+
149148
tc.assertEqual(status, 0, err)
150149
tc.verifyEqual(msg, "3")
151150
tc.verifyEqual(err, "")
@@ -154,6 +153,12 @@ function test_java_stdin(tc, lang_in)
154153

155154
function test_java_cwd(tc)
156155

156+
if isMATLABReleaseOlderThan('R2022a')
157+
td = tempdir;
158+
else
159+
td = tc.createTemporaryFolder();
160+
end
161+
157162
if ispc
158163
c = ["cmd", "/c", "dir"];
159164
else
@@ -165,7 +170,7 @@ function test_java_cwd(tc)
165170
tc.verifyGreaterThan(strlength(m), 0, "empty directory not expected")
166171
tc.verifyEqual(strlength(e), 0, e)
167172

168-
[s, mc, e] = stdlib.java_run(c, cwd=tc.td);
173+
[s, mc, e] = stdlib.java_run(c, cwd=td);
169174
tc.assertEqual(s, 0, "status non-zero")
170175
tc.verifyNotEqual(m, mc, "expected different directory to have different contents")
171176
tc.verifyEqual(strlength(e), 0, e)

0 commit comments

Comments
 (0)