-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (52 loc) · 1.52 KB
/
Makefile
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
56
57
58
59
60
TYPST ?= typst
SUBDIRS := $(wildcard test/[0-9][0-9]/)
test: $(SUBDIRS) $(patsubst %.tbl,%.png,$(wildcard *.tbl))
help:
@printf 'Available targets:\n\
\n\
test (default) Run only tests that are out-of-date.\n\
-B to run all tests unconditionally.\n\
-j to specify the number of tests to run in parallel.\n\
-k to keep going after a test fails.\n\
-s to silence MAKE messages.\n\
DIR/ Run only tests in DIR/ (trailing slash required).\n\
The above options are also accepted.\n\
\n\
clean Remove newly-generated PNG files.\n\
reset Remove *all* PNG files.\n\
update Accept newly-generated PNG files as correct.\n\
'
clean:
@rm -f test/*/*.png.new
reset:
@rm -f test/*/*.png*
update:
@for i in test/*/*.png.new; do \
mv -f "$$i" "$${i%.new}"; \
done
%.png: %.tbl options.typ ../driver.typ.in ../../tbl.typ
@sed \
-e 's#@PATH_TBL@#"$<"#g' \
../driver.typ.in > '$*.typ'; \
mv -f '$@' '[email protected]' 2>/dev/null || :; \
if ! $(TYPST) compile '$*.typ' '$@'; then \
rm -f '$@' '[email protected]'; \
fi; \
mv -f '$@' '[email protected]' 2>/dev/null || :; \
mv -f '[email protected]' '$@' 2>/dev/null || :; \
rm -f '$*.typ'; \
if ! [ -e '$@' ]; then \
echo 'MISS $(TEST_DIR)$* (run `make update`?)'; \
exit 1; \
elif diff -q '$@' '[email protected]' >/dev/null 2>&1; then \
echo 'PASS $(TEST_DIR)$*'; \
touch '$@'; \
else \
echo 'FAIL $(TEST_DIR)$*'; \
exit 1; \
fi;
$(SUBDIRS):
@$(MAKE) -C '$@' -f ../../Makefile \
TYPST_ROOT='$(CURDIR)' \
TEST_DIR='$@'
.PHONY: test help clean reset update $(SUBDIRS)