From 35c7d67c5cc1398e83c7f23e8a286d46245c38b8 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 27 Apr 2017 02:30:29 -0700 Subject: [PATCH] [test] test the correct version of toplevel.cmo Summary: There are 2 possible places where to find toplevel.cmo: - infer/_build/infer/toplevel.cmo, built by `make toplevel` - infer/_build/test/infer/toplevel.cmo, built by `make test` The test loading and running toplevel.cmo would give priority to the non-test version of toplevel.cmo, which might be stale because `make test` doesn't rebuild it. This diff makes sure we use the test version of toplevel.cmo in `make test`. Reviewed By: akotulski Differential Revision: D4960550 fbshipit-source-id: 9c817ba --- Makefile | 3 ++- scripts/infer_repl | 20 ++++++-------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index b4ff7a07f..6069c01c6 100644 --- a/Makefile +++ b/Makefile @@ -289,7 +289,8 @@ toplevel: clang_plugin .PHONY: inferScriptMode_test inferScriptMode_test: test_build $(QUIET)$(call silent_on_success,Testing infer OCaml REPL,\ - INFER_REPL_BINARY=ocaml $(SCRIPT_DIR)/infer_repl $(INFER_DIR)/tests/repl/infer_batch_script.ml) + INFER_REPL_BINARY=ocaml TOPLEVEL_DIR=$(BUILD_DIR)/test/infer $(SCRIPT_DIR)/infer_repl \ + $(INFER_DIR)/tests/repl/infer_batch_script.ml) .PHONY: checkCopyright checkCopyright: diff --git a/scripts/infer_repl b/scripts/infer_repl index 4244b6efe..87cc921e2 100755 --- a/scripts/infer_repl +++ b/scripts/infer_repl @@ -2,14 +2,11 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -# _build/infer is first so that it takes precedence. This way if someone explicitly builds the -# toplevel (`make toplevel`) they get the expected version of infer. The _build/test toplevel is -# built during `make test` which is probably run less often, hence why it doesn't take -# precedence. Of course this cannot be perfect so caution is advised. -TOPLEVEL_INCLUDES=( - -I "$SCRIPT_DIR"/../infer/_build/infer - -I "$SCRIPT_DIR"/../infer/_build/test/infer -) +# where to find toplevel.cmo, can be overridden +TOPLEVEL_DIR=${TOPLEVEL_DIR:-"$SCRIPT_DIR"/../infer/_build/infer} + +# how to load the toplevel; can be overridden (with "ocaml" for example) +INFER_REPL_BINARY=${INFER_REPL_BINARY:-"utop"} # to build new toplevel, run `make toplevel` # -init option is used only in interactive mode @@ -20,9 +17,4 @@ TOPLEVEL_INCLUDES=( # so they can be located anywhere and still find toplevel_init # file. In interactive mode $SCRIPT_DIR isn't needed -# by default utop is used, pass `INFER_REPL_BINARY` to change the toplevel -# binary (to `ocaml` for example) -if [ -z "$INFER_REPL_BINARY" ]; then - INFER_REPL_BINARY="utop" -fi -$INFER_REPL_BINARY -init $SCRIPT_DIR/toplevel_init ${TOPLEVEL_INCLUDES[@]} -I $SCRIPT_DIR $@ +"$INFER_REPL_BINARY" -init "$SCRIPT_DIR"/toplevel_init -I "$TOPLEVEL_DIR" -I "$SCRIPT_DIR" $@