From 4326d984349ceef8551c470386f39c43517dd6ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Thu, 28 Feb 2019 00:07:23 +0100 Subject: [PATCH] testsuite: build the tools in parallel --- Makefile | 32 +++++++++++++++++++++++--------- nimbus.nimble | 13 ------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index b6fd8baaa..15470348c 100644 --- a/Makefile +++ b/Makefile @@ -81,17 +81,27 @@ else MD5SUM := md5sum endif -.PHONY: all premix persist debug dumper hunter regress deps github-ssh build-nim update status ntags ctags nimbus test clean mrproper fetch-dlls beacon_node validator_keygen clean_eth2_network_simulation_files eth2_network_simulation test-libp2p-daemon +# guess who does parsing before variable expansion +COMMA := , +EMPTY := +SPACE := $(EMPTY) $(EMPTY) +# debugging tools + testing tools +TOOLS := premix persist debug dumper hunter regress tracerTestGen persistBlockTestGen +# comma-separated values for the "clean" target +TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS)) + +.PHONY: all $(TOOLS) deps github-ssh build-nim update status ntags ctags nimbus testsuite test clean mrproper fetch-dlls beacon_node validator_keygen clean_eth2_network_simulation_files eth2_network_simulation test-libp2p-daemon # default target, because it's the first one that doesn't start with '.' -all: premix persist debug dumper hunter regress nimbus +all: $(TOOLS) nimbus -# debugging tools -premix persist debug dumper hunter regress: | build deps - $(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ premix/$@.nim && \ +# builds the tools, wherever they are +$(TOOLS): | build deps + for D in premix tests; do [ -e "$${D}/$@.nim" ] && TOOL_DIR="$${D}" && break; done && \ + $(ENV_SCRIPT) nim c $(NIM_PARAMS) -o:build/$@ "$${TOOL_DIR}/$@.nim" && \ echo -e "\nThe binary is in './build/$@'.\n" -#- a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated +# a phony target, because teaching `make` how to do conditional recompilation of Nim projects is too complicated nimbus: | build deps $(ENV_SCRIPT) nim nimbus $(NIM_PARAMS) nimbus.nims && \ echo -e "\nThe binary is in './build/nimbus'.\n" @@ -121,10 +131,14 @@ $(NIMBLE_DIR): | $(NIM_BINARY) nimbus.nims: ln -s nimbus.nimble $@ -# builds and runs all tests -test: | build deps +# builds and runs the testsuite +testsuite: | build deps $(ENV_SCRIPT) nim test $(NIM_PARAMS) nimbus.nims +#- builds the tools, to make sure they're still compilable +#- builds and runs all tests +test: | $(TOOLS) testsuite + # primitive reproducibility test test-reproducibility: + [ -e build/nimbus ] || $(MAKE) V=0 nimbus; \ @@ -137,7 +151,7 @@ test-reproducibility: # usual cleaning clean: - rm -rf build/{nimbus,premix,persist,debug,dumper,hunter,regress,all_tests,beacon_node,validator_keygen,*.exe} vendor/go/bin \ + rm -rf build/{nimbus,$(TOOLS_CSV),all_tests,test_rpc,beacon_node,validator_keygen,*.exe} vendor/go/bin \ $(NIMBLE_DIR) $(NIM_BINARY) $(NIM_DIR)/nimcache nimcache # dangerous cleaning, because you may have not-yet-pushed branches and commits in those vendor repos you're about to delete diff --git a/nimbus.nimble b/nimbus.nimble index 0c2e9be4e..a485d47dd 100644 --- a/nimbus.nimble +++ b/nimbus.nimble @@ -32,19 +32,6 @@ proc test(name: string, lang = "c") = buildBinary name, "tests/", "-r -d:chronicles_log_level=ERROR" task test, "Run tests": - # debugging tools don't have tests yet, but they should be compilable - for binary in [ - "premix/premix", - "premix/persist", - "premix/debug", - "premix/dumper", - "premix/hunter", - "premix/regress", - "tests/tracerTestGen", - "tests/persistBlockTestGen", - ]: - exec "nim c --verbosity:0 --hints:off --warnings:off " & binary - rmFile binary test "all_tests" test "test_rpc"