From baafa286232c780230f5264a6e31f4cf4b91a207 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Mon, 24 Nov 2025 11:56:07 +0000 Subject: [PATCH 1/3] Split download/build/install extension features --- features/build-extensions.feature | 17 +++++++++++++ features/download-extensions.feature | 22 +++++++++++++++++ features/install-extensions.feature | 36 ---------------------------- 3 files changed, 39 insertions(+), 36 deletions(-) create mode 100644 features/build-extensions.feature create mode 100644 features/download-extensions.feature diff --git a/features/build-extensions.feature b/features/build-extensions.feature new file mode 100644 index 00000000..3006594f --- /dev/null +++ b/features/build-extensions.feature @@ -0,0 +1,17 @@ +Feature: Extensions can be built with PIE + + # pie build + Example: An extension can be built + When I run a command to build an extension + Then the extension should have been built + + # pie build + Example: An extension can be built with warnings at PHP startup + Given I have an invalid extension installed + When I run a command to build an extension + Then the extension should have been built + + # pie build --with-some-options=foo + Example: An extension can be built with configure options + When I run a command to build an extension with configure options + Then the extension should have been built with options diff --git a/features/download-extensions.feature b/features/download-extensions.feature new file mode 100644 index 00000000..012e3928 --- /dev/null +++ b/features/download-extensions.feature @@ -0,0 +1,22 @@ +Feature: Extensions can be downloaded with PIE + + # pie download + Example: The latest version of an extension can be downloaded + When I run a command to download the latest version of an extension + Then the latest version should have been downloaded + + # pie download : + Scenario Outline: A version matching the requested constraint can be downloaded + When I run a command to download version "" of an extension + Then version "" should have been downloaded + + Examples: + | constraint | version | + | 2.0.5 | 2.0.5 | + | ^2.0 | 2.0.5 | + + # pie download :dev-main + @non-windows + Example: An in-development version can be downloaded on non-Windows systems + When I run a command to download version "dev-main" of an extension + Then version "dev-main" should have been downloaded diff --git a/features/install-extensions.feature b/features/install-extensions.feature index cbae8880..63d0b239 100644 --- a/features/install-extensions.feature +++ b/features/install-extensions.feature @@ -1,41 +1,5 @@ Feature: Extensions can be installed with PIE - # pie download - Example: The latest version of an extension can be downloaded - When I run a command to download the latest version of an extension - Then the latest version should have been downloaded - - # pie download : - Scenario Outline: A version matching the requested constraint can be downloaded - When I run a command to download version "" of an extension - Then version "" should have been downloaded - - Examples: - | constraint | version | - | 2.0.5 | 2.0.5 | - | ^2.0 | 2.0.5 | - - # pie download :dev-main - @non-windows - Example: An in-development version can be downloaded on non-Windows systems - When I run a command to download version "dev-main" of an extension - Then version "dev-main" should have been downloaded - - # pie build - Example: An extension can be built - When I run a command to build an extension - Then the extension should have been built - - Example: An extension can be built with warnings at PHP startup - Given I have an invalid extension installed - When I run a command to build an extension - Then the extension should have been built - - # pie build --with-some-options=foo - Example: An extension can be built with configure options - When I run a command to build an extension with configure options - Then the extension should have been built with options - # pie install --skip-enable-extension Example: An extension can be installed without enabling When I run a command to install an extension without enabling it From 3f3f5f87b7b4943ad4487332290d5ec56c55d335 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Mon, 24 Nov 2025 14:34:22 +0000 Subject: [PATCH 2/3] Allow capturing of requested package argument when configure options are placed before package argument --- src/Command/ArgvInput.php | 55 +++++++++++++++++++++++++++++ src/Container.php | 2 +- test/unit/Command/ArgvInputTest.php | 49 +++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/Command/ArgvInput.php create mode 100644 test/unit/Command/ArgvInputTest.php diff --git a/src/Command/ArgvInput.php b/src/Command/ArgvInput.php new file mode 100644 index 00000000..225c377a --- /dev/null +++ b/src/Command/ArgvInput.php @@ -0,0 +1,55 @@ +exceptionThrown = null; + + parent::parse(); + + if ($this->exceptionThrown !== null) { + throw $this->exceptionThrown; + } + } + + protected function parseToken(string $token, bool $parseOptions): bool + { + try { + return parent::parseToken($token, $parseOptions); + } catch (Throwable $caught) { + $this->exceptionThrown = $caught; + + // Ignore the error intentionally + return $parseOptions; + } + } +} diff --git a/src/Container.php b/src/Container.php index 2815650c..c24182bd 100644 --- a/src/Container.php +++ b/src/Container.php @@ -13,6 +13,7 @@ use Php\Pie\Building\Build; use Php\Pie\Building\UnixBuild; use Php\Pie\Building\WindowsBuild; +use Php\Pie\Command\ArgvInput; use Php\Pie\Command\BuildCommand; use Php\Pie\Command\DownloadCommand; use Php\Pie\Command\InfoCommand; @@ -43,7 +44,6 @@ use Symfony\Component\Console\Event\ConsoleCommandEvent; use Symfony\Component\Console\Formatter\OutputFormatter; use Symfony\Component\Console\Helper\QuestionHelper; -use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; diff --git a/test/unit/Command/ArgvInputTest.php b/test/unit/Command/ArgvInputTest.php new file mode 100644 index 00000000..c96da3c8 --- /dev/null +++ b/test/unit/Command/ArgvInputTest.php @@ -0,0 +1,49 @@ +>> */ + public static function argvWithInvalidInputProvider(): array + { + return [ + 'simple-option' => [['myapp', '--invalid-option', 'myvalue']], + 'value-option' => [['myapp', '--invalid-option=foo', 'myvalue']], + 'short-option' => [['myapp', '-i', 'myvalue']], + // explicitly not supported for now; we can't tell which is the argument here + // 'split-option' => [['myapp', '--invalid-option', 'foo', 'myvalue']], + ]; + } + + /** @param list $argv */ + #[DataProvider('argvWithInvalidInputProvider')] + public function testInvalidOptionsDoNotCauseArgumentsToBeMissed(array $argv): void + { + $definition = new InputDefinition(); + $definition->addArgument(new InputArgument('myarg', InputArgument::OPTIONAL)); + + $argvInput = new ArgvInput($argv); + try { + $argvInput->bind($definition); + self::fail('Expected an exception to be thrown because `--invalid-option` is not defined'); + } catch (Throwable) { + // An exception is expected here, because `--invalid-option` was not defined + self::addToAssertionCount(1); + } + + // But, crucially, we should have captured the following argument + self::assertSame('myvalue', $argvInput->getArgument('myarg')); + } +} From 9bac9f83b7d0a48fb6e104b5f1c66e680a677265 Mon Sep 17 00:00:00 2001 From: James Titcumb Date: Mon, 24 Nov 2025 14:54:30 +0000 Subject: [PATCH 3/3] Remove 8.5 RC step --- .github/workflows/continuous-integration.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 31b1690b..b422988e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -98,15 +98,9 @@ jobs: libbz2-dev \ libzip-dev - name: "Set php-src download URL" - if: ${{ !startsWith(matrix.php-versions, '8.5') }} run: | DIST_URL=`curl -fsSL "https://www.php.net/releases/index.php?json&max=1&version=${{ matrix.php-versions }}" | jq -r '.[].source[]|select(.filename|endswith(".gz")).filename'` echo "php_src_download_url=https://www.php.net/distributions/$DIST_URL" >> $GITHUB_ENV - - name: "Set php-src download URL (8.5 pre-release)" - if: ${{ startsWith(matrix.php-versions, '8.5') }} - run: | - RC_URL=`curl -fsSL "https://www.php.net/release-candidates.php?format=json" | jq -r '.releases[]|select(.version|startswith("${{ matrix.php-versions }}")).files.gz.path'` - echo "php_src_download_url=$RC_URL" >> $GITHUB_ENV - name: "Install PHP ${{ matrix.php-versions }}" run: | mkdir -p /tmp/php