Skip to content

Commit 56194b9

Browse files
Optimized co-phpunit do not broken in coroutine environment, when cases failed. (#1636)
* 测试中的出现异常不应该直接使用 exit 退出, 这样无法准确定位哪个测试没通过 * Optimized code. Co-authored-by: 李铭昕 <[email protected]>
1 parent f2a4d08 commit 56194b9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

co-phpunit

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env php
22
<?php
3-
\Swoole\Coroutine::create(function () {
3+
4+
$code = 0;
5+
\Swoole\Coroutine::create(function () use (&$code) {
46
if (version_compare('7.1.0', PHP_VERSION, '>')) {
57
fwrite(
68
STDERR,
@@ -58,9 +60,8 @@
5860
require PHPUNIT_COMPOSER_INSTALL;
5961

6062
$code = PHPUnit\TextUI\Command::main(false);
61-
if ($code > 0) {
62-
exit($code);
63-
}
64-
65-
swoole_event_exit();
6663
});
64+
65+
swoole_event_wait();
66+
67+
exit($code);

0 commit comments

Comments
 (0)