Makefile.coq.local 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9
# run tests after real-all
post-all:: test

# the test suite
TESTFILES=$(wildcard tests/*.v)

test: $(TESTFILES:.v=.vo)
.PHONY: test

10
COQ_TEST=$(COQTOP) $(COQDEBUG) -batch -test-mode
11 12 13 14 15
REF_FILTER=egrep -v '(^Welcome to Coq|^Skipping rcfile loading.$$)'

# Can't use pipes because that discards error codes and dash provides no way to control that.
# Also egrep errors if it doesn't match anything, we have to ignore that.
# Oh Unix...
16

17
$(TESTFILES:.v=.vo): %.vo: %.v $(VFILES:.v=.vo)
18
	$(SHOW)COQTOP [test] $<
19
	$(HIDE)TEST="$$(basename -s .v $<)" && \
Ralf Jung's avatar
Ralf Jung committed
20
	  TMPFILE="$$(mktemp)" && \
21
	  $(TIMER) $(COQ_TEST) $(TIMING_ARG) $(COQFLAGS) $(COQLIBS) -load-vernac-source $< $(TIMING_EXTRA) > "$$TMPFILE" && \
22 23 24
	  ($(REF_FILTER) < "$$TMPFILE" > "$$TMPFILE.filtered" || true) && \
	  (diff -u "tests/$$TEST.ref" "$$TMPFILE.filtered" || rm -f "tests/$$TEST.vo" "$$TMPFILE" "$$TMPFILE.filtered") && \
	  rm "$$TMPFILE" "$$TMPFILE.filtered"
25 26 27 28 29 30

# a target, for convenience sake, to create the .ref file with the current output
ref: $(TESTFILES:.v=.ref)
.PHONY: ref

tests/%.ref: tests/%.v $(VFILES:.v=.vo)
31
	$(SHOW)COQTOP [ref] $<
32
	$(HIDE)TEST="$$(basename -s .v $<)" && \
33 34 35
	  $(TIMER) $(COQ_TEST) $(TIMING_ARG) $(COQFLAGS) $(COQLIBS) -load-vernac-source $< $(TIMING_EXTRA) > "tests/$$TEST.ref" && \
	  ($(REF_FILTER) < "tests/$$TEST.ref" > "tests/$$TEST.ref.filtered" || true) && \
	  mv "tests/$$TEST.ref.filtered" "tests/$$TEST.ref"