From 870e63be7360b5a0097a27656048e853bc720464 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 21 Jul 2014 22:29:16 -0700 Subject: Initial commit --- oldtests/Makefile | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 oldtests/Makefile (limited to 'oldtests/Makefile') 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} -- cgit v1.2.3