Skip to content

Commit

Permalink
Capture buggy behaviour with forwarded command (bamarni#113)
Browse files Browse the repository at this point in the history
Related to bamarni#106
  • Loading branch information
theofidry committed Jul 10, 2022
1 parent a0b2a84 commit aa8fa44
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/scenario7/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/actual.txt
/composer.lock
/vendor/
/vendor-bin/*/composer.lock
/vendor-bin/*/vendor/
1 change: 1 addition & 0 deletions e2e/scenario7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tests that dev dependencies are not installed if no-dev is passed.
16 changes: 16 additions & 0 deletions e2e/scenario7/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"repositories": [
{
"type": "path",
"url": "../../"
}
],
"require": {
"bamarni/composer-bin-plugin": "dev-master"
},
"config": {
"allow-plugins": {
"bamarni/composer-bin-plugin": true
}
}
}
9 changes: 9 additions & 0 deletions e2e/scenario7/expected.txt
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 24 additions & 0 deletions e2e/scenario7/script.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions e2e/scenario7/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": {
"nikic/iter": "v1.6.0"
},
"require-dev": {
"phpstan/phpstan": "1.8.0"
}
}
5 changes: 5 additions & 0 deletions e2e/scenario8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/actual.txt
/composer.lock
/vendor/
/vendor-bin/*/composer.lock
/vendor-bin/*/vendor/
3 changes: 3 additions & 0 deletions e2e/scenario8/README.md
Original file line number Diff line number Diff line change
@@ -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.
21 changes: 21 additions & 0 deletions e2e/scenario8/composer.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
22 changes: 22 additions & 0 deletions e2e/scenario8/expected.txt
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions e2e/scenario8/script.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions e2e/scenario8/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": {
"nikic/iter": "v1.6.0"
},
"require-dev": {
"phpstan/phpstan": "1.8.0"
}
}

0 comments on commit aa8fa44

Please sign in to comment.