diff --git a/.gitignore b/.gitignore index 795cf7056..4409230d9 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ duplicates.txt *.ast.sh *.ast.bdump *.ast.biniou +/infer/tests/build_systems/buck_flavors_diff/src/hello.c /infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/libs/ /infer/tests/build_systems/codetoanalyze/ndk-build/hello_app/obj/ /infer/tests/build_systems/codetoanalyze/utf8_*n_pwd @@ -38,8 +39,6 @@ duplicates.txt /infer/tests/build_systems/codetoanalyze/xcodebuild/simple_app/build/ /infer/tests/build_systems/differential_*/**/*.class /infer/tests/build_systems/differential_*/**/Diff*.java -/infer/tests/build_systems/differential_*/infer-current -/infer/tests/build_systems/differential_*/infer-previous /infer/tests/build_systems/diff/src /infer/tests/build_systems/diff_*/src /infer/tests/build_systems/buck_flavors_deterministic/capture_hash-*.sha diff --git a/infer/src/backend/infer.ml b/infer/src/backend/infer.ml index 17bd7577b..10e13e5ea 100644 --- a/infer/src/backend/infer.ml +++ b/infer/src/backend/infer.ml @@ -35,11 +35,14 @@ let setup () = ResultsDir.remove_results_dir () ; ResultsDir.create_results_dir () | Capture | Compile | Run -> let driver_mode = Lazy.force Driver.mode_from_command_line in - if not - ( Driver.(equal_mode driver_mode Analyze) - || - Config.(buck || continue_capture || infer_is_clang || infer_is_javac || reactive_mode) - ) + if Config.( + (* In Buck mode, delete infer-out directories inside buck-out to start fresh and to + avoid getting errors because some of their contents is missing (removed by + [Driver.clean_results_dir ()]). *) + buck && flavors) + || not + ( Driver.(equal_mode driver_mode Analyze) + || Config.(continue_capture || infer_is_clang || infer_is_javac || reactive_mode) ) then ResultsDir.remove_results_dir () ; ResultsDir.create_results_dir () | Explore -> diff --git a/infer/tests/build_systems/buck_flavors_diff/.buckconfig b/infer/tests/build_systems/buck_flavors_diff/.buckconfig new file mode 100644 index 000000000..e69de29bb diff --git a/infer/tests/build_systems/buck_flavors_diff/.inferconfig b/infer/tests/build_systems/buck_flavors_diff/.inferconfig new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/infer/tests/build_systems/buck_flavors_diff/.inferconfig @@ -0,0 +1 @@ +{} diff --git a/infer/tests/build_systems/buck_flavors_diff/Makefile b/infer/tests/build_systems/buck_flavors_diff/Makefile new file mode 100644 index 000000000..074f952e5 --- /dev/null +++ b/infer/tests/build_systems/buck_flavors_diff/Makefile @@ -0,0 +1,55 @@ +# 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. + +TESTS_DIR = ../.. +INFER_OUT = infer-out +include $(TESTS_DIR)/differential.make + +DIFFERENTIAL_ARGS = --differential-filter-files changed_files.txt + +include ../../differential.make + +BUCK_TARGET = //src:hello +INFER_OPTIONS = $(DIFFERENTIAL_ARGS) --flavors --reactive --debug-exceptions +SRC_DIR = $(CURDIR)/../codetoanalyze + +.PHONY: compare_reports +compare_reports: current.exp.test previous.exp.test + $(QUIET)$(call check_no_diff,current.exp,current.exp.test) + $(QUIET)$(call check_no_diff,previous.exp,previous.exp.test) + +.PHONY: replace_reports +replace_reports: current.exp.test previous.exp.test + $(COPY) current.exp.test current.exp + $(COPY) previous.exp.test previous.exp + +current.exp.test: $(CURRENT_REPORT) + $(QUIET)$(INFER_BIN) report -o $( + +void test_hello2() { + int* s = NULL; + *s = 42; +} diff --git a/infer/tests/build_systems/buck_flavors_run/Makefile b/infer/tests/build_systems/buck_flavors_run/Makefile index eeca7fb68..8ed53f89b 100644 --- a/infer/tests/build_systems/buck_flavors_run/Makefile +++ b/infer/tests/build_systems/buck_flavors_run/Makefile @@ -10,7 +10,7 @@ ROOT_DIR = $(TESTS_DIR)/../.. ANALYZER = checkers BUCK_TARGET = //src:hello -SOURCES = $(wildcard src/hello.c) +SOURCES = src/hello.c src/hello2.c OBJECTS = buck-out/gen/src/hello\#compile-hello.c.o1f717d69,default/hello.c.o INFER_OPTIONS = --report-custom-error --developer-mode --project-root $(TESTS_DIR) INFERPRINT_OPTIONS = --project-root $(TESTS_DIR) --issues-tests @@ -18,7 +18,7 @@ CLEAN_EXTRA = buck-out include $(TESTS_DIR)/infer.make -$(OBJECTS): $(JAVA_SOURCE_FILES) +$(OBJECTS): $(SOURCES) $(QUIET)$(call silent_on_success,Compiling Buck flavors tests,\ NO_BUCKD=1 $(BUCK) build --no-cache $(BUCK_TARGET)) diff --git a/infer/tests/differential.make b/infer/tests/differential.make index ce7e8c4fc..fc9aac18e 100644 --- a/infer/tests/differential.make +++ b/infer/tests/differential.make @@ -15,8 +15,8 @@ EXPECTED_TEST_OUTPUT = introduced.exp.test INFERPRINT_ISSUES_FIELDS = \ "bug_type,file,procedure,line_offset,procedure_id,procedure_id_without_crc" -CURRENT_DIR = infer-current -PREVIOUS_DIR = infer-previous +CURRENT_DIR = infer-out-current +PREVIOUS_DIR = infer-out-previous CURRENT_REPORT = $(CURRENT_DIR)/report.json PREVIOUS_REPORT = $(PREVIOUS_DIR)/report.json