From e8f058a6e473078290b3235f0b4472b02008f0ba Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 4 Jun 2022 03:41:31 +0700 Subject: [PATCH] [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 :tada: * phpstan * final touch: eol * clean up * clean up * final touch: use escapeshellarg() * Add note for why escapeshellarg() is needed in parallel --- .github/workflows/e2e.yaml | 1 + e2e/parallel with space/composer.json | 5 +++++ e2e/parallel with space/rector.php | 12 ++++++++++++ e2e/parallel with space/src/Test.php | 5 +++++ .../Command/WorkerCommandLineFactory.php | 19 ++++++++++++++++++- 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 e2e/parallel with space/composer.json create mode 100644 e2e/parallel with space/rector.php create mode 100644 e2e/parallel with space/src/Test.php diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 5e20191d85b..a9b0cf25e46 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -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 }} diff --git a/e2e/parallel with space/composer.json b/e2e/parallel with space/composer.json new file mode 100644 index 00000000000..8b5ca727be7 --- /dev/null +++ b/e2e/parallel with space/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "php": "^8.1" + } +} diff --git a/e2e/parallel with space/rector.php b/e2e/parallel with space/rector.php new file mode 100644 index 00000000000..9974d13c138 --- /dev/null +++ b/e2e/parallel with space/rector.php @@ -0,0 +1,12 @@ +paths([ + __DIR__ . '/src', + ]); + $rectorConfig->parallel(); +}; diff --git a/e2e/parallel with space/src/Test.php b/e2e/parallel with space/src/Test.php new file mode 100644 index 00000000000..09037ce3e74 --- /dev/null +++ b/e2e/parallel with space/src/Test.php @@ -0,0 +1,5 @@ +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);