Makefile.coq.local 1.48 KB
Newer Older
1 2
# run tests with main build
real-all: test
3 4 5 6 7 8 9

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

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

10
COQ_TEST=$(COQTOP) $(COQDEBUG) -batch -test-mode
11
COQ_OLD=$(shell echo "$(COQ_VERSION)" | egrep "^8\.7\b" > /dev/null && echo 1)
Ralf Jung's avatar
Ralf Jung committed
12
COQ_MINOR_VERSION=$(shell echo "$(COQ_VERSION)" | egrep '^[0-9]+\.[0-9]+' -o)
13 14 15 16

# 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...
17 18 19
REF_FILTER=egrep -v '(^Welcome to Coq|^Skipping rcfile loading.$$)'

tests/.coqdeps.d: $(TESTFILES)
Ralf Jung's avatar
Ralf Jung committed
20
	$(SHOW)'COQDEP TESTFILES'
21 22
	$(HIDE)$(COQDEP) -dyndep var $(COQMF_COQLIBS_NOML) $^ $(redir_if_ok)
-include tests/.coqdeps.d
23

24
$(TESTFILES:.v=.vo): %.vo: %.v $(if $(MAKE_REF),,%.ref)
25
	$(HIDE)TEST="$$(basename -s .v $<)" && \
Ralf Jung's avatar
Ralf Jung committed
26 27 28 29 30
	  if test -f "tests/$$TEST.$(COQ_MINOR_VERSION).ref"; then \
	    REF="tests/$$TEST.$(COQ_MINOR_VERSION).ref"; \
	  else \
	    REF="tests/$$TEST.ref"; \
	  fi && \
31
	  echo $(if $(MAKE_REF),"COQTEST [ref] `basename "$$REF"`","COQTEST$(if $(COQ_OLD), [ignored],) `basename "$$REF"`") && \
Ralf Jung's avatar
Ralf Jung committed
32
	  TMPFILE="$$(mktemp)" && \
33
	  $(TIMER) $(COQ_TEST) $(COQFLAGS) $(COQLIBS) -load-vernac-source $< > "$$TMPFILE" && \
34
	  ($(REF_FILTER) < "$$TMPFILE" > "$$TMPFILE.filtered" || true) && \
Ralf Jung's avatar
Ralf Jung committed
35
	  $(if $(MAKE_REF), \
Ralf Jung's avatar
Ralf Jung committed
36
	    mv "$$TMPFILE.filtered" "$$REF", \
37
	    $(if $(COQ_OLD),true,diff -u "$$REF" "$$TMPFILE.filtered") \
38
	  ) && \
39
	  rm -f "$$TMPFILE" "$$TMPFILE.filtered" && \
40
	  touch $@