summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rwxr-xr-xtest26
-rw-r--r--tests/bad_ws.mk2
-rw-r--r--tests/cont_of_blank.mk3
-rw-r--r--tests/cont_to_blank.mk3
-rw-r--r--tests/eof_cont.mk3
-rw-r--r--tests/ws_before_comment.mk2
7 files changed, 44 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index f0a9b22..c6fb323 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ HDR =\
arg.h\
common.h
-all: makel
+all: makel check
$(OBJ): $(HDR)
.c.o:
@@ -23,6 +23,9 @@ $(OBJ): $(HDR)
makel: $(OBJ)
$(CC) -o $@ $(OBJ) $(LDFLAGS)
+check: makel
+ ./test
+
install: makel
mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1/"
@@ -40,4 +43,4 @@ clean:
.SUFFIXES:
.SUFFIXES: .o .c
-.PHONY: all install uninstall clean
+.PHONY: all check install uninstall clean
diff --git a/test b/test
new file mode 100755
index 0000000..f8fc26c
--- /dev/null
+++ b/test
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Every test file must start with a line formatted as follows:
+# #:<exit code>:<additional makel command line options>
+
+nfails=0
+for f in tests/*.mk; do
+ header=$(head -n1 "$f")
+ exp=$(echo "$header" | cut -d: -f2)
+ options=$(echo "$header" | cut -d: -f3)
+ ./makel -f$f $options 2>/dev/null 1>/dev/null
+ got=$?
+ if [ $got -lt $exp ]; then
+ echo "$f: defect was not detected (expected $exp, got $got)"
+ nfails=$((nfails+1))
+ fi
+ if [ $got -gt $exp ]; then
+ echo "$f: found more serious defects than expected (expected $exp, got $got)"
+ nfails=$((nfails+1))
+ fi
+done
+if [ $nfails -gt 0 ]; then
+ echo "----------"
+ echo "$nfails tests returned different exit codes than expected."
+fi
+
diff --git a/tests/bad_ws.mk b/tests/bad_ws.mk
new file mode 100644
index 0000000..7b3a0f7
--- /dev/null
+++ b/tests/bad_ws.mk
@@ -0,0 +1,2 @@
+#:6:
+ foo: bar # This line is preceded by a vertical tab
diff --git a/tests/cont_of_blank.mk b/tests/cont_of_blank.mk
new file mode 100644
index 0000000..ea9fac4
--- /dev/null
+++ b/tests/cont_of_blank.mk
@@ -0,0 +1,3 @@
+#:2:
+\
+ OBJS=
diff --git a/tests/cont_to_blank.mk b/tests/cont_to_blank.mk
new file mode 100644
index 0000000..20ed281
--- /dev/null
+++ b/tests/cont_to_blank.mk
@@ -0,0 +1,3 @@
+#:2:
+OBJS=\
+
diff --git a/tests/eof_cont.mk b/tests/eof_cont.mk
new file mode 100644
index 0000000..989d6fd
--- /dev/null
+++ b/tests/eof_cont.mk
@@ -0,0 +1,3 @@
+#:4:
+# Continuation to end-of-file
+OBJS=\
diff --git a/tests/ws_before_comment.mk b/tests/ws_before_comment.mk
new file mode 100644
index 0000000..1157b05
--- /dev/null
+++ b/tests/ws_before_comment.mk
@@ -0,0 +1,2 @@
+#:6:
+ # This is not actually a valid comment