From 9f3874d4549b648f54fb1274cd7ff4505491e6db Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Sat, 16 Aug 2025 21:55:36 +0200 Subject: Makefile: Add logs for tests and move to assert This provides a better log system that more clearly states what went wrong in the test files. --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b900387..5edae85 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,14 @@ clean: $(TEST_FILES): $(TARGET) $(TEST_SOURCES) $(HEADERS) @printf "Running %-40s%s " '`$@`' @$(CC) $(CFLAGS) -o $@ $(addsuffix .c, $@) $(OBJ) - @if ./$@ ; then printf "PASS\n";else printf "FAIL: exit value: %d\n" $$?; fi + @result=$$(./$@ 2>&1); \ + ret=$$?; \ + printf "Exit value: %s\n%s" "$$ret" "$$result" >$@.log; \ + if test $$ret -eq 0 ; then \ + printf "\e[0;32mPASS\e[0m\n";\ + else\ + printf "\e[0;31mFAIL\e[0m\n";\ + fi check: test test: $(TEST_FILES) -- cgit v1.2.3