From 3c48d87688bb38167795f2e247df45c9dec07b76 Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Sat, 30 Nov 2019 14:10:37 +0100
Subject: [PATCH] add 'make test' target

---
 Makefile | 13 ++++++++++---
 t/.keep  |  0
 2 files changed, 10 insertions(+), 3 deletions(-)
 create mode 100644 t/.keep

diff --git a/Makefile b/Makefile
index d5e8e3e..7322086 100644
--- a/Makefile
+++ b/Makefile
@@ -4,11 +4,18 @@ CFLAGS += -Wall -Werror
 # i have, for instance, symlinks:
 # hammer@ -> ../hammer/src
 # lib@ -> ../hammer/build/opt/src
-CFLAGS += -I.
-LDFLAGS += -L./lib
+HAMMER_INCLUDE = .
+HAMMER_LIB = ./lib
+CFLAGS += -I$(HAMMER_INCLUDE)
+LDFLAGS += -L$(HAMMER_LIB)
 
+.PHONY: all test
 all: pdf
-.PHONY: all
+
+test: pdf
+	LD_LIBRARY_PATH=$(HAMMER_LIB) sh -c \
+	'for x in t/*.pdf; do ./pdf "$$x" >/dev/null && echo OK: "$$x"; done'
+	@true
 
 pdf: pdf.c
 	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $> -lhammer
diff --git a/t/.keep b/t/.keep
new file mode 100644
index 0000000..e69de29
-- 
GitLab