Skip to content
Snippets Groups Projects
Makefile.coq.local 2.56 KiB
Newer Older
# use NO_TEST=1 to skip the tests
NO_TEST:=

# use MAKE_REF=1 to generate new reference files
MAKE_REF:=

# Run tests interleaved with main build.  They have to be in the same target for this.
real-all: style $(if $(NO_TEST),,test)
style: $(VFILES) coq-lint.sh
# Make sure everything imports the options, and all Instance/Argument/Hint are qualified.
Ralf Jung's avatar
Ralf Jung committed
	$(HIDE)for FILE in $(VFILES); do \
Ralf Jung's avatar
Ralf Jung committed
	  if ! grep -F -q 'From iris.prelude Require Import options.' "$$FILE"; then echo "ERROR: $$FILE does not import 'options'."; echo; exit 1; fi ; \
Ralf Jung's avatar
Ralf Jung committed
	  ./coq-lint.sh "$$FILE" || exit 1; \
# Make sure main Iris does not import other Iris packages.
Ralf Jung's avatar
Ralf Jung committed
	$(HIDE)if grep -E 'iris\.(heap_lang|deprecated|unstable)' --include "*.v" -R iris; then echo "ERROR: Iris may not import modules from other Iris packages (see above for violations)."; echo; exit 1; fi
.PHONY: style

# the test suite
TESTFILES:=$(shell find tests -name "*.v")
NORMALIZER:=test-normalizer.sed

test: $(TESTFILES:.v=.vo)
COQ_TEST=$(COQTOP) $(COQDEBUG) -batch -test-mode
# These versions of Coq are known to have different output so we don't test them.
# Need to make this a lazy variable (`=` instead of `:=`) since COQ_VERSION is only set later.
Ralf Jung's avatar
Ralf Jung committed
# Make sure to recognize both 8.19.0 and 8.19+alpha.
COQ_NOREF=$(shell echo "$(COQ_VERSION)" | egrep "^8\.19[.+]" -q && echo 1)
tests/.coqdeps.d: $(TESTFILES)
Ralf Jung's avatar
Ralf Jung committed
	$(SHOW)'COQDEP TESTFILES'
	$(HIDE)$(COQDEP) -dyndep var $(COQMF_COQLIBS_NOML) $^ $(redir_if_ok)
-include tests/.coqdeps.d
# Main test script (comments out-of-line because macOS otherwise barfs?!?)
# - Determine reference file (`REF`).
# - Print user-visible status line.
# - unset env vars that change Coq's output
# - 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.
$(TESTFILES:.v=.vo): %.vo: %.v $(if $(MAKE_REF),,%.ref) $(NORMALIZER)
	$(HIDE)REF=$*".ref" && \
	  echo "COQTEST$(if $(COQ_NOREF), [ref diff ignored],$(if $(MAKE_REF), [make ref],)) $< (ref: $$REF)" && \
	  TMPFILE="$$(mktemp)" && \
	  unset OCAMLRUNPARAM && \
	  $(TIMER) $(COQ_TEST) $(COQFLAGS) $(COQLIBS) -load-vernac-source $< > "$$TMPFILE" && \
	  sed -f $(NORMALIZER) "$$TMPFILE" > "$$TMPFILE".new && \
	  mv "$$TMPFILE".new "$$TMPFILE" && \
	  $(if $(COQ_NOREF), (diff --strip-trailing-cr -u "$$REF" "$$TMPFILE" || true) , \
	    $(if $(MAKE_REF),mv "$$TMPFILE" "$$REF",diff --strip-trailing-cr -u "$$REF" "$$TMPFILE") \
	  ) && \
	  rm -f "$$TMPFILE" && \