blob: c8a30bd25365f8b2a66152e89162769a92c3dbc0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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}
|