Skip to content

Commit 13ca277

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`. Note that the test script uses the deprecated `suite` hook to build the test suite from the command-line arguments, if there are any. Upstream `shunit2` already does this by default.
1 parent 3adac4f commit 13ca277

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Makefile

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

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

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

2121
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/run

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,17 @@ assertFile() {
315315
assertEquals "$1" "$(cat ${compile_dir}/$2)"
316316
}
317317

318+
# If tests are passed as command-line arguments, only run those tests.
319+
if [ $# -gt 0 ]; then
320+
shunit_funcs_="$*"
321+
set --
322+
323+
suite() {
324+
for shunit_func_ in ${shunit_funcs_}; do
325+
suite_addTest ${shunit_func_}
326+
done
327+
unset shunit_func_
328+
}
329+
fi
330+
318331
source $(pwd)/test/shunit2

0 commit comments

Comments
 (0)