From ebe15f684f2db046e3f16f347b3956e14313c31c Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Fri, 19 Sep 2025 20:09:09 +0200 Subject: [PATCH] fixup! tests: further silence outputs --- Makefile | 27 ++++++++++++++++++++++++--- tests/gen-tests-makefile.sh | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 937acb668..7b65caaea 100644 --- a/Makefile +++ b/Makefile @@ -936,13 +936,33 @@ SH_ABC_TEST_DIRS += tests/alumacc seed-tests: $(SH_TEST_DIRS:%=seed-tests/%) .PHONY: seed-tests/% seed-tests/%: %/run-test.sh $(TARGETS) $(EXTRA_TARGETS) - +cd $* && /usr/bin/env time -f "PASS $* in %e seconds" sh -c 'bash run-test.sh $(SEEDOPT) 2>/dev/null >/dev/null' + @echo "cd $* && bash run-test.sh $(SEEDOPT)" + @cd $* && \ + TIME_OUTPUT=$$(/usr/bin/env time -f "%e seconds" sh -c 'bash run-test.sh $(SEEDOPT) 2>/dev/null >/dev/null; exit $$?' 2>&1); \ + EXIT_CODE=$$?; \ + CLEAN_TIME=$$(echo "$$TIME_OUTPUT" | tail -n1); \ + if [ $$EXIT_CODE -eq 0 ]; then \ + MSG=". PASS $* $$CLEAN_TIME"; \ + else \ + MSG="X FAIL $* $$CLEAN_TIME"; \ + fi; \ + echo $$MSG # abcopt-tests/ is a dummy string, not a directory .PHONY: abcopt-tests abcopt-tests: $(SH_ABC_TEST_DIRS:%=abcopt-tests/%) abcopt-tests/%: %/run-test.sh $(TARGETS) $(EXTRA_TARGETS) - +cd $* && /usr/bin/env time -f "PASS $* in %e seconds" sh -c 'bash run-test.sh $(ABCOPT) $(SEEDOPT) 2>/dev/null >/dev/null' + @echo "cd $* && bash run-test.sh $(ABCOPT) $(SEEDOPT)" + @cd $* && \ + TIME_OUTPUT=$$(/usr/bin/env time -f "%e seconds" sh -c 'bash run-test.sh $(ABCOPT) $(SEEDOPT) 2>/dev/null >/dev/null; exit $$?' 2>&1); \ + EXIT_CODE=$$?; \ + CLEAN_TIME=$$(echo "$$TIME_OUTPUT" | tail -n1); \ + if [ $$EXIT_CODE -eq 0 ]; then \ + MSG=". PASS $* $$CLEAN_TIME"; \ + else \ + MSG="X FAIL $* $$CLEAN_TIME"; \ + fi; \ + echo $$MSG # makefile-tests/ is a dummy string, not a directory .PHONY: makefile-tests @@ -953,7 +973,8 @@ makefile-tests: $(MK_TEST_DIRS:%=makefile-tests/%) +cd $(dir $*) && bash run-test.sh # this one spawns submake on each makefile-tests/%: %/run-test.mk $(TARGETS) $(EXTRA_TARGETS) - stdbuf -oL -eL $(MAKE) -C $* -f run-test.mk + @echo $(MAKE) -C $* -f run-test.mk + @stdbuf -oL -eL $(MAKE) -C $* -f run-test.mk test: makefile-tests abcopt-tests seed-tests @echo "" diff --git a/tests/gen-tests-makefile.sh b/tests/gen-tests-makefile.sh index 677f39a5d..98b110ea3 100755 --- a/tests/gen-tests-makefile.sh +++ b/tests/gen-tests-makefile.sh @@ -9,7 +9,7 @@ generate_target() { echo "all: $target_name" echo ".PHONY: $target_name" echo "$target_name:" - printf "\t@/usr/bin/env time -f \"PASS $target_name %%e seconds\" sh -c %q\n" "{ $test_command ;} >/dev/null 2>/dev/null" + printf "\t@set -o pipefail; time_output=\$\$(/usr/bin/env time -f \"%%e\" sh -c %q 2>&1 >/dev/null | tail -1); if [ \$\$? -eq 0 ]; then echo \". PASS $target_name \$\$time_output seconds\"; else echo \"X FAIL $target_name \$\$time_output seconds\"; exit 1; fi\n" "$test_command" } # $ generate_ys_test ys_file [yosys_args]