Skip to content

Commit a978ef1

Browse files
committed
test: use Eventually timeout
1 parent 46a5b8a commit a978ef1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/TestSubprocess.m

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,23 @@ function test_env_run(tc)
7575

7676
function test_timeout(tc)
7777
import matlab.unittest.constraints.StartsWithSubstring
78+
import matlab.unittest.constraints.Eventually
79+
import matlab.unittest.constraints.IsEqualTo
7880

7981
timeout = 1;
8082

8183
if ispc
82-
c = ["powershell", "-command", "Start-Sleep -s 3"];
84+
% https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/start-sleep
85+
c = ["powershell", "-command", "Start-Sleep -m 500"];
8386
else
84-
c = ["sleep", "3"];
87+
c = ["bash", "-c", "sleep", "0.5"];
8588
end
8689

87-
[ret, ~, err] = stdlib.subprocess_run(c, "timeout", timeout);
90+
tc.verifyThat(@()stdlib.subprocess_run(c,timeout=timeout), ...
91+
Eventually(IsEqualTo(-1), WithTimeoutOf=2))
92+
93+
[~, ~, err] = stdlib.subprocess_run(c, timeout=timeout);
8894

89-
tc.verifyNotEqual(ret, 0, err)
9095
tc.verifyThat(err, StartsWithSubstring("Subprocess timeout"))
9196

9297
end

0 commit comments

Comments
 (0)