From a0f8cb82977822d4e552f40bf5bb2c034db0f40e Mon Sep 17 00:00:00 2001 From: Darshan K <35736874+darshankabariya@users.noreply.github.com> Date: Tue, 8 Jul 2025 18:25:36 +0530 Subject: [PATCH] fix: make test configuration (#3480) --- .github/workflows/ci.yml | 5 +++-- Makefile | 21 +++++++++++++++++---- tests/all_tests_waku.nim | 6 ++---- waku.nimble | 9 ++++++--- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41f5500a0..30708ead9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,12 +119,13 @@ jobs: sudo docker run --rm -d -e POSTGRES_PASSWORD=test123 -p 5432:5432 postgres:15.4-alpine3.18 postgres_enabled=1 fi - + export MAKEFLAGS="-j1" export NIMFLAGS="--colors:off -d:chronicles_colors:none" export USE_LIBBACKTRACE=0 - make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 POSTGRES=$postgres_enabled test testwakunode2 + make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 POSTGRES=$postgres_enabled test + make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 POSTGRES=$postgres_enabled testwakunode2 build-docker-image: needs: changes diff --git a/Makefile b/Makefile index 555a20472..e41b4207a 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,19 @@ endif # default target, because it's the first one that doesn't start with '.' all: | wakunode2 example2 chat2 chat2bridge libwaku -test: | testcommon testwaku +TEST_FILE := $(word 2,$(MAKECMDGOALS)) +TEST_NAME := $(wordlist 3,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + +test: +ifeq ($(strip $(TEST_FILE)),) + $(MAKE) testcommon + $(MAKE) testwaku +else + $(MAKE) compile-test $(TEST_FILE) $(TEST_NAME) +endif +# this prevents make from erroring on unknown targets like "Index" +%: + @true waku.nims: ln -s waku.nimble $@ @@ -244,9 +256,10 @@ build/%: | build deps librln echo -e $(BUILD_MSG) "build/$*" && \ $(ENV_SCRIPT) nim buildone $(NIM_PARAMS) waku.nims $* -test/%: | build deps librln - echo -e $(BUILD_MSG) "test/$*" && \ - $(ENV_SCRIPT) nim testone $(NIM_PARAMS) waku.nims $* +compile-test: | build deps librln + echo -e $(BUILD_MSG) "$(TEST_FILE)" && \ + $(ENV_SCRIPT) nim buildTest $(NIM_PARAMS) waku.nims $(TEST_FILE) && \ + $(ENV_SCRIPT) nim execTest $(NIM_PARAMS) waku.nims $(TEST_FILE) "$(TEST_NAME)" ################ ## Waku tools ## diff --git a/tests/all_tests_waku.nim b/tests/all_tests_waku.nim index 98ea0e36f..aac92863a 100644 --- a/tests/all_tests_waku.nim +++ b/tests/all_tests_waku.nim @@ -38,7 +38,8 @@ when os == "Linux" and #./waku_archive_legacy/test_driver_postgres_query, #./waku_archive_legacy/test_driver_postgres, ./factory/test_node_factory, - ./wakunode_rest/test_rest_store + ./wakunode_rest/test_rest_store, + ./wakunode_rest/test_all # Waku store test suite import @@ -91,9 +92,6 @@ import # Waku Keystore test suite import ./test_waku_keystore_keyfile, ./test_waku_keystore -## Wakunode Rest API test suite -import ./wakunode_rest/test_all - import ./waku_rln_relay/test_all # Node Factory diff --git a/waku.nimble b/waku.nimble index 3790b0333..3d2d7de88 100644 --- a/waku.nimble +++ b/waku.nimble @@ -161,10 +161,13 @@ task buildone, "Build custom target": let filepath = paramStr(paramCount()) discard buildModule filepath -task testone, "Test custom target": +task buildTest, "Test custom target": let filepath = paramStr(paramCount()) - if buildModule(filepath): - exec "build/" & filepath & ".bin" + discard buildModule(filepath) + +task execTest, "Run test": + let filepath = paramStr(paramCount() - 1) + exec "build/" & filepath & ".bin" & " test \"" & paramStr(paramCount()) & "\"" ### C Bindings let chroniclesParams =