From b54fbc277621ef1115d819616524662160071b1e Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 19 Feb 2016 06:57:03 -0800 Subject: [PATCH] Add test_build target warnings not fatal otherwise Summary:public Adds test_build target to toplevel Makefile, which compiles InferAnalyze, InferPrint, InferClang, and InferJava where warnings listed in OCAML_FATAL_WARNINGS defined in infer/src/Makefile are fatal. Other builds do not treat warnings as fatal. The test build is performed in parallel with the tests by scripts/test.sh. This makes refactoring and debugging easier, but prevents warnings from slipping into the repo. Also, make test target robust wrt parallel make. Reviewed By: jvillard Differential Revision: D2953085 fb-gh-sync-id: 5c0282a shipit-source-id: 5c0282a --- Makefile.in | 18 ++++++++++-------- infer/src/Makefile.in | 34 ++++++++++++++-------------------- scripts/test.sh | 2 +- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Makefile.in b/Makefile.in index 8daff6b04..b0d863671 100644 --- a/Makefile.in +++ b/Makefile.in @@ -78,26 +78,28 @@ endif clang: clang_plugin endif +test_build: + $(MAKE) -C $(SRC_DIR) test_clean + $(MAKE) -C $(SRC_DIR) test_build + buck_test: $(INFER_ANALYZERS) NO_BUCKD=1 buck clean NO_BUCKD=1 buck test $(TARGETS_TO_TEST) +ifeq (@BUILD_JAVA_ANALYZERS@,yes) + NO_BUCKD=1 ./scripts/build_integration_tests.py +endif buck_test_xml: $(INFER_ANALYZERS) NO_BUCKD=1 buck clean NO_BUCKD=1 buck test --xml test.xml $(TARGETS_TO_TEST) - -build_integration_tests: $(INFER_ANALYZERS) +ifeq (@BUILD_JAVA_ANALYZERS@,yes) NO_BUCKD=1 ./scripts/build_integration_tests.py +endif test: buck_test test_xml: buck_test_xml -ifeq (@BUILD_JAVA_ANALYZERS@,yes) -test: build_integration_tests -test_xml: build_integration_tests -endif - clean: @rm -fv test.xml ifeq (@BUILD_C_ANALYZERS@,yes) @@ -106,4 +108,4 @@ ifeq (@BUILD_C_ANALYZERS@,yes) endif $(MAKE) -C $(INFER_DIR) clean -.PHONY: all build_integration_tests clean clang clang_plugin clang_setup java test test_xml +.PHONY: all build_integration_tests clean clang clang_plugin clang_setup java test test_xml test_build diff --git a/infer/src/Makefile.in b/infer/src/Makefile.in index 3be7ff2f9..fe77ccb4a 100644 --- a/infer/src/Makefile.in +++ b/infer/src/Makefile.in @@ -39,6 +39,8 @@ ETC_DIR = $(INFER_DIR)/etc #### ocamlbuild options #### +OCAML_FATAL_WARNINGS = +5+6+8+10+11+12+18+19+20+26+29+27+32+33+34+35+37+38+39 + OCAMLBUILD_OPTIONS = \ -classic-display \ -cflags -short-paths \ @@ -46,26 +48,7 @@ OCAMLBUILD_OPTIONS = \ -cflags -principal \ -cflags -strict-formats \ -cflags -strict-sequence \ - -cflags -w,@5 \ - -cflags -w,@6 \ - -cflags -w,@8 \ - -cflags -w,@10 \ - -cflags -w,@11 \ - -cflags -w,@12 \ - -cflags -w,@18 \ - -cflags -w,@19 \ - -cflags -w,@20 \ - -cflags -w,@26 \ - -cflags -w,@29 \ - -cflags -w,@27 \ - -cflags -w,@32 \ - -cflags -w,@33 \ - -cflags -w,@34 \ - -cflags -w,@35 \ - -cflags -w,@37 \ - -cflags -w,@38 \ - -cflags -w,@39 \ - -cflags -w,-40..42 \ + -cflags -w,$(OCAML_FATAL_WARNINGS)-4-9-40-41-42-45-48-50 \ -tag-line "<*{clang/clang_ast_*,backend/jsonbug_*}>: warn(-27-32-35-39)" \ -tag-line "not <**/{config,iList,utils}.*>: open(Utils)" \ -pkgs atdgen,extlib,str,unix,yojson,zip @@ -199,6 +182,14 @@ byte: init $(INFERPRINT_ATDGEN_STUBS) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MI $(INFERJAVA_MAIN).byte \ $(INFERCLANG_MAIN).byte +test_build: init $(INFERPRINT_ATDGEN_STUBS) $(CLANG_ATDGEN_STUBS) $(INFER_CLANG_FCP_MIRRORED_FILES) + $(OCAMLBUILD) -build-dir $(TEST_BUILD_DIR) $(JAVA_OCAMLBUILD_OPTIONS) \ + -cflags -warn-error,$(OCAML_FATAL_WARNINGS) \ + $(INFERANALYZE_MAIN).byte \ + $(INFERPRINT_MAIN).byte \ + $(INFERJAVA_MAIN).byte \ + $(INFERCLANG_MAIN).byte + ifeq (@ENABLE_OCAML_ANNOT@,yes) java_annotations: build_java rsync -a --include '*/' --include '*.annot' --exclude '*' $(JAVA_BUILD_DIR)/ $(ANNOT_DIR)/ @@ -300,6 +291,9 @@ $(INFERLLVM_BIN): build_llvm $(CHECKCOPYRIGHT_BIN): build_checkCopyright $(COPY) $(SCRIPTS_BUILD_DIR)/$(CHECKCOPYRIGHT_MAIN).native $(CHECKCOPYRIGHT_BIN) +test_clean: + $(REMOVE_DIR) $(TEST_BUILD_DIR) + clean: $(REMOVE_DIR) $(BUILD_DIR) ifeq (@ENABLE_OCAML_ANNOT@,yes) diff --git a/scripts/test.sh b/scripts/test.sh index 1a53f4949..3aba94445 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -18,4 +18,4 @@ if [ "$1" == "--xml" ]; then XML="_xml" fi -make -C "$INFER_DIR" test$XML +make -j -C "$INFER_DIR" test_build test$XML