Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Dec 13, 2024
1 parent b7d1929 commit 8cf3e1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion tests/swoole_coroutine/cancel/wait.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ swoole_coroutine/cancel: wait/waitpid
<?php
require __DIR__ . '/../../include/bootstrap.php';

use Swoole\Process;
use function Swoole\Coroutine\run;
use function Swoole\Coroutine\go;
use Swoole\Coroutine;
use Swoole\Coroutine\System;

run(function () {
$proc = new Process(function (){
sleep(100);
}, false, 0);
$proc->start();

run(function () use ($proc) {
$cid = Coroutine::getCid();
go(function () use ($cid) {
System::sleep(0.002);
Assert::true(Coroutine::cancel($cid));
});

$retval = System::wait();
echo "Done\n";
Process::kill($proc->pid, SIGKILL);
Assert::eq($retval, false);
Assert::eq(swoole_last_error(), SWOOLE_ERROR_CO_CANCELED);
});
Expand Down
4 changes: 2 additions & 2 deletions tests/swoole_runtime/base.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ go(function () use ($server) {
$server->shutdown();
});
echo '5' . PHP_EOL;
Swoole\Runtime::enableCoroutine(true); // all
Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL); // all
go(function () {
usleep(5 * 1000);
echo 'sleep1' . PHP_EOL;
Expand All @@ -57,7 +57,7 @@ go(function () use ($server) {
});
echo '7' . PHP_EOL;
Swoole\Event::wait();
Swoole\Runtime::enableCoroutine(false); // disable all
Swoole\Runtime::enableCoroutine(0); // disable all
?>
--EXPECT--
1
Expand Down

0 comments on commit 8cf3e1b

Please sign in to comment.