@@ -55,6 +55,7 @@ DOCKER_COMPOSE=docker compose --env-file=${ENV_FILE} ${LOAD_EXTRA_ENV_FILE}
5555DOCKER_COMPOSE_TEST=WEB_RESOURCES_PATH =./web-default ROBOTOFF_URL="http://backend:8881/" GOOGLE_CLOUD_VISION_API_URL="http://backend:8881/" COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}_test PO_COMMON_PREFIX=test_ MONGO_EXPOSE_PORT=27027 docker compose --env-file=${ENV_FILE}
5656# Enable Redis only for integration tests
5757DOCKER_COMPOSE_INT_TEST=REDIS_URL ="redis:6379" ${DOCKER_COMPOSE_TEST}
58+ TEST_CMD ?= yath test -PProductOpener::LoadData
5859
5960.DEFAULT_GOAL := usage
6061
@@ -262,7 +263,7 @@ tests: build_taxonomies_test build_lang_test unit_test integration_test
262263unit_test : create_folders
263264 @echo " 🥫 Running unit tests …"
264265 ${DOCKER_COMPOSE_TEST} up -d memcached postgres mongodb
265- ${DOCKER_COMPOSE_TEST} run ${COVER_OPTS} -T --rm backend prove -l --jobs ${CPU_COUNT} -r tests/unit
266+ ${DOCKER_COMPOSE_TEST} run ${COVER_OPTS} -e PO_EAGER_LOAD_DATA=1 - T --rm backend yath test --job-count= ${CPU_COUNT} -PProductOpener::LoadData tests/unit
266267 ${DOCKER_COMPOSE_TEST} stop
267268 @echo " 🥫 unit tests success"
268269
@@ -273,7 +274,7 @@ integration_test: create_folders
273274# this is the place where variables are important
274275 ${DOCKER_COMPOSE_INT_TEST} up -d memcached postgres mongodb backend dynamicfront incron minion redis
275276# note: we need the -T option for ci (non tty environment)
276- ${DOCKER_COMPOSE_INT_TEST} exec ${COVER_OPTS} -T backend prove -l -r tests/integration
277+ ${DOCKER_COMPOSE_INT_TEST} exec ${COVER_OPTS} -e PO_EAGER_LOAD_DATA=1 -T backend yath -PProductOpener::LoadData tests/integration
277278 ${DOCKER_COMPOSE_INT_TEST} stop
278279 @echo "🥫 integration tests success"
279280
@@ -283,19 +284,21 @@ test-stop:
283284 ${DOCKER_COMPOSE_TEST} stop
284285
285286# usage: make test-unit test=test-name.t
286- # you can add args= to pass options, like args="-d" to debug
287+ # you can use TEST_CMD to change test command, like TEST_CMD="perl -d" to debug a test
288+ # you can also add args= to pass more options to your test command
287289test-unit : guard-test create_folders
288290 @echo " 🥫 Running test: 'tests/unit/${test} ' …"
289291 ${DOCKER_COMPOSE_TEST} up -d memcached postgres mongodb
290- ${DOCKER_COMPOSE_TEST} run --rm backend perl ${args} tests/unit/${test}
292+ ${DOCKER_COMPOSE_TEST} run --rm -e PO_EAGER_LOAD_DATA=1 backend ${TEST_CMD} ${args} tests/unit/${test}
291293
292294# usage: make test-int test=test-name.t
293- # to update expected results: make test-int test="test-name.t --update-expected-results"
294- # you can add args= to pass options, like args="-d" to debug
295+ # to update expected results: make test-int test="test-name.t :: --update-expected-results"
296+ # you can use TEST_CMD to change test command, like TEST_CMD="perl -d" to debug a test
297+ # you can also add args= to pass more options to your test command
295298test-int : guard-test create_folders
296299 @echo " 🥫 Running test: 'tests/integration/${test} ' …"
297300 ${DOCKER_COMPOSE_INT_TEST} up -d memcached postgres mongodb backend dynamicfront incron minion redis
298- ${DOCKER_COMPOSE_INT_TEST} exec backend perl ${args} tests/integration/${test}
301+ ${DOCKER_COMPOSE_INT_TEST} exec -e PO_EAGER_LOAD_DATA=1 backend ${TEST_CMD} ${args} tests/integration/${test}
299302# better shutdown, for if we do a modification of the code, we need a restart
300303 ${DOCKER_COMPOSE_INT_TEST} stop backend
301304
@@ -378,17 +381,19 @@ check_critic:
378381 @echo " 🥫 Checking with perlcritic"
379382 test -z " ${TO_CHECK} " || ${DOCKER_COMPOSE} run --rm --no-deps backend perlcritic ${TO_CHECK}
380383
381- TAXONOMIES_TO_CHECK := $(shell [ -x "`which git 2>/dev/null`" ] && git diff origin/main --name-only | grep 'taxonomies* / * \.txt$$' | grep -v '\.result.txt' | xargs ls -d 2>/dev/null | grep -v "^.$$")
384+ TAXONOMIES_TO_CHECK := $(shell [ -x "`which git 2>/dev/null`" ] && git diff origin/main --name-only | grep 'taxonomies. * /. * \.txt$$' | grep -v '\.result.txt' | xargs ls -d 2>/dev/null | grep -v "^.$$")
382385
386+ # TODO remove --no-sort as soon as we have sorted taxonomies
383387check_taxonomies :
384388 @echo " 🥫 Checking taxonomies"
385389 test -z " ${TAXONOMIES_TO_CHECK} " || \
386- ${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/sort_each_taxonomy_entry.sh --check ${TAXONOMIES_TO_CHECK}
390+ ${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/lint_taxonomy.pl --verbose -- check --no-sort ${TAXONOMIES_TO_CHECK}
387391
392+ # TODO remove --no-sort as soon as we have sorted taxonomies
388393lint_taxonomies :
389394 @echo " 🥫 Linting taxonomies"
390395 test -z " ${TAXONOMIES_TO_CHECK} " || \
391- ${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/sort_each_taxonomy_entry.sh ${TAXONOMIES_TO_CHECK}
396+ ${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/lint_taxonomy.pl --verbose --no-sort ${TAXONOMIES_TO_CHECK}
392397
393398
394399check_openapi_v2 :
@@ -412,7 +417,11 @@ build_taxonomies: create_folders
412417 # GITHUB_TOKEN might be empty, but if it's a valid token it enables pushing taxonomies to build cache repository
413418 ${DOCKER_COMPOSE} run --no-deps --rm -e GITHUB_TOKEN=${GITHUB_TOKEN} backend /opt/product-opener/scripts/taxonomies/build_tags_taxonomy.pl ${name}
414419
415- rebuild_taxonomies : build_taxonomies
420+ # a version where we force building without using cache
421+ # use it when you are developing in Tags.pm and want to iterate
422+ # at the end, change the $BUILD_TAGS_VERSION in Tags.pm
423+ rebuild_taxonomies :
424+ ${DOCKER_COMPOSE} run --no-deps --rm -e TAXONOMY_NO_GET_FROM_CACHE=1 backend /opt/product-opener/scripts/taxonomies/build_tags_taxonomy.pl ${name}
416425
417426build_taxonomies_test : create_folders
418427 @echo " 🥫 build taxonomies"
0 commit comments