From e41e169f4448ffe8f66c3b4917073e66f82f8084 Mon Sep 17 00:00:00 2001 From: Ralf Jung <jung@mpi-sws.org> Date: Thu, 10 Dec 2020 14:51:42 +0100 Subject: [PATCH] update test harness --- Makefile.coq.local | 36 ++++++++++++++++++++++++------------ test-normalizer.sed | 0 2 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 test-normalizer.sed diff --git a/Makefile.coq.local b/Makefile.coq.local index cdb0b65c..b7d4c4ca 100644 --- a/Makefile.coq.local +++ b/Makefile.coq.local @@ -1,8 +1,15 @@ +# 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: $(if $(NO_TEST),,test) # the test suite -TESTFILES=$(wildcard tests/*.v) +TESTFILES:=$(shell find tests/ -name "*.v") +NORMALIZER:=test-normalizer.sed test: $(TESTFILES:.v=.vo) # Make sure everything imports the options. @@ -12,26 +19,31 @@ test: $(TESTFILES:.v=.vo) .PHONY: test COQ_TEST=$(COQTOP) $(COQDEBUG) -batch -test-mode -COQ_OLD=$(shell echo "$(COQ_VERSION)" | egrep "^8\.(7|8|9)\b" -q && echo 1) -COQ_MINOR_VERSION=$(shell echo "$(COQ_VERSION)" | egrep '^[0-9]+\.[0-9]+\b' -o) +COQ_MINOR_VERSION:=$(shell echo "$(COQ_VERSION)" | egrep '^[0-9]+\.[0-9]+\b' -o) tests/.coqdeps.d: $(TESTFILES) $(SHOW)'COQDEP TESTFILES' $(HIDE)$(COQDEP) -dyndep var $(COQMF_COQLIBS_NOML) $^ $(redir_if_ok) -include tests/.coqdeps.d -$(TESTFILES:.v=.vo): %.vo: %.v $(if $(MAKE_REF),,%.ref) - $(HIDE)TEST="$$(basename -s .v $<)" && \ - if test -f "tests/$$TEST.$(COQ_MINOR_VERSION).ref"; then \ - REF="tests/$$TEST.$(COQ_MINOR_VERSION).ref"; \ +# 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. +$(TESTFILES:.v=.vo): %.vo: %.v $(if $(MAKE_REF),,%.ref) $(NORMALIZER) + $(HIDE)if test -f $*".$(COQ_MINOR_VERSION).ref"; then \ + REF=$*".$(COQ_MINOR_VERSION).ref"; \ else \ - REF="tests/$$TEST.ref"; \ + REF=$*".ref"; \ fi && \ - echo "COQTEST$(if $(COQ_OLD), [no ref],$(if $(MAKE_REF), [make ref],)) $<$(if $(COQ_OLD),, (ref: $$REF))" && \ + echo "COQTEST$(if $(MAKE_REF), [make ref],) $< (ref: $$REF)" && \ TMPFILE="$$(mktemp)" && \ $(TIMER) $(COQ_TEST) $(COQFLAGS) $(COQLIBS) -load-vernac-source $< > "$$TMPFILE" && \ - $(if $(COQ_OLD),true, \ - $(if $(MAKE_REF),mv "$$TMPFILE" "$$REF",diff -u "$$REF" "$$TMPFILE") \ - ) && \ + sed -f $(NORMALIZER) "$$TMPFILE" > "$$TMPFILE".new && \ + mv "$$TMPFILE".new "$$TMPFILE" && \ + $(if $(MAKE_REF),mv "$$TMPFILE" "$$REF",diff -u "$$REF" "$$TMPFILE") && \ rm -f "$$TMPFILE" && \ touch $@ diff --git a/test-normalizer.sed b/test-normalizer.sed new file mode 100644 index 00000000..e69de29b -- GitLab