From aa8fa4498c5b4d7cec8253b4844860168ec4b25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sun, 10 Jul 2022 15:48:46 +0200 Subject: [PATCH] Capture buggy behaviour with forwarded command (#113) Related to #106 --- e2e/scenario7/.gitignore | 5 +++++ e2e/scenario7/README.md | 1 + e2e/scenario7/composer.json | 16 +++++++++++++++ e2e/scenario7/expected.txt | 9 ++++++++ e2e/scenario7/script.sh | 24 ++++++++++++++++++++++ e2e/scenario7/vendor-bin/ns1/composer.json | 8 ++++++++ e2e/scenario8/.gitignore | 5 +++++ e2e/scenario8/README.md | 3 +++ e2e/scenario8/composer.json | 21 +++++++++++++++++++ e2e/scenario8/expected.txt | 22 ++++++++++++++++++++ e2e/scenario8/script.sh | 22 ++++++++++++++++++++ e2e/scenario8/vendor-bin/ns1/composer.json | 8 ++++++++ 12 files changed, 144 insertions(+) create mode 100644 e2e/scenario7/.gitignore create mode 100644 e2e/scenario7/README.md create mode 100644 e2e/scenario7/composer.json create mode 100644 e2e/scenario7/expected.txt create mode 100755 e2e/scenario7/script.sh create mode 100644 e2e/scenario7/vendor-bin/ns1/composer.json create mode 100644 e2e/scenario8/.gitignore create mode 100644 e2e/scenario8/README.md create mode 100644 e2e/scenario8/composer.json create mode 100644 e2e/scenario8/expected.txt create mode 100755 e2e/scenario8/script.sh create mode 100644 e2e/scenario8/vendor-bin/ns1/composer.json diff --git a/e2e/scenario7/.gitignore b/e2e/scenario7/.gitignore new file mode 100644 index 0000000..cac9c03 --- /dev/null +++ b/e2e/scenario7/.gitignore @@ -0,0 +1,5 @@ +/actual.txt +/composer.lock +/vendor/ +/vendor-bin/*/composer.lock +/vendor-bin/*/vendor/ diff --git a/e2e/scenario7/README.md b/e2e/scenario7/README.md new file mode 100644 index 0000000..87140b4 --- /dev/null +++ b/e2e/scenario7/README.md @@ -0,0 +1 @@ +Tests that dev dependencies are not installed if no-dev is passed. diff --git a/e2e/scenario7/composer.json b/e2e/scenario7/composer.json new file mode 100644 index 0000000..bff880f --- /dev/null +++ b/e2e/scenario7/composer.json @@ -0,0 +1,16 @@ +{ + "repositories": [ + { + "type": "path", + "url": "../../" + } + ], + "require": { + "bamarni/composer-bin-plugin": "dev-master" + }, + "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + } + } +} diff --git a/e2e/scenario7/expected.txt b/e2e/scenario7/expected.txt new file mode 100644 index 0000000..f6bd9e9 --- /dev/null +++ b/e2e/scenario7/expected.txt @@ -0,0 +1,9 @@ +[bamarni-bin] Current working directory: /path/to/project/e2e/scenario7 +[bamarni-bin] Configuring bin directory to /path/to/project/e2e/scenario7/vendor/bin. +[bamarni-bin] Checking namespace vendor-bin/ns1 +[bamarni-bin] Changed current directory to vendor-bin/ns1. +[bamarni-bin] Running `@composer update --no-dev --verbose --working-dir='.' -- foo`. +Cannot update only a partial set of packages without a lock file present. Run `composer update` to generate a lock file. +[bamarni-bin] Changed current directory to /path/to/project/e2e/scenario7. +––––––––––––––––––––– +No dependencies installed. Try running composer install or update. diff --git a/e2e/scenario7/script.sh b/e2e/scenario7/script.sh new file mode 100755 index 0000000..ea402a7 --- /dev/null +++ b/e2e/scenario7/script.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +readonly ORIGINAL_WORKING_DIR=$(pwd) + +trap "cd ${ORIGINAL_WORKING_DIR}" err exit + +# Change to script directory +cd "$(dirname "$0")" + +# Ensure we have a clean state +rm -rf actual.txt || true +rm -rf composer.lock || true +rm -rf vendor || true +rm -rf vendor-bin/*/composer.lock || true +rm -rf vendor-bin/*/vendor || true + +composer update + +# Actual command to execute the test itself +composer bin ns1 update --no-dev --verbose -- foo 2>&1 | tee > actual.txt || true +echo "–––––––––––––––––––––" >> actual.txt +composer bin ns1 show --direct --name-only 2>&1 | tee >> actual.txt || true diff --git a/e2e/scenario7/vendor-bin/ns1/composer.json b/e2e/scenario7/vendor-bin/ns1/composer.json new file mode 100644 index 0000000..7b72340 --- /dev/null +++ b/e2e/scenario7/vendor-bin/ns1/composer.json @@ -0,0 +1,8 @@ +{ + "require": { + "nikic/iter": "v1.6.0" + }, + "require-dev": { + "phpstan/phpstan": "1.8.0" + } +} diff --git a/e2e/scenario8/.gitignore b/e2e/scenario8/.gitignore new file mode 100644 index 0000000..cac9c03 --- /dev/null +++ b/e2e/scenario8/.gitignore @@ -0,0 +1,5 @@ +/actual.txt +/composer.lock +/vendor/ +/vendor-bin/*/composer.lock +/vendor-bin/*/vendor/ diff --git a/e2e/scenario8/README.md b/e2e/scenario8/README.md new file mode 100644 index 0000000..9cdf3ed --- /dev/null +++ b/e2e/scenario8/README.md @@ -0,0 +1,3 @@ +Tests that extra arguments and options are not lost when forwarding the command to a bin namespace. +In this scenario the dependencies are not install in the bin namespace since the parsed (forwarded) +command is invalid. diff --git a/e2e/scenario8/composer.json b/e2e/scenario8/composer.json new file mode 100644 index 0000000..3061d0c --- /dev/null +++ b/e2e/scenario8/composer.json @@ -0,0 +1,21 @@ +{ + "repositories": [ + { + "type": "path", + "url": "../../" + } + ], + "require": { + "bamarni/composer-bin-plugin": "dev-master" + }, + "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + } + }, + "extra": { + "bamarni-bin": { + "forward-command": true + } + } +} diff --git a/e2e/scenario8/expected.txt b/e2e/scenario8/expected.txt new file mode 100644 index 0000000..0bfcdd3 --- /dev/null +++ b/e2e/scenario8/expected.txt @@ -0,0 +1,22 @@ +Loading composer repositories with package information +Updating dependencies +Lock file operations: 1 install, 0 updates, 0 removals + - Locking bamarni/composer-bin-plugin (dev-hash) +Writing lock file +Installing dependencies from lock file +Package operations: 1 install, 0 updates, 0 removals + - Installing bamarni/composer-bin-plugin (dev-hash): Symlinking from ../.. +Generating autoload files +[bamarni-bin] The command is being forwarded. +Loading composer repositories with package information +Updating dependencies +Lock file operations: 2 installs, 0 updates, 0 removals + - Locking nikic/iter (v1.6.0) + - Locking phpstan/phpstan (1.8.0) +Writing lock file +Installing dependencies from lock file +Package operations: 1 install, 0 updates, 0 removals + - Installing nikic/iter (v1.6.0): Extracting archive +Generating autoload files +–––––––––––––– +nikic/iter diff --git a/e2e/scenario8/script.sh b/e2e/scenario8/script.sh new file mode 100755 index 0000000..11786d5 --- /dev/null +++ b/e2e/scenario8/script.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +readonly ORIGINAL_WORKING_DIR=$(pwd) + +trap "cd ${ORIGINAL_WORKING_DIR}" err exit + +# Change to script directory +cd "$(dirname "$0")" + +# Ensure we have a clean state +rm -rf actual.txt || true +rm -rf composer.lock || true +rm -rf vendor || true +rm -rf vendor-bin/*/composer.lock || true +rm -rf vendor-bin/*/vendor || true + +# Actual command to execute the test itself +composer update --no-dev 2>&1 | tee > actual.txt || true +echo "––––––––––––––" >> actual.txt +composer bin ns1 show --direct --name-only 2>&1 | tee >> actual.txt || true diff --git a/e2e/scenario8/vendor-bin/ns1/composer.json b/e2e/scenario8/vendor-bin/ns1/composer.json new file mode 100644 index 0000000..7b72340 --- /dev/null +++ b/e2e/scenario8/vendor-bin/ns1/composer.json @@ -0,0 +1,8 @@ +{ + "require": { + "nikic/iter": "v1.6.0" + }, + "require-dev": { + "phpstan/phpstan": "1.8.0" + } +}