From f0746c904f8d2bd30291395d3b8807aa51c6027b Mon Sep 17 00:00:00 2001 From: Yukti <73362292+yuktea@users.noreply.github.com> Date: Fri, 10 Jun 2022 21:55:06 +0530 Subject: [PATCH] build: Add make target to run a single test (#6875) --- Makefile | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 195f1bb366f62..5f7ba8944c249 100644 --- a/Makefile +++ b/Makefile @@ -153,7 +153,7 @@ import_sample_data: import_more_sample_data: @echo "🥫 Importing sample data (~2000 products) into MongoDB …" - ${DOCKER_COMPOSE} run --rm backend bash /opt/product-opener/scripts/import_more_sample_data.sh + ${DOCKER_COMPOSE} run --rm backend bash /opt/product-opener/scripts/import_more_sample_data.sh import_prod_data: @echo "🥫 Importing production data (~2M products) into MongoDB …" @@ -182,12 +182,17 @@ checks: front_build front_lint check_perl_fast tests: build_lang_test - @echo "🥫 Runing tests …" + @echo "🥫 Running tests …" ${DOCKER_COMPOSE_TEST} up -d memcached postgres mongodb ${DOCKER_COMPOSE_TEST} run --rm backend prove -l --jobs ${CPU_COUNT} ${DOCKER_COMPOSE_TEST} stop @echo "🥫 test success" +test-one: guard-test # usage: make test-one test=t/test-file.t + @echo "🥫 Running test: '${test}' …" + ${DOCKER_COMPOSE_TEST} up -d memcached postgres mongodb + ${DOCKER_COMPOSE_TEST} run --rm backend perl ${test} + # check perl compiles, (pattern rule) / but only for newer files %.pm %.pl: _FORCE if [ -f $@ ]; then perl -c -CS -Ilib $@; else true; fi @@ -255,3 +260,13 @@ clean_folders: ( rm -f logs/* logs/apache2/* logs/nginx/* || true ) clean: goodbye hdown prune prune_cache clean_folders + +#-----------# +# Utilities # +#-----------# + +guard-%: # guard clause for targets that require an environment variable (usually used as an argument) + @ if [ "${${*}}" = "" ]; then \ + echo "Environment variable '$*' is not set"; \ + exit 1; \ + fi;