From 1bb891c41cab9f88fb110900a25228c25887687c Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Mon, 29 May 2023 12:44:25 -0300 Subject: [PATCH] List all process Signed-off-by: Vitor Mattos --- .github/workflows/behat.yml | 5 ++++- README.md | 2 +- src/RunServerListener.php | 7 +++++-- src/Server.php | 4 ++++ tests/psalm-baseline.xml | 13 ++++++++----- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/behat.yml b/.github/workflows/behat.yml index 0d608b2..09f931f 100644 --- a/.github/workflows/behat.yml +++ b/.github/workflows/behat.yml @@ -25,4 +25,7 @@ jobs: run: composer install - name: Run behat - run: vendor/bin/behat + run: | + BEHAT_RUN_AS=$(ls -ld behat.yml | awk '{print $3}') + BEHAT_VERBOSE=$ACTIONS_RUNNER_DEBUG + vendor/bin/behat diff --git a/README.md b/README.md index 0589f83..715bceb 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ default: | config | default | Environment | Description | | ------- | ------------- | -------------- | -------------------------------------------------- | -| verbose | false | none | Enables/disables verbose mode | +| verbose | false | BEHAT_VERBOSE | Enables/disables verbose mode | | rootDir | /var/www/html | BEHAT_HOST | Specifies http root dir | | host | localhost | BEHAT_ROOT_DIR | Host domain or IP | | runAs | | BEHAT_RUN_AS | The username to be used to run the built-in server | diff --git a/src/RunServerListener.php b/src/RunServerListener.php index 2972e2b..d4c303b 100644 --- a/src/RunServerListener.php +++ b/src/RunServerListener.php @@ -114,7 +114,10 @@ public function start(): void } if (!$this->isRunning()) { - throw new ServerException('Failed to start server. Is something already running on port ' . self::$port . '?'); + throw new ServerException( + 'Failed to start server. Is something already running on port ' . self::$port . "?\n" . + 'Full command: ' . $fullCmd + ); } register_shutdown_function(function () { @@ -162,7 +165,7 @@ public function killZombies(): void 'grep "php -S ' . self::$host . '"|' . 'grep -v grep|' . 'sed -e "s/^[[:space:]]*//"|cut -d" " -f1'; - $pids = trim(exec($cmd)); + $pids = trim(shell_exec($cmd)); $pids = explode("\n", $pids); foreach ($pids as $pid) { if ($pid) { diff --git a/src/Server.php b/src/Server.php index be19fa1..48df64f 100644 --- a/src/Server.php +++ b/src/Server.php @@ -150,6 +150,10 @@ private function getVerboseLevel(ContainerBuilder $container, array $config): ?i $verbose = $input->getParameterOption('-v'); return strlen($verbose); } + $runAs = getenv('BEHAT_VERBOSE'); + if ($runAs) { + return $runAs; + } return $config['verbose'] ? 0 : null; } diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 4e198d3..44c9394 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -1,8 +1,11 @@ - - - - scalarNode - + + + + shell_exec($cmd) + + + shell_exec($cmd) +