commit 36b41db7f54bacd0c35341375cc930eee8b54b51
parent ca77dfc3d7bc2c82bbebb6d8be0b76ce5ea35894
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Wed, 3 Apr 2024 19:05:24 -0700
Add testing system
It's a simple make(1) target which compiles and runs all the tests
listed in the tests variable. This is for a future commit, and there
are currently no tests.
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -13,6 +13,8 @@ src = ${hdrsrc} ${pages}
hdr = ${hdrsrc:.c=.h} util.h pages/util.h pages/pages.h config.h
obj = ${src:.c=.o}
+tests =
+
all: ${name}
.c.o:
@@ -25,6 +27,7 @@ ${name}: ${name}.o ${obj}
clean:
rm -f ${name} ${name}.o ${obj}
+ rm -f ${tests}
install: ${name}
mkdir -p ${prefix} ${datadir}
@@ -45,5 +48,13 @@ uninstall:
rm -rf ${datadir}/frags
rm -f ${prefix}/${name}
-.PHONY: all clean install uninstall install-run-pre install-run-post install-run
+${tests}: ${tests:=.c} ${obj}
+ ${cc} ${cflags} -I. -o $@ $@.c ${obj} ${lddflags}
+
+test: ${tests}
+ for test in ${tests}; do \
+ if $$test; then echo $$test; else echo $$test FAILURE; fi ;\
+ done
+
+.PHONY: all clean install uninstall install-run-pre install-run-post install-run test
.SUFFIX: .c .o