From 632c0eb267c03ecaedd621f8ab1e675545fbd7cd Mon Sep 17 00:00:00 2001 From: Massimiliano Torromeo Date: Wed, 11 Mar 2026 14:33:09 +0100 Subject: [PATCH] fix: broken testing environment start due to changes in startTemporalServer --- testing/src/Environment.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/testing/src/Environment.php b/testing/src/Environment.php index 2fa8119e..32790d08 100644 --- a/testing/src/Environment.php +++ b/testing/src/Environment.php @@ -123,7 +123,7 @@ public function startTemporalServer( $this->temporalServerProcess->start(); $deadline = \microtime(true) + $commandTimeout; - while (!$temporalStarted && \microtime(true) < $deadline) { + while ($this->temporalServerProcess->isRunning() && !$temporalStarted && \microtime(true) < $deadline) { \usleep(10_000); $check = new Process([ $this->systemInfo->temporalCliExecutable, @@ -192,7 +192,7 @@ public function startTemporalTestServer(int $commandTimeout = 10): void /** * @param array $envs */ - public function startRoadRunner(?string $rrCommand = null, int $commandTimeout = 10, array $envs = [], string $configFile = '.rr.yaml'): void + public function startRoadRunner(string|array|null $rrCommand = null, int $commandTimeout = 10, array $envs = [], string $configFile = '.rr.yaml'): void { if (!$this->isTemporalRunning() && !$this->isTemporalTestRunning()) { $this->io->error([ @@ -201,8 +201,14 @@ public function startRoadRunner(?string $rrCommand = null, int $commandTimeout = exit(1); } + if (is_string($rrCommand)) { + $rrCommand = \explode(' ', $rrCommand); + } + + $rrCommand ??= [$this->systemInfo->rrExecutable, 'serve', '-c', $configFile]; + $this->roadRunnerProcess = new Process( - command: $rrCommand ? \explode(' ', $rrCommand) : [$this->systemInfo->rrExecutable, 'serve'], + command: $rrCommand, env: $envs, ); $this->roadRunnerProcess->setTimeout($commandTimeout); @@ -214,16 +220,16 @@ public function startRoadRunner(?string $rrCommand = null, int $commandTimeout = // wait for roadrunner to start $deadline = \microtime(true) + $commandTimeout; - while (!$roadRunnerStarted && \microtime(true) < $deadline) { + while ($this->roadRunnerProcess->isRunning() && !$roadRunnerStarted && \microtime(true) < $deadline) { \usleep(10_000); - $check = new Process([$this->systemInfo->rrExecutable, 'workers', '-c', $configFile]); + $check = new Process(array_map(static fn ($arg) => $arg === 'serve' ? 'workers' : $arg, $rrCommand)); $check->run(); if (\str_contains($check->getOutput(), 'Workers of')) { $roadRunnerStarted = true; } } - if (!$roadRunnerStarted) { + if (!$roadRunnerStarted || !$this->roadRunnerProcess->isRunning()) { $this->io->error(\sprintf( 'Failed to start until RoadRunner is ready. Status: "%s". Stderr: "%s". Stdout: "%s".', $this->roadRunnerProcess->getStatus(),