Skip to content

Commit

Permalink
Add tests to ensure environment variables are correctly forwarded (#116)
Browse files Browse the repository at this point in the history
Closes #63
  • Loading branch information
theofidry authored Jul 10, 2022
1 parent 3ccc33d commit c1bbee3
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
6 changes: 6 additions & 0 deletions e2e/scenario10/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/actual.txt
/.composer/
/composer.lock
/vendor/
/vendor-bin/*/composer.lock
/vendor-bin/*/vendor/
1 change: 1 addition & 0 deletions e2e/scenario10/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check that the composer environment variables are well respected when commands are forwarded to the namespaces.
21 changes: 21 additions & 0 deletions e2e/scenario10/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
}
}
}
2 changes: 2 additions & 0 deletions e2e/scenario10/expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./.composer
.composer
31 changes: 31 additions & 0 deletions e2e/scenario10/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -Eeuo pipefail

# Set env envariables in order to experience a behaviour closer to what happens
# in the CI locally. It should not hurt to set those in the CI as the CI should
# contain those values.
export CI=1
export COMPOSER_NO_INTERACTION=1

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 || true
rm -rf composer.lock || true
rm -rf vendor || true
rm -rf vendor-bin/*/composer.lock || true
rm -rf vendor-bin/*/vendor || true
rm -rf vendor-bin/*/.composer || true

readonly CUSTOM_COMPOSER_DIR=$(pwd)/.composer
COMPOSER_CACHE_DIR=$CUSTOM_COMPOSER_DIR composer update

# Actual command to execute the test itself
find . ".composer" -name ".composer" -type d 2>&1 | tee > actual.txt || true
5 changes: 5 additions & 0 deletions e2e/scenario10/vendor-bin/ns1/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"nikic/iter": "v1.6.0"
}
}
2 changes: 1 addition & 1 deletion e2e/scenario9/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Tests that extra arguments and options are not lost when forwarding the command to a bin namespace.
Tests that plugins installed in a namespace are loaded when a command is executed in the namespace.

0 comments on commit c1bbee3

Please sign in to comment.