From bcac924e7fec1f72c6b91f52443b44fff9d9a37f Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 15 Dec 2016 10:08:30 -0800 Subject: [PATCH] register checkers in monocore mode Summary: Most of the diff adds a way to run an existing test with different infer options. Also, do not run the Python script when capturing "analyze". fixes https://github.com/facebook/infer/issues/518 Reviewed By: jberdine Differential Revision: D4333762 fbshipit-source-id: 642acff --- Makefile | 2 +- Makefile.config.in | 2 +- infer/src/backend/InferAnalyze.re | 1 + infer/src/backend/InferAnalyzeExe.re | 1 - infer/src/backend/infer.ml | 2 ++ infer/tests/base.make | 13 +++++++------ infer/tests/build_systems/j1/Makefile | 12 ++++++++++++ infer/tests/clang.make | 7 +++++-- 8 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 infer/tests/build_systems/j1/Makefile diff --git a/Makefile b/Makefile index 06e6d0ce5..7a053c9ec 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ endif BUILD_SYSTEMS_TESTS = \ assembly ck_analytics ck_imports clang_multiple_files clang_translation clang_unknown_ext \ - delete_results_dir fail_on_issue gradle javac linters make project_root_rel reactive \ + delete_results_dir fail_on_issue gradle j1 javac linters make project_root_rel reactive \ utf8_in_procname utf8_in_pwd waf ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant diff --git a/Makefile.config.in b/Makefile.config.in index b06b58d42..db341503c 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -125,5 +125,5 @@ CLANG_DEPS = $(addprefix $(PYTHON_LIB_DIR)/, \ JAVA_MODELS_JAR = $(LIB_DIR)/java/models.jar define silent_on_success - $(1) >/dev/null 2>/dev/null || ($(1) && exit 1) + $(1) >/dev/null 2>/dev/null || (echo $(1); $(1) && exit 1) endef diff --git a/infer/src/backend/InferAnalyze.re b/infer/src/backend/InferAnalyze.re index c1a5c2b1b..79e5b22ac 100644 --- a/infer/src/backend/InferAnalyze.re +++ b/infer/src/backend/InferAnalyze.re @@ -93,6 +93,7 @@ let print_stdout_legend () => { }; let main makefile => { + RegisterCheckers.register (); BuiltinDefn.init (); switch Config.modified_targets { | Some file => MergeCapture.modified_file file diff --git a/infer/src/backend/InferAnalyzeExe.re b/infer/src/backend/InferAnalyzeExe.re index c2a8b3139..82ba9a40e 100644 --- a/infer/src/backend/InferAnalyzeExe.re +++ b/infer/src/backend/InferAnalyzeExe.re @@ -47,6 +47,5 @@ let () = { Printexc.record_backtrace true }; print_prolog (); - RegisterCheckers.register (); InferAnalyze.main Config.makefile_cmdline }; diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index c5776619a..c23455c22 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -151,6 +151,8 @@ let capture_with_compilation_database db_files = let capture build_cmd = function | Analyze when not (List.is_empty !Config.clang_compilation_db_files) -> capture_with_compilation_database !Config.clang_compilation_db_files + | Analyze -> + () | Buck when Config.use_compilation_database <> None -> L.stdout "Capturing using Buck's compilation database...@\n"; let json_cdb = CaptureCompilationDatabase.get_compilation_database_files_buck () in diff --git a/infer/tests/base.make b/infer/tests/base.make index 7d39fa789..6121ab872 100644 --- a/infer/tests/base.make +++ b/infer/tests/base.make @@ -11,22 +11,23 @@ include $(ROOT_DIR)/Makefile.config default: compile -issues.exp.test: infer-out/report.json $(INFERPRINT_BIN) +issues.exp.test$(TEST_SUFFIX): infer-out$(TEST_SUFFIX)/report.json $(INFERPRINT_BIN) $(INFERPRINT_BIN) -q -a $(ANALYZER) $(INFERPRINT_OPTIONS) $@ --from-json-report $< .PHONY: compile compile: $(OBJECTS) .PHONY: analyze -analyze: infer-out/report.json +analyze: infer-out$(TEST_SUFFIX)/report.json .PHONY: print -print: issues.exp.test +print: issues.exp.test$(TEST_SUFFIX) .PHONY: test -test: issues.exp.test - diff -u issues.exp issues.exp.test +test: issues.exp.test$(TEST_SUFFIX) + diff -u issues.exp issues.exp.test$(TEST_SUFFIX) .PHONY: clean clean: - rm -rf codetoanalyze issues.exp.test infer-out $(OBJECTS) $(CLEAN_EXTRA) + $(REMOVE_DIR) codetoanalyze issues.exp.test$(TEST_SUFFIX) infer-out$(TEST_SUFFIX) \ + $(OBJECTS) $(CLEAN_EXTRA) diff --git a/infer/tests/build_systems/j1/Makefile b/infer/tests/build_systems/j1/Makefile new file mode 100644 index 000000000..7141223fe --- /dev/null +++ b/infer/tests/build_systems/j1/Makefile @@ -0,0 +1,12 @@ +# Copyright (c) 2016 - 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. + +default: compile + +.PHONY: print test clean +print test clean: + INFER_ARGS=-j^1 $(MAKE) -C ../../codetoanalyze/cpp/checkers TEST_SUFFIX=-j1 $@ diff --git a/infer/tests/clang.make b/infer/tests/clang.make index 33d11f1bd..0e61202ed 100644 --- a/infer/tests/clang.make +++ b/infer/tests/clang.make @@ -14,7 +14,10 @@ OBJECTS = $(foreach source,$(SOURCES),$(basename $(source)).o) include $(TESTS_DIR)/base.make include $(TESTS_DIR)/clang-base.make -infer-out/report.json: $(CLANG_DEPS) $(SOURCES) $(HEADERS) +infer-out$(TEST_SUFFIX)/report.json: $(CLANG_DEPS) $(SOURCES) $(HEADERS) $(call silent_on_success,\ - $(INFER_BIN) --check-duplicate-symbols $(INFER_OPTIONS) -a $(ANALYZER) -- clang $(CLANG_OPTIONS) $(SOURCES) 2>duplicates.txt) + $(INFER_BIN) --results-dir $(@D) --check-duplicate-symbols \ + $(INFER_OPTIONS) -a $(ANALYZER) -- \ + clang $(CLANG_OPTIONS) $(SOURCES) 2> \ + >(tee duplicates.txt)) grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0