From 823898039537782a2d3f8db220d6754579087946 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 28 Oct 2021 17:24:43 +0100 Subject: [PATCH] [TOOLS] Allow specifying a list of filters when running tests with `make`. When running `make test foobar` only the test `foobar` is executed (read the documentation for `phpunit --filter`) --- Makefile | 7 ++++++- docker/tooling/coverage.sh | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 839e1be73e..60acf29f07 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,11 @@ + DIR=$(strip $(notdir $(CURDIR))) # Seems a bit hack-ish, but `basename` works differently translate-container-name = $$(if docker container inspect $(1) > /dev/null 2>&1; then echo $(1); else echo $(1) | sed 'y/_/-/' ; fi) +args = `arg="$(filter-out $@,$(MAKECMDGOALS))" && echo $${arg:-${1}}` + +%: + @: .PHONY: @if ! docker info > /dev/null; then echo "Docker does not seem to be running"; exit 1; fi @@ -30,7 +35,7 @@ tooling-docker: .PHONY @cd docker/tooling && docker-compose up -d > /dev/null 2>&1 test: tooling-docker - docker exec $(call translate-container-name,tooling_php_1) /var/tooling/coverage.sh + docker exec $(call translate-container-name,tooling_php_1) /var/tooling/coverage.sh $(call args,defaultstring) doc-check: bin/php-doc-check src components plugins diff --git a/docker/tooling/coverage.sh b/docker/tooling/coverage.sh index 7a64f29f69..aa76c02737 100755 --- a/docker/tooling/coverage.sh +++ b/docker/tooling/coverage.sh @@ -2,6 +2,14 @@ cd /var/www/social || exit 1 +printf "Cleaning Redis cache: " && echo "FLUSHALL" | nc redis 6379 yes yes | php bin/console doctrine:fixtures:load || exit 1 -runuser -u www-data -- vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report +echo yooo + +if [ "$#" -eq 0 ]; then + runuser -u www-data -- vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report +else + echo "Running with filter" + runuser -u www-data -- vendor/bin/simple-phpunit -vvv --coverage-html .test_coverage_report --filter "$*" +fi