Makefile.coq.local 1.7 KB
Newer Older
1 2
# Run tests interleaved with main build.  They have to be in the same target for this.
real-all: $(if $(NO_TEST),,test)
3 4 5

# the test suite
TESTFILES=$(wildcard tests/*.v)
6
NORMALIZER=test-normalizer.sed
7 8 9 10

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

11
COQ_TEST=$(COQTOP) $(COQDEBUG) -batch -test-mode
12
COQ_OLD=$(shell echo "$(COQ_VERSION)" | egrep "^8\.7\b" -q && echo 1)
13
COQ_MINOR_VERSION=$(shell echo "$(COQ_VERSION)" | egrep '^[0-9]+\.[0-9]+\b' -o)
14

15
tests/.coqdeps.d: $(TESTFILES)
Ralf Jung's avatar
Ralf Jung committed
16
	$(SHOW)'COQDEP TESTFILES'
17 18
	$(HIDE)$(COQDEP) -dyndep var $(COQMF_COQLIBS_NOML) $^ $(redir_if_ok)
-include tests/.coqdeps.d
19

20 21 22 23 24 25 26
# Main test script (comments out-of-line because macOS otherwise barfs?!?)
# - Determine reference file (`REF`).
# - Print user-visible status line.
# - Dump Coq output into a temporary file.
# - Run `sed -i` on that file in a way that works on macOS.
# - Either compare the result with the reference file, or move it over the reference file.
# - Cleanup, and mark as done for make.
27
$(TESTFILES:.v=.vo): %.vo: %.v $(if $(MAKE_REF),,%.ref) $(NORMALIZER)
28
	$(HIDE)TEST="$$(basename -s .v $<)" && \
Ralf Jung's avatar
Ralf Jung committed
29 30 31 32 33
	  if test -f "tests/$$TEST.$(COQ_MINOR_VERSION).ref"; then \
	    REF="tests/$$TEST.$(COQ_MINOR_VERSION).ref"; \
	  else \
	    REF="tests/$$TEST.ref"; \
	  fi && \
Ralf Jung's avatar
Ralf Jung committed
34
	  echo "COQTEST$(if $(COQ_OLD), [no ref],$(if $(MAKE_REF), [make ref],)) $<$(if $(COQ_OLD),, (ref: $$REF))" && \
35
	  TMPFILE="$$(mktemp)" && \
36
	  $(TIMER) $(COQ_TEST) $(COQFLAGS) $(COQLIBS) -load-vernac-source $< > "$$TMPFILE" && \
37 38
	  sed -f $(NORMALIZER) "$$TMPFILE" > "$$TMPFILE".new && \
	  mv "$$TMPFILE".new "$$TMPFILE" && \
Ralf Jung's avatar
Ralf Jung committed
39 40
	  $(if $(COQ_OLD),true, \
	    $(if $(MAKE_REF),mv "$$TMPFILE" "$$REF",diff -u "$$REF" "$$TMPFILE") \
41
	  ) && \
42
	  rm -f "$$TMPFILE" && \
43
	  touch $@