aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul LeoNerd Evans <leonerd@leonerd.org.uk>2011-03-31 12:11:19 +0100
committerPaul LeoNerd Evans <leonerd@leonerd.org.uk>2011-03-31 12:11:19 +0100
commit3bbda921b7180340ccc50c1a8a2bf01631508f36 (patch)
tree787f87e96597293bff639162ccb4a67c59fcb8eb
parent620038af7274a338160e9ad0a787cc21e4fc64ea (diff)
downloadtermo-3bbda921b7180340ccc50c1a8a2bf01631508f36.tar.gz
termo-3bbda921b7180340ccc50c1a8a2bf01631508f36.tar.xz
termo-3bbda921b7180340ccc50c1a8a2bf01631508f36.zip
Created a little Test::More-like library for TAP testing
-rw-r--r--Makefile7
-rw-r--r--t/01base.c8
-rw-r--r--t/taplib.c23
-rw-r--r--t/taplib.h3
4 files changed, 35 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index d9a5b10..da19c7f 100644
--- a/Makefile
+++ b/Makefile
@@ -81,12 +81,15 @@ doc: $(BUILTMAN)
%.3: %.3.sh
sh $< >$@
-TESTSOURCES=$(wildcard t/*.c)
+TESTSOURCES=$(wildcard t/[0-9]*.c)
TESTFILES=$(TESTSOURCES:.c=.t)
-t/%.t: t/%.c $(LIBRARY)
+t/%.t: t/%.c $(LIBRARY) t/taplib.lo
$(LIBTOOL) --mode=link --tag=CC gcc -o $@ $^
+t/taplib.lo: t/taplib.c
+ $(LIBTOOL) --mode=compile --tag=CC gcc $(CFLAGS) -o $@ -c $^
+
test: $(TESTFILES)
prove -e ""
diff --git a/t/01base.c b/t/01base.c
index 7fbddc0..0340287 100644
--- a/t/01base.c
+++ b/t/01base.c
@@ -1,20 +1,20 @@
#include <stdio.h>
#include "termkey.h"
+#include "taplib.h"
int main(int argc, char *argv[])
{
TermKey *tk;
- printf("1..2\n");
+ plan_tests(2);
tk = termkey_new(0, TERMKEY_FLAG_NOTERMIOS);
- printf(tk ? "" : "not ");
- printf("ok 1 - termkey_new\n");
+ ok(!!tk, "termkey_new");
termkey_destroy(tk);
- printf("ok 2 - termkey_free\n");
+ ok(1, "termkey_free");
return 0;
}
diff --git a/t/taplib.c b/t/taplib.c
new file mode 100644
index 0000000..0e8735a
--- /dev/null
+++ b/t/taplib.c
@@ -0,0 +1,23 @@
+#include "taplib.h"
+
+#include <stdio.h>
+
+static int nexttest = 1;
+static int _exit_status = 0;
+
+void plan_tests(int n)
+{
+ printf("1..%d\n", n);
+}
+
+void ok(int cmp, char *name)
+{
+ printf("%s %d - %s\n", cmp ? "ok" : "not ok", nexttest++, name);
+ if(!cmp)
+ _exit_status = 1;
+}
+
+int exit_status(void)
+{
+ return _exit_status;
+}
diff --git a/t/taplib.h b/t/taplib.h
new file mode 100644
index 0000000..16e41b6
--- /dev/null
+++ b/t/taplib.h
@@ -0,0 +1,3 @@
+void plan_tests(int n);
+void ok(int cmp, char *name);
+int exit_status(void);