1818use Pest \Kernel ;
1919use Pest \Plugins \Concerns \HandleArguments ;
2020use Pest \Support \Container ;
21- use PHPUnit \TextUI \Application ;
2221use Swoole \Coroutine ;
2322use Swoole \Timer ;
24- use Symfony \Component \Console \Output \OutputInterface ;
2523
2624/**
2725 * @property string $vendorDir
2826 */
29- class Pest implements HandlesArguments
27+ final class Pest implements HandlesArguments
3028{
3129 use HandleArguments;
3230
@@ -43,22 +41,19 @@ public function handleArguments(array $arguments): array
4341 }
4442
4543 if ($ this ->hasArgument ('--parallel ' , $ arguments ) || $ this ->hasArgument ('-p ' , $ arguments )) {
46- throw new InvalidOption ('The coroutine mode is not supported when running in parallel. ' );
44+ throw new InvalidOption ('The [-- coroutine] option is not supported when running in parallel. ' );
4745 }
4846
4947 $ arguments = $ this ->popArgument ('--coroutine ' , $ arguments );
5048
51- exit ($ this ->runInCoroutine ($ arguments ));
49+ exit ($ this ->runTestsInCoroutine ($ arguments ));
5250 }
5351
54- private function runInCoroutine (array $ arguments ): int
52+ private function runTestsInCoroutine (array $ arguments ): int
5553 {
5654 $ code = 0 ;
57- $ output = Container::getInstance ()->get (OutputInterface::class);
58- $ kernel = new Kernel (
59- new Application (),
60- $ output ,
61- );
55+ /** @var Kernel $kernel */
56+ $ kernel = Container::getInstance ()->get (Kernel::class);
6257
6358 Coroutine::set (['hook_flags ' => SWOOLE_HOOK_ALL , 'exit_condition ' => function () {
6459 return Coroutine::stats ()['coroutine_num ' ] === 0 ;
@@ -79,12 +74,14 @@ private function runInCoroutine(array $arguments): int
7974 private function prepend (array $ arguments ): array
8075 {
8176 $ prepend = null ;
77+
8278 foreach ($ arguments as $ key => $ argument ) {
8379 if (str_starts_with ($ argument , '--prepend= ' )) {
8480 $ prepend = explode ('= ' , $ argument , 2 )[1 ];
8581 unset($ arguments [$ key ]);
8682 break ;
8783 }
84+
8885 if (str_starts_with ($ argument , '--prepend ' )) {
8986 if (isset ($ arguments [$ key + 1 ])) {
9087 $ prepend = $ arguments [$ key + 1 ];
0 commit comments