Skip to content

Commit

Permalink
Fixed running parallel analysis via shortcut command
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Feb 15, 2020
1 parent 0464d0f commit 0a5cd64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/Parallel/ParallelAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 15 additions & 2 deletions tests/PHPStan/Parallel/ParallelAnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0a5cd64

Please sign in to comment.