summaryrefslogtreecommitdiff
path: root/oldtests/Makefile
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-07-21 22:29:16 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-08-13 22:56:32 -0700
commit870e63be7360b5a0097a27656048e853bc720464 (patch)
treee8f19ee2d62e529115cb71dcda5f3298cca7d389 /oldtests/Makefile
parent650ad87f35f4405a2ca8270d2b2835daa442e5f1 (diff)
Initial commit
Diffstat (limited to 'oldtests/Makefile')
-rw-r--r--oldtests/Makefile55
1 files changed, 55 insertions, 0 deletions
diff --git a/oldtests/Makefile b/oldtests/Makefile
new file mode 100644
index 0000000..c8a30bd
--- /dev/null
+++ b/oldtests/Makefile
@@ -0,0 +1,55 @@
+SHELL=/bin/bash
+TESTDIR ?= *
+PATT ?= .
+TESTS=$(shell ls $(TESTDIR)/*.markdown | grep $(PATT))
+DIFFS=$(patsubst %.markdown,%.diff,$(TESTS))
+PROG ?= ../stmd
+FILTER ?= perl -pe 's/ /␣/g'
+TIDYCMD ?= tidy -asxhtml -utf8 --show-body-only yes --show-warnings no -quiet
+DETAILS ?= 1
+
+# Check to see if echo supports -e option to allow backslash escapes
+ifeq ($(shell echo -e),-e)
+ECHO=echo
+else
+ECHO=echo -e
+endif
+
+all: $(DIFFS)
+ PASS=0;TESTS=0; \
+ for f in $(DIFFS); do \
+ let TESTS=TESTS+1; \
+ [ -s $$f ] || let PASS=PASS+1; \
+ done; \
+ $(ECHO) "\033[1m$$PASS of $$TESTS tests passed.\033[0m"; \
+ if [ $$TESTS -eq $$PASS ]; then exit 0; else exit 1; fi
+
+%.actual.html: %.markdown
+ifeq ($(TIDY),1)
+ -cat $< | $(PROG) | $(TIDYCMD) > $@
+else
+ -cat $< | $(PROG) > $@
+endif
+
+%.expected.html: %.html
+ifeq ($(TIDY),1)
+ -$(TIDYCMD) $< > $@
+else
+ cp $< $@
+endif
+
+%.diff: %.expected.html %.actual.html
+ diff --unified=1 <(cat $(word 1,$^) | $(FILTER)) <(cat $(word 2,$^) | $(FILTER)) > $@ ; \
+ if [ -s $@ ]; then \
+ $(ECHO) "\033[1;31m✘ $(patsubst %.diff,%,$@)\033[0m"; \
+ if [ $(DETAILS) == "1" ]; then \
+ $(ECHO) "\033[0;36m" ; cat $@; $(ECHO) "\033[0m"; \
+ fi \
+ else \
+ $(ECHO) "\033[1;32m✓ $(patsubst %.diff,%,$@)\033[0m"; \
+ fi
+
+.PHONY: all clean
+
+clean:
+ -@rm */*.{diff,actual.html,expected.html}