From 0a5cd64058948e164c5e2612294eb0ae806b4d08 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sat, 15 Feb 2020 13:43:21 +0100 Subject: [PATCH] Fixed running parallel analysis via shortcut command --- src/Parallel/ParallelAnalyser.php | 8 +------- .../ParallelAnalyserIntegrationTest.php | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Parallel/ParallelAnalyser.php b/src/Parallel/ParallelAnalyser.php index 1dbd742a89..69571d8f96 100644 --- a/src/Parallel/ParallelAnalyser.php +++ b/src/Parallel/ParallelAnalyser.php @@ -183,17 +183,11 @@ private function getWorkerCommand( InputInterface $input ): string { - $args = array_merge([PHP_BINARY, $mainScript], array_slice($_SERVER['argv'], 1)); $processCommandArray = []; - foreach ($args as $arg) { - if (in_array($arg, ['analyse', 'analyze'], true)) { - break; - } - + foreach ([PHP_BINARY, $mainScript, 'worker'] as $arg) { $processCommandArray[] = escapeshellarg($arg); } - $processCommandArray[] = 'worker'; if ($projectConfigFile !== null) { $processCommandArray[] = '--configuration'; $processCommandArray[] = escapeshellarg($projectConfigFile); diff --git a/tests/PHPStan/Parallel/ParallelAnalyserIntegrationTest.php b/tests/PHPStan/Parallel/ParallelAnalyserIntegrationTest.php index 1c99f25c68..77791bbcf5 100644 --- a/tests/PHPStan/Parallel/ParallelAnalyserIntegrationTest.php +++ b/tests/PHPStan/Parallel/ParallelAnalyserIntegrationTest.php @@ -8,12 +8,25 @@ class ParallelAnalyserIntegrationTest extends TestCase { - public function testTraitsInDifferentJobAnalysed(): void + public function dataRun(): array + { + return [ + ['analyse'], + ['a'], + ]; + } + + /** + * @dataProvider dataRun + * @param string $command + */ + public function testRun(string $command): void { exec(sprintf( - '%s %s analyse -l 8 -c %s --error-format json %s', + '%s %s %s -l 8 -c %s --error-format json %s', escapeshellarg(PHP_BINARY), escapeshellarg(__DIR__ . '/../../../bin/phpstan'), + $command, escapeshellarg(__DIR__ . '/parallel-analyser.neon'), implode(' ', array_map(static function (string $path): string { return escapeshellarg($path);