[test] make tests pass in clang-only or java-only mode

Summary:
This is useful to make sure `./build-infer.sh clang` and `./build-infer.sh
java` work correctly.

I had to move one unit test inside a new unit/clang/ directory used only if clang is enabled, and create a stub for it in unit/clang_stubs/ for when clang is disabled.

Renamed `OCAML_SOURCES` to the more consistent and descriptive `OCAML_CONFIG_SOURCES`.

Reviewed By: jeremydubreil

Differential Revision: D4571997

fbshipit-source-id: 9502114
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent 7260d5b763
commit 7e1f1f9101

@ -29,7 +29,7 @@ BUILD_SYSTEMS_TESTS += \
project_root_rel \
reactive \
run_hidden_linters \
utf8_in_procname utf8_in_pwd \
utf8_in_procname \
waf \
ifneq ($(CMAKE),no)
@ -50,7 +50,7 @@ endif # XCODE_SELECT
endif # BUILD_C_ANALYZERS
ifeq ($(BUILD_JAVA_ANALYZERS),yes)
BUILD_SYSTEMS_TESTS += gradle javac
BUILD_SYSTEMS_TESTS += gradle javac utf8_in_pwd
ifneq ($(ANT),no)
BUILD_SYSTEMS_TESTS += ant
endif
@ -223,9 +223,15 @@ endtoend_test: print_direct_tests print_build_systems_tests
.PHONY: inferTraceBugs_test
inferTraceBugs_test: infer
ifeq ($(BUILD_JAVA_ANALYZERS),yes)
$(INFER_BIN) -o __test-infer-out__ -- \
javac $(EXAMPLES_DIR)/Hello.java \
> /dev/null
else
$(INFER_BIN) -o __test-infer-out__ -- \
clang -c $(EXAMPLES_DIR)/hello.c \
> /dev/null
endif
@rm -f Hello.class
$(PYTHON_DIR)/inferTraceBugs -o __test-infer-out__ \
--select 0 --max-level max > /dev/null

@ -150,7 +150,9 @@ DEPENDENCIES += java_stubs
endif
ifeq ($(BUILD_C_ANALYZERS),yes)
INFER_CONFIG_TARGETS += $(INFERCLANG_MAIN).native
DEPENDENCIES += clang
DEPENDENCIES += clang unit/clang
else
DEPENDENCIES += unit/clang_stubs
endif
OCAML_BASE_SOURCES = \
@ -158,9 +160,9 @@ OCAML_BASE_SOURCES = \
$(DEPENDENCIES:=/[a-zA-Z]*.mll) $(DEPENDENCIES:=/[a-zA-Z]*.mly) \
$(DEPENDENCIES:=/[a-zA-Z]*.re) $(DEPENDENCIES:=/[a-zA-Z]*.rei)) \
$(STACKTREE_ATDGEN_STUBS) $(INFERPRINT_ATDGEN_STUBS)
OCAML_SOURCES = $(OCAML_BASE_SOURCES)
OCAML_CONFIG_SOURCES = $(OCAML_BASE_SOURCES)
ifeq ($(BUILD_C_ANALYZERS),yes)
OCAML_SOURCES += $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES)
OCAML_CONFIG_SOURCES += $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES)
endif
OCAML_ALL_SOURCES = $(OCAML_BASE_SOURCES) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES)
@ -171,7 +173,7 @@ all: infer
# single out infer.native as the source of truth for make, knowing that in fact several targets are
# produced by the build
$(INFER_BUILD_DIR)/$(INFER_MAIN).native: base/Version.ml $(BUILD_DIR) $(OCAML_SOURCES) \
$(INFER_BUILD_DIR)/$(INFER_MAIN).native: base/Version.ml $(BUILD_DIR) $(OCAML_CONFIG_SOURCES) \
$(MAKEFILE_LIST)
$(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) $(INFER_CONFIG_TARGETS)
# let make know that the target is up-to-date even if ocamlbuild cached it
@ -197,9 +199,9 @@ ifeq ($(BUILD_C_ANALYZERS),yes)
infer: $(CLANG_BINIOU_DICT)
endif
$(INFER_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES)
$(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) \
$(INFER_ALL_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte
$(INFER_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_CONFIG_SOURCES)
$(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) \
$(INFER_CONFIG_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte
@touch $@
$(INFER_BIN).byte: $(INFER_BUILD_DIR)/$(INFER_MAIN).byte $(BIN_DIR)
@ -228,11 +230,11 @@ module: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES)
$(MFLAGS) \
$(M)
$(TEST_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_ALL_SOURCES) \
$(TEST_BUILD_DIR)/$(INFER_MAIN).byte: base/Version.ml $(BUILD_DIR) $(OCAML_CONFIG_SOURCES) \
toplevel.mlpack $(MAKEFILE_LIST)
$(OCAMLBUILD_ALL) -build-dir $(TEST_BUILD_DIR) \
$(OCAMLBUILD_CONFIG) -build-dir $(TEST_BUILD_DIR) \
-cflags -warn-error,$(OCAML_FATAL_WARNINGS) \
$(INFER_ALL_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte toplevel.cmo
$(INFER_CONFIG_TARGETS:.native=.byte) $(INFERUNIT_MAIN).byte toplevel.cmo
@touch $@
.PHONY: test_build
@ -283,7 +285,7 @@ $(shell \
| awk 'BEGIN { FS = "/"; OFS = "/" } ; {$$NF=toupper(substr($$NF,1,1))substr($$NF,2); print $$0}')
endef
toplevel.mlpack: base/Version.ml $(OCAML_ALL_SOURCES) $(MAKEFILE_LIST)
toplevel.mlpack: base/Version.ml $(OCAML_CONFIG_SOURCES) $(MAKEFILE_LIST)
# We need to pack all the infer modules into another module to avoid name clashes with some
# of them coming from ocaml libraries (Ident for example). To do that, we generate a .mlpack
# file containing namespaced modules.
@ -295,13 +297,13 @@ toplevel.mlpack: base/Version.ml $(OCAML_ALL_SOURCES) $(MAKEFILE_LIST)
$(foreach module,\
$(filter-out $(foreach root,$(roots),%/$(root)),\
$(foreach source,\
$(filter-out unit/% facebook/scripts/eradicate_stats.ml,$(OCAML_ALL_SOURCES)),\
$(filter-out unit/% facebook/scripts/eradicate_stats.ml,$(OCAML_CONFIG_SOURCES)),\
$(call to_ocaml_module,$(source)))),\
$(shell echo $(module) >> $($@_tmp)))
mv $($@_tmp) $@
$(INFER_BUILD_DIR)/toplevel.cmo: toplevel.mlpack $(BUILD_DIR)
$(OCAMLBUILD_ALL) -build-dir $(INFER_BUILD_DIR) toplevel.cmo
$(OCAMLBUILD_CONFIG) -build-dir $(INFER_BUILD_DIR) toplevel.cmo
@touch $@
.PHONY: toplevel

@ -0,0 +1,13 @@
(*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
open! IStd
let tests = [
CiOSVersionNumbersTests.tests;
]

@ -0,0 +1,11 @@
(*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
open! IStd
val tests : OUnit2.test list

@ -0,0 +1,12 @@
(*
* Copyright (c) 2017 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*)
open! IStd
let tests = OUnitTest.TestList []

@ -20,13 +20,12 @@ let () =
AddressTakenTests.tests;
BoundedCallTreeTests.tests;
CopyPropagationTests.tests;
CiOSVersionNumbersTests.tests;
ProcCfgTests.tests;
LivenessTests.tests;
SchedulerTests.tests;
StacktraceTests.tests;
TaintTests.tests;
TraceTests.tests;
] in
] @ ClangTests.tests in
let test_suite = "all" >::: tests in
OUnit2.run_test_tt_main test_suite

Loading…
Cancel
Save