Skip to content

Commit f0de38d

Browse files
committed
Stabilize test case timing
1 parent 4b44780 commit f0de38d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

tests/AsyncTaskTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ public function testAsyncTimeout()
138138
$task = new AsyncTask($timeoutTask);
139139
$task->withTimeLimit(1)->start();
140140
// we wait for it to timeout
141-
$this->sleep(2);
141+
$this->sleep(0.5);
142+
$this->sleep(0.5);
143+
$this->sleep(0.5);
142144
// should have timed out
143145
$this->assertFileExists($textFilePath, "The async task probably did not trigger its timeout handler because its timeout output file is not found.");
144146
$this->assertStringEqualsFile($textFilePath, $message);

tests/Tasks/TestTimeoutNormalTask.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ public function __construct(
1717
public function execute(): void
1818
{
1919
// we have to sleep a bit to trigger the timeout
20-
// the test has a timeout of 1s, so we try to sleep for 1.5s
21-
sleep(1);
22-
usleep(500000);
20+
// the test has a timeout of 1s, so we try to sleep for slightly longer than 1 seconds
21+
// this is currently 1.2 seconds
22+
usleep(300000);
23+
usleep(300000);
24+
usleep(300000);
25+
usleep(300000);
2326
}
2427

2528
public function handleTimeout(): void

0 commit comments

Comments
 (0)