diff options
author | Adam Spiers <stow@adamspiers.org> | 2019-06-28 20:46:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-28 20:46:15 +0100 |
commit | d991dfbbf8abc75d92c235a8e9a27277fe12cb92 (patch) | |
tree | 4b7d01fdd42b9e06290cd2d9793a1051b115b4cc | |
parent | 8acb10e26cabac844846985e81dc3feefed10785 (diff) | |
parent | 5d667c3e71281068d7742f41cdfe13b53fd092d7 (diff) | |
download | stow-d991dfbbf8abc75d92c235a8e9a27277fe12cb92.tar.gz |
Make testing within Docker containers easier (#56)
Make testing within Docker containers easier
-rwxr-xr-x | docker/run-stow-tests.sh | 38 | ||||
-rwxr-xr-x | test-docker.sh | 31 |
2 files changed, 63 insertions, 6 deletions
diff --git a/docker/run-stow-tests.sh b/docker/run-stow-tests.sh index 416594c..121542c 100755 --- a/docker/run-stow-tests.sh +++ b/docker/run-stow-tests.sh @@ -22,11 +22,12 @@ . /usr/local/perlbrew/etc/bashrc # Standard safety protocol -set -euf -o pipefail +set -ef -o pipefail IFS=$'\n\t' -for p_version in $(perlbrew list | sed 's/ //g'); do - perlbrew use $p_version +test_perl_version () { + perl_version="$1" + perlbrew use $perl_version echo $(perl --version) @@ -40,6 +41,33 @@ for p_version in $(perlbrew list | sed 's/ //g'); do make distcheck perl Build.PL && ./Build build && cover -test ./Build distcheck -done +} -make distclean +if [[ -n "$LIST_PERL_VERSIONS" ]]; then + echo "Listing Perl versions available from perlbrew ..." + perlbrew list +elif [[ -z "$PERL_VERSION" ]]; then + echo "Testing all versions ..." + for perl_version in $(perlbrew list | sed 's/ //g'); do + test_perl_version $perl_version + done + make distclean +else + echo "Testing with Perl $PERL_VERSION" + # Test a specific version requested via $PERL_VERSION environment + # variable. Make sure set -e doesn't cause us to bail on failure + # before we start an interactive shell. + test_perl_version $PERL_VERSION || : + # N.B. Don't distclean since we probably want to debug this Perl + # version interactively. + cat <<EOF +To run a specific test, type something like: + +perl -Ilib -Ibin -It t/cli_options.t + +Code can be edited on the host and will immediately take effect inside +this container. + +EOF + bash +fi diff --git a/test-docker.sh b/test-docker.sh index f10456d..4bd446b 100755 --- a/test-docker.sh +++ b/test-docker.sh @@ -2,7 +2,36 @@ # Test Stow across multiple Perl versions, by executing the # Docker image built via build-docker.sh. +# +# Usage: ./test-docker.sh [list | PERL_VERSION] +# +# If the first argument is 'list', list available Perl versions. +# If the first argument is a Perl version, test just that version interactively. +# If no arguments are given test all available Perl versions non-interactively. version=$( tools/get-version ) -docker run --rm -it -v $(pwd):$(pwd) -w $(pwd) stowtest:$version +if [ -z "$1" ]; then + # Normal non-interactive run + docker run --rm -it \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + stowtest:$version +elif [ "$1" == list ]; then + # List available Perl versions + docker run --rm -it \ + -v $(pwd):$(pwd) \ + -v $(pwd)/docker/run-stow-tests.sh:/run-stow-tests.sh \ + -w $(pwd) \ + -e LIST_PERL_VERSIONS=1 \ + stowtest:$version +else + # Interactive run for testing / debugging a particular version + perl_version="$1" + docker run --rm -it \ + -v $(pwd):$(pwd) \ + -v $(pwd)/docker/run-stow-tests.sh:/run-stow-tests.sh \ + -w $(pwd) \ + -e PERL_VERSION=$perl_version \ + stowtest:$version +fi |