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 @@
# Compilation:
*.native
_build
_build*
*.processed.ml
# MacOS:
.DS_Store
doc/auto
\ No newline at end of file
doc/auto
export VISITORS_BUILDING_DOCUMENTATION=true
# For consistency with doc/Makefile, which relies on the same
# set of %.processed.ml files.
# ocamlbuild options.
OCAMLBUILD := ocamlbuild -use-ocamlfind -classic-display
TESTS := \
$(shell ls *.ml | grep -v processed)
# For consistency with doc/Makefile, which relies on the same set of
# %.processed.ml files, we set this variable to true.
export VISITORS_BUILDING_DOCUMENTATION=true
TARGETS := \
$(patsubst %.ml,%.native,$(TESTS))
# The source files.
TESTS := $(shell ls *.ml | grep -v processed)
MLI := \
$(patsubst %.ml,%.inferred.mli,$(TESTS))
# ------------------------------------------------------------------------------
OCAMLBUILD := \
ocamlbuild \
-use-ocamlfind \
-classic-display \
.PHONY: test reinstall coverage bench mli processed clean
.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
@ echo Re-compiling...
@ $(OCAMLBUILD) $(TARGETS)
@ echo Compiling...
@ 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
@ echo Re-compiling...
@ $(OCAMLBUILD) $@
# A tiny speed benchmark.
bench: reinstall
@ echo Re-compiling...
@ $(OCAMLBUILD) bench.native
@ $(OCAMLBUILD) -build-dir _build_bench bench.native
@ echo Running...
@ ./bench.native
@ _build_bench/bench.native
# ------------------------------------------------------------------------------
# Building inferred .mli files.
mli: reinstall
@ echo Re-compiling...
@ $(OCAMLBUILD) $(MLI)
make -j4 $(patsubst %.ml,%.inferred.mli,$(TESTS))
# 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:
@ rm -f *~
@ 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: \
debug, \
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