Skip to content

Commit a887282

Browse files
committed
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
1 parent 494cc76 commit a887282

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ check:
1010

1111
test-cedar-14:
1212
@echo "Running tests in docker (cedar-14)..."
13-
@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;'
13+
@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;'
1414
@echo ""
1515

1616
test-heroku-16:
1717
@echo "Running tests in docker (heroku-16)..."
18-
@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;'
18+
@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;'
1919
@echo ""
2020

2121
test-heroku-18:
2222
@echo "Running tests in docker (heroku-18)..."
23-
@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;'
23+
@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;'
2424
@echo ""
2525

2626
buildenv-heroku-16:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ make test-heroku-18
8383
make test-heroku-16
8484
```
8585

86+
You can also specify which tests to run:
87+
88+
```
89+
make test TESTS="testPython3_7 testGitEgg"
90+
```
91+
8692
The tests are run via the vendored
8793
[shunit2](https://github.com/kward/shunit2)
8894
test framework.

test/utils

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,13 @@ release() {
264264
assertFile() {
265265
assertEquals "$1" "$(cat ${compile_dir}/$2)"
266266
}
267+
268+
# If TESTS is present in the environment, only run the specified tests.
269+
if [ -n "$TESTS" ]; then
270+
suite() {
271+
for shunit_func_ in ${TESTS}; do
272+
suite_addTest ${shunit_func_}
273+
done
274+
unset shunit_func_
275+
}
276+
fi

0 commit comments

Comments
 (0)