Commit fb20be25 authored by POTTIER Francois's avatar POTTIER Francois

Complete rewrite of test/Makefile so as to allow parallel tests.

parent 65f2fdec
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
# Compilation: # Compilation:
*.native *.native
_build _build*
*.processed.ml *.processed.ml
# MacOS: # MacOS:
.DS_Store .DS_Store
doc/auto doc/auto
\ No newline at end of file
export VISITORS_BUILDING_DOCUMENTATION=true # ocamlbuild options.
# For consistency with doc/Makefile, which relies on the same OCAMLBUILD := ocamlbuild -use-ocamlfind -classic-display
# set of %.processed.ml files.
TESTS := \ # For consistency with doc/Makefile, which relies on the same set of
$(shell ls *.ml | grep -v processed) # %.processed.ml files, we set this variable to true.
export VISITORS_BUILDING_DOCUMENTATION=true
TARGETS := \ # The source files.
$(patsubst %.ml,%.native,$(TESTS)) TESTS := $(shell ls *.ml | grep -v processed)
MLI := \ # ------------------------------------------------------------------------------
$(patsubst %.ml,%.inferred.mli,$(TESTS))
OCAMLBUILD := \ .PHONY: test reinstall coverage bench mli processed clean
ocamlbuild \
-use-ocamlfind \
-classic-display \
.PHONY: test bench mli processed clean reinstall # Because ocamlbuild is not good at parallel builds, we have broken up the set
# of test sources into several subsets, each of which is described by an
# [.mllib] file. For each such file, we make a separate ocamlbuild invocation,
# and we let [make] run these invocations in parallel. (Each of them must use
# a distinct build directory, and ignore everyone else's build directory.)
test: reinstall test: reinstall
@ echo Re-compiling... @ echo Compiling...
@ $(OCAMLBUILD) $(TARGETS) @ make -j4 $(patsubst %.mllib,%.cma,$(shell ls *.mllib))
%.cma:
@ $(OCAMLBUILD) -build-dir _build_$* $@
# To ensure that we always have the current version of [visitors], we
# reinstall it before compiling.
reinstall:
@ echo Re-installing...
@ make -C ../src reinstall >/dev/null 2>/dev/null
# Checking that every .ml file is covered by one .mllib file.
coverage:
@ for i in $(TESTS) ; do \
if ! grep -iw `basename $$i .ml` *.mllib >/dev/null ; then \
echo [ERROR] $$i is not covered by any .mllib file. ; \
fi \
done
# ------------------------------------------------------------------------------
%.native: reinstall # A tiny speed benchmark.
@ echo Re-compiling...
@ $(OCAMLBUILD) $@
bench: reinstall bench: reinstall
@ echo Re-compiling... @ $(OCAMLBUILD) -build-dir _build_bench bench.native
@ $(OCAMLBUILD) bench.native
@ echo Running... @ echo Running...
@ ./bench.native @ _build_bench/bench.native
# ------------------------------------------------------------------------------
# Building inferred .mli files.
mli: reinstall mli: reinstall
@ echo Re-compiling... make -j4 $(patsubst %.ml,%.inferred.mli,$(TESTS))
@ $(OCAMLBUILD) $(MLI)
# This one is a bit tricky, as we must specify the right build directory.
# We grep to find out which .mllib file covers the desired .mli file,
# then construct the name of the build directory from the name of the
# .mllib file.
%.inferred.mli:
@ $(OCAMLBUILD) -build-dir \
_build_$(shell grep -iw $* *.mllib | sed -e 's/\([^.]*\).mllib:.*/\1/') \
$@
# ------------------------------------------------------------------------------
include ../src/Makefile.preprocess # Preprocessing all source files.
processed: $(patsubst %.ml,%.processed.ml,$(TESTS)) processed: reinstall
make -j4 -f ../src/Makefile.preprocess \
$(patsubst %.ml,%.processed.ml,$(TESTS))
# ------------------------------------------------------------------------------
# Cleaning up.
clean: clean:
@ rm -f *~ @ rm -f *~
@ rm -f *.processed.ml @ rm -f *.processed.ml
@ $(OCAMLBUILD) -clean @ rm -rf _build*
reinstall: # ------------------------------------------------------------------------------
@ echo Re-installing...
@ make -C ../src reinstall >/dev/null 2>/dev/null
# Declare that the build directories should not be traversed.
<_build*>: -traverse
true: \ true: \
debug, \ debug, \
safe_string, \ safe_string, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment