From 17bea385ad6c13995f261be60bd1c48b8d1a35d6 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 21 Aug 2019 20:58:00 +0200 Subject: [PATCH 1/5] Switch Heroku account used by Travis CI Change the HEROKU_API_KEY and HEROKU_API_USER environment variables used by Travis CI. The encrypted values were generated using the following commands: heroku authorizations:create --description "For Travis" travis login --com travis encrypt HEROKU_API_KEY= --add --com travis encrypt HEROKU_API_USER= --add --com --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 703f4a125..51753c1df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,5 +38,5 @@ env: - IS_RUNNING_ON_CI=true - HATCHET_APP_LIMIT=5 - HATCHET_DEPLOY_STRATEGY=git - - secure: yjtlPE5FbVxTKnjUy/tZUBgSEf4qADD3QOxtgziuid73S0U/1IEXlMGFULsQzIjtlHKmHeywZqpVVEpthIH4RuT7uoX1Pb7SSM/g0T8fT3VoEFbFK1uYl0oZQbUS4Klxv9tPiumj8if3m6ULEGIz1X0wZcMOC0tMLwVCnwmap0E= - - secure: ZeFTHWwnpIKE9nAqs88ocmiQh7bKce84lilGm5J23nf3N6V4wNyLwqlkvsM008WGBCaOg9AUx7ZunasT0ANsR5gLP3eV2UUg7ILdRgV2Gy13eNRFheC4PHdN92RqQ3aKoqlIv2K999xlhVjod0NzhkQQXB6PddfQINbuU7ks6As= + - secure: aICPFKFCmu+OWynYd0QRJVU37Rw3GTCxy3PePj5DSDx3/2S2i0BXXLhn/LECdMY98h24O0xL8k860+gy646Mjq8Cpaf16BUNJhWH5HWS50paymREhnrYd/twSh0i6M2dnlbCjXDHWc8n+64/vu4FmS1UhLw2nQBMCrcIRcxHBpPPHIy3F4pctGBb1LEaExmA3JQRDUoX6uzgt/68gjMDPfvUwM5lzBwRLOdpUwNOvIlYxKioxcqjhMAFuHNo3na50QzPlNE2dqt84iDRj4N7/7v6NzWhG/9O1TxkcVCjn8ZhRI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3e32d659f8ff10de11 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 25 Sep 2019 16:35:32 +0200 Subject: [PATCH 2/5] Use a separate CI job per stack Run the tests in a separate CI job per test suite and stack. Testing on all stacks in a single job exceeds Travis time limits. --- .travis.yml | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51753c1df..b172e849e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,12 +9,8 @@ before_script: - bundle exec hatchet ci:setup script: - - docker build --pull --tag travis-build-cedar-14 --file $(pwd)/builds/cedar-14.Dockerfile . - - docker run --rm -e "STACK=cedar-14" -e "USE_STAGING_BINARIES=$USE_STAGING_BINARIES" travis-build-cedar-14 bash $TESTFOLDER - - docker build --pull --tag travis-build-heroku-16 --file $(pwd)/builds/heroku-16.Dockerfile . - - docker run --rm -e "STACK=heroku-16" -e "USE_STAGING_BINARIES=$USE_STAGING_BINARIES" travis-build-heroku-16 bash $TESTFOLDER - - docker build --pull --tag travis-build-heroku-18 --file $(pwd)/builds/heroku-18.Dockerfile . - - docker run --rm -e "STACK=heroku-18" -e "USE_STAGING_BINARIES=$USE_STAGING_BINARIES" travis-build-heroku-18 bash $TESTFOLDER + - docker build --pull --tag travis-build-$STACK --file $(pwd)/builds/$STACK.Dockerfile . + - docker run --rm -e "STACK=$STACK" -e "USE_STAGING_BINARIES=$USE_STAGING_BINARIES" travis-build-$STACK bash $TESTFOLDER jobs: include: @@ -27,12 +23,24 @@ jobs: script: "bundle exec rspec" env: matrix: - - TESTFOLDER=test/run-deps - - TESTFOLDER=test/run-deps USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging - - TESTFOLDER=test/run-versions - - TESTFOLDER=test/run-versions USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging - - TESTFOLDER=test/run-features - - TESTFOLDER=test/run-features USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=cedar-14 TESTFOLDER=test/run-deps + - STACK=cedar-14 TESTFOLDER=test/run-deps USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=cedar-14 TESTFOLDER=test/run-versions + - STACK=cedar-14 TESTFOLDER=test/run-versions USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=cedar-14 TESTFOLDER=test/run-features + - STACK=cedar-14 TESTFOLDER=test/run-features USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=heroku-16 TESTFOLDER=test/run-deps + - STACK=heroku-16 TESTFOLDER=test/run-deps USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=heroku-16 TESTFOLDER=test/run-versions + - STACK=heroku-16 TESTFOLDER=test/run-versions USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=heroku-16 TESTFOLDER=test/run-features + - STACK=heroku-16 TESTFOLDER=test/run-features USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=heroku-18 TESTFOLDER=test/run-deps + - STACK=heroku-18 TESTFOLDER=test/run-deps USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=heroku-18 TESTFOLDER=test/run-versions + - STACK=heroku-18 TESTFOLDER=test/run-versions USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging + - STACK=heroku-18 TESTFOLDER=test/run-features + - STACK=heroku-18 TESTFOLDER=test/run-features USE_STAGING_BINARIES=https://lang-python.s3.amazonaws.com/staging global: - HATCHET_RETRIES=3 - IS_RUNNING_ON_CI=true From a887282c6979f4b099bc3c04d07266df0a77e42e Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Fri, 23 Aug 2019 10:36:09 +0200 Subject: [PATCH 3/5] Allow running specific tests by passing TESTS Make it possible to specify individual tests to run, to facilitate debugging. Running the entire test suite every time can take quite long. Tests can be specified by passing the TESTS variable to `make test`. If TESTS is non-empty, the test script defines the `suite` hook to build the test suite using `suite_addTest` with each specified test function. If TESTS is unset or empty, shUnit2's default behaviour is to run all functions beginning with the word `test`. See https://github.com/kward/shunit2#-suites --- Makefile | 6 +++--- README.md | 6 ++++++ test/utils | 10 ++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bf7c5c7cc..e3da5678f 100644 --- a/Makefile +++ b/Makefile @@ -10,17 +10,17 @@ check: test-cedar-14: @echo "Running tests in docker (cedar-14)..." - @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=cedar-14" heroku/cedar:14 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;' + @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=cedar-14" -e TESTS=$(TESTS) heroku/cedar:14 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;' @echo "" test-heroku-16: @echo "Running tests in docker (heroku-16)..." - @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-16" heroku/heroku:16-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;' + @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-16" -e TESTS=$(TESTS) heroku/heroku:16-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;' @echo "" test-heroku-18: @echo "Running tests in docker (heroku-18)..." - @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-18" heroku/heroku:18-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;' + @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-18" -e TESTS=$(TESTS) heroku/heroku:18-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run-deps; test/run-features; test/run-versions;' @echo "" buildenv-heroku-16: diff --git a/README.md b/README.md index e3ea62a25..4a6fdb8d1 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ make test-heroku-18 make test-heroku-16 ``` +You can also specify which tests to run: + +``` +make test TESTS="testPython3_7 testGitEgg" +``` + The tests are run via the vendored [shunit2](https://github.com/kward/shunit2) test framework. diff --git a/test/utils b/test/utils index ff22b7400..6b8614750 100644 --- a/test/utils +++ b/test/utils @@ -264,3 +264,13 @@ release() { assertFile() { assertEquals "$1" "$(cat ${compile_dir}/$2)" } + +# If TESTS is present in the environment, only run the specified tests. +if [ -n "$TESTS" ]; then + suite() { + for shunit_func_ in ${TESTS}; do + suite_addTest ${shunit_func_} + done + unset shunit_func_ + } +fi From cc735a6628f65b3fe77044cbeb9a8f4b30bdeb65 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 25 Sep 2019 14:32:32 +0200 Subject: [PATCH 4/5] Skip undefined functions when processing TESTS Do not attempt to invoke test functions specified via the TESTS environment variable if they are not defined. The Makefile invokes multiple test scripts and each test function is only defined in one of them. --- test/utils | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/utils b/test/utils index 6b8614750..663df14f1 100644 --- a/test/utils +++ b/test/utils @@ -269,7 +269,9 @@ assertFile() { if [ -n "$TESTS" ]; then suite() { for shunit_func_ in ${TESTS}; do - suite_addTest ${shunit_func_} + if declare -F ${shunit_func_} > /dev/null; then + suite_addTest ${shunit_func_} + fi done unset shunit_func_ } From 99d0e51309afeb5bf91edab3bb9a5f5155e9bfe8 Mon Sep 17 00:00:00 2001 From: Claudio Jolowicz Date: Wed, 25 Sep 2019 14:49:14 +0200 Subject: [PATCH 5/5] Do not run all tests when no tests match TESTS Define a noop test function when TESTS is passed and no function in the test script matches the contents of TESTS. The noop function merely prints a line notifying the user that the tests were skipped. This happens because tests were split up into multiple test scripts, but the Makefile passes TESTS to all of them. When the `suite` hook does not invoke `suite_addTest`, shunit2 falls back to running all defined tests. --- test/utils | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/utils b/test/utils index 663df14f1..e2822c311 100644 --- a/test/utils +++ b/test/utils @@ -274,5 +274,12 @@ if [ -n "$TESTS" ]; then fi done unset shunit_func_ + + if [ -z "$__shunit_suite" ]; then + testNoop() { + echo "Skipping tests because they do not match TESTS." + } + suite_addTest testNoop + fi } fi