diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-04 05:25:30 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-04 05:43:36 +0900 |
| commit | 2cb2f128cffb4e664145c9a8a392b9666d014459 (patch) | |
| tree | 1b14c97f384dac7e0b708399553914be914fcf44 /crates/shirabe/tests/plugin/fixtures/e2e | |
| parent | b1ec6db345f1b2fe67ccf39fd0d2b77d85cb18c5 (diff) | |
| download | php-shirabe-2cb2f128cffb4e664145c9a8a392b9666d014459.tar.gz php-shirabe-2cb2f128cffb4e664145c9a8a392b9666d014459.tar.zst php-shirabe-2cb2f128cffb4e664145c9a8a392b9666d014459.zip | |
test(plugin): compare a real-plugin install against upstream Composer
Run upstream Composer and Shirabe over pristine copies of a fixture
project at the same path and require composer.lock, the whole vendor tree
(including the plugin-generated GeneratedConfig.php), the plugin's IO
lines and the exit code to match byte for byte.
The plugin under test (phpstan/extension-installer 1.4.3) is downloaded by
fixtures/e2e/fetch — pinned to an upstream commit and hash-verified — into
a git-ignored directory rather than committed; the test skips while it is
absent, like the other real-PHP prerequisites. Its dependencies are
minimal stand-ins resolved from local repositories, so test runs stay
offline. A zip dist would exercise the known lossy-string byte-precision
debt in RemoteFilesystem, so the fixture serves the plugin through a path
dist until that is resolved.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/plugin/fixtures/e2e')
6 files changed, 127 insertions, 0 deletions
diff --git a/crates/shirabe/tests/plugin/fixtures/e2e/fetch b/crates/shirabe/tests/plugin/fixtures/e2e/fetch new file mode 100755 index 00000000..a4179955 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e/fetch @@ -0,0 +1,33 @@ +#!/bin/sh +# Fetches the external plugin the E2E test runs against, into the git-ignored ext/ +# directory. The plugin is pinned to an immutable upstream commit and the extracted +# files are verified by hash, so the test stays deterministic without the third-party +# source ever entering this repository. Requires network once; the E2E test skips +# itself while ext/ is absent. +set -eu + +# phpstan/extension-installer 1.4.3 +commit=85e90b3942d06b2326fba0403ec24fe912372936 +dir="$(dirname "$0")/ext/phpstan-extension-installer-1.4.3" + +if [ -f "$dir/src/Plugin.php" ]; then + echo "already fetched: $dir" + exit 0 +fi + +mkdir -p "$dir" +curl -fsSL "https://codeload.github.com/phpstan/extension-installer/tar.gz/$commit" \ + | tar -xz -C "$dir" --strip-components=1 + +# GitHub archives are content-addressed by the commit, but the archive encoding is not +# guaranteed stable; the extracted files are what the test consumes, so they are what +# gets pinned. +(cd "$dir" && sha256sum -c --quiet) <<'EOF' || { rm -rf "$dir"; echo "hash mismatch; discarded the fetched tree" >&2; exit 1; } +92d8a5f0f9da0ebe198fe466bc4efc1793d90d8da93efd912fdc9dc414a56885 LICENSE +76197285d0c2a8dec7cff9f8562638bda879367829fd982281cba53068c7f153 README.md +71f6125d095522d8b24925d9144d361b2419f41be6174607b026473ae65c2604 composer.json +fc46b5548e9656fab230ed4b97fdf13b54712743d04498374d40ebae2610bac1 src/GeneratedConfig.php +5803a3fb8c272d52848e4aa240707370e301fa081fc632b487fafacfe4985af7 src/Plugin.php +EOF + +echo "fetched: $dir" diff --git a/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-extension/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-extension/composer.json new file mode 100644 index 00000000..066c25e3 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-extension/composer.json @@ -0,0 +1,11 @@ +{ + "name": "acme/extension", + "version": "1.0.0", + "type": "phpstan-extension", + "description": "PHPStan extension fixture handled by phpstan/extension-installer.", + "extra": { + "phpstan": { + "includes": ["extension.neon"] + } + } +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-extension/extension.neon b/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-extension/extension.neon new file mode 100644 index 00000000..e9bca97b --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-extension/extension.neon @@ -0,0 +1,2 @@ +parameters: + acmeExtensionLoaded: true diff --git a/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-phpstan-tools/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-phpstan-tools/composer.json new file mode 100644 index 00000000..074dbe8c --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e/packages/acme-phpstan-tools/composer.json @@ -0,0 +1,5 @@ +{ + "name": "acme/phpstan-tools", + "version": "1.0.0", + "description": "Package whose name mentions phpstan without being an extension; exercises the NOT_INSTALLED path." +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e/packages/phpstan-phpstan/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e/packages/phpstan-phpstan/composer.json new file mode 100644 index 00000000..cbd11818 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e/packages/phpstan-phpstan/composer.json @@ -0,0 +1,5 @@ +{ + "name": "phpstan/phpstan", + "version": "2.1.0", + "description": "Minimal stand-in for phpstan/phpstan used by the extension-installer E2E fixture." +} diff --git a/crates/shirabe/tests/plugin/fixtures/e2e/project/composer.json b/crates/shirabe/tests/plugin/fixtures/e2e/project/composer.json new file mode 100644 index 00000000..d16b5383 --- /dev/null +++ b/crates/shirabe/tests/plugin/fixtures/e2e/project/composer.json @@ -0,0 +1,71 @@ +{ + "name": "shirabe/e2e-extension-installer", + "description": "E2E fixture project: install phpstan/extension-installer and let it generate its config.", + "repositories": [ + { + "type": "package", + "package": { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "type": "composer-plugin", + "license": [ + "MIT" + ], + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "require": { + "php": "^7.2 || ^8.0", + "composer-plugin-api": "^2.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "dist": { + "type": "path", + "url": "../ext/phpstan-extension-installer-1.4.3" + }, + "transport-options": { + "symlink": false + } + } + }, + { + "type": "path", + "url": "../packages/phpstan-phpstan", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "../packages/acme-extension", + "options": { + "symlink": false + } + }, + { + "type": "path", + "url": "../packages/acme-phpstan-tools", + "options": { + "symlink": false + } + }, + { + "packagist.org": false + } + ], + "require": { + "phpstan/extension-installer": "1.4.3", + "acme/extension": "1.0.0", + "acme/phpstan-tools": "1.0.0" + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } + } +} |
