Verified Commit 70aad50f authored by Jelle van der Waa's avatar Jelle van der Waa 🚧
Browse files

Allows bats arguments to be passed to tests

Useful to specify a specific test to run during development/debugging.
parent ce6d77c9
IMAGE:=dbscripts/test IMAGE:=dbscripts/test
RUN_OPTIONS:=--rm --network=none -v $(PWD):/dbscripts:ro --tmpfs=/tmp:exec -w /dbscripts/test RUN_OPTIONS:=--rm --network=none -v $(PWD):/dbscripts:ro --tmpfs=/tmp:exec -w /dbscripts/test
CASES ?= cases CASES ?= cases
BATS_ARGS ?=
DOCKER ?= docker DOCKER ?= docker
test-image: test-image:
$(DOCKER) build --pull -t $(IMAGE) test $(DOCKER) build --pull -t $(IMAGE) test
test: test-image test: test-image
$(DOCKER) run $(RUN_OPTIONS) $(IMAGE) make CASES=$(CASES) test $(DOCKER) run $(RUN_OPTIONS) $(IMAGE) make CASES=$(CASES) BATS_ARGS="$(BATS_ARGS)" test
test-coverage: test-image test-coverage: test-image
rm -rf ${PWD}/coverage rm -rf ${PWD}/coverage
......
...@@ -62,6 +62,12 @@ issuing `systemctl start docker`. ...@@ -62,6 +62,12 @@ issuing `systemctl start docker`.
* The test suite can now be run with `make test`. * The test suite can now be run with `make test`.
* A coverage report can be generated with `make test-coverage`. Open `coverage/index.html` in your web browser to inspect the results. * A coverage report can be generated with `make test-coverage`. Open `coverage/index.html` in your web browser to inspect the results.
Bats arguments or specific test can be run by providing `CASES` and `BATS_ARGS`:
```
make test DOCKER=podman CASES=cases/db-update.bats BATS_ARGS='-f Wrong'
```
## License ## License
For a long time, dbscripts didn't have an explicit license. Currently it is For a long time, dbscripts didn't have an explicit license. Currently it is
primarily licensed under the GPL-2.0-or-later, but some code is of unknown primarily licensed under the GPL-2.0-or-later, but some code is of unknown
......
CASES ?= cases CASES ?= cases
BATS_ARGS ?=
test: test:
BUILDDIR=/build PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) bats $(CASES) BUILDDIR=/build PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) bats $(BATS_ARGS) $(CASES)
test-coverage: test-coverage:
BUILDDIR=/build PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) kcov \ BUILDDIR=/build PATH=$(CURDIR)/../:$(CURDIR)/../cron-jobs/:$(PATH) kcov \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment