From c1bbee3662a2a84c6aad84b7c6daefcae29e5690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sun, 10 Jul 2022 19:28:16 +0200 Subject: [PATCH] Add tests to ensure environment variables are correctly forwarded (#116) Closes #63 --- e2e/scenario10/.gitignore | 6 ++++ e2e/scenario10/README.md | 1 + e2e/scenario10/composer.json | 21 ++++++++++++++ e2e/scenario10/expected.txt | 2 ++ e2e/scenario10/script.sh | 31 +++++++++++++++++++++ e2e/scenario10/vendor-bin/ns1/composer.json | 5 ++++ e2e/scenario9/README.md | 2 +- 7 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 e2e/scenario10/.gitignore create mode 100644 e2e/scenario10/README.md create mode 100644 e2e/scenario10/composer.json create mode 100644 e2e/scenario10/expected.txt create mode 100755 e2e/scenario10/script.sh create mode 100644 e2e/scenario10/vendor-bin/ns1/composer.json diff --git a/e2e/scenario10/.gitignore b/e2e/scenario10/.gitignore new file mode 100644 index 0000000..1fced8e --- /dev/null +++ b/e2e/scenario10/.gitignore @@ -0,0 +1,6 @@ +/actual.txt +/.composer/ +/composer.lock +/vendor/ +/vendor-bin/*/composer.lock +/vendor-bin/*/vendor/ diff --git a/e2e/scenario10/README.md b/e2e/scenario10/README.md new file mode 100644 index 0000000..0ffbf03 --- /dev/null +++ b/e2e/scenario10/README.md @@ -0,0 +1 @@ +Check that the composer environment variables are well respected when commands are forwarded to the namespaces. diff --git a/e2e/scenario10/composer.json b/e2e/scenario10/composer.json new file mode 100644 index 0000000..3061d0c --- /dev/null +++ b/e2e/scenario10/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/scenario10/expected.txt b/e2e/scenario10/expected.txt new file mode 100644 index 0000000..033cf0b --- /dev/null +++ b/e2e/scenario10/expected.txt @@ -0,0 +1,2 @@ +./.composer +.composer diff --git a/e2e/scenario10/script.sh b/e2e/scenario10/script.sh new file mode 100755 index 0000000..9f012a3 --- /dev/null +++ b/e2e/scenario10/script.sh @@ -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 diff --git a/e2e/scenario10/vendor-bin/ns1/composer.json b/e2e/scenario10/vendor-bin/ns1/composer.json new file mode 100644 index 0000000..9871ea3 --- /dev/null +++ b/e2e/scenario10/vendor-bin/ns1/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "nikic/iter": "v1.6.0" + } +} diff --git a/e2e/scenario9/README.md b/e2e/scenario9/README.md index 9af1b6d..80f120b 100644 --- a/e2e/scenario9/README.md +++ b/e2e/scenario9/README.md @@ -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.