[e2e] Add e2e for parallel process with current directory contains space (#2421)

* [e2e] Add e2e for parallel process with current directory contains space

* [e2e] Add e2e for parallel process with current directory contains space

* dir name

* Fixed 🎉

* phpstan

* final touch: eol

* clean up

* clean up

* final touch: use escapeshellarg()

* Add note for why escapeshellarg() is needed in parallel
This commit is contained in:
Abdul Malik Ikhsan 2022-06-04 03:41:31 +07:00 committed by GitHub
parent d2bf080d6b
commit e8f058a6e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 1 deletions

View File

@ -32,6 +32,7 @@ jobs:
- 'e2e/template-extends'
- 'e2e/use-rector-configurator'
- 'e2e/applied-rule-removed-node'
- 'e2e/parallel with space'
name: End to end test - ${{ matrix.directory }}

View File

@ -0,0 +1,5 @@
{
"require": {
"php": "^8.1"
}
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src',
]);
$rectorConfig->parallel();
};

View File

@ -0,0 +1,5 @@
<?php
class Test
{
}

View File

@ -93,7 +93,24 @@ final class WorkerCommandLineFactory
if ($input->hasOption(Option::CONFIG)) {
$workerCommandArray[] = '--config';
$workerCommandArray[] = $input->getOption(Option::CONFIG);
/**
* On parallel, the command is generated with `--config` addition
* Using escapeshellarg() to ensure the --config path escaped, even when it has a space.
*
* eg:
* --config /path/e2e/parallel with space/rector.php
*
* that can cause error:
*
* File /rector-src/e2e/parallel\" was not found
*
* the escaped result is:
*
* --config '/path/e2e/parallel with space/rector.php'
*
* tested in macOS and Ubuntu (github action)
*/
$workerCommandArray[] = escapeshellarg($input->getOption(Option::CONFIG));
}
return implode(' ', $workerCommandArray);