From 0aa93c97bd13e0ddef31c49d3068c40cd3109eb9 Mon Sep 17 00:00:00 2001 From: Andrzej Kotulski Date: Tue, 29 Nov 2016 05:35:10 -0800 Subject: [PATCH] [tests] Extend compilation database tests to handle multiple scenarios Summary: Add new integration test for compilation databse integration. Because new test needs another flags in infer invocation, I created one directory per test. Reviewed By: jberdine Differential Revision: D4231659 fbshipit-source-id: 81bb355 --- .../clang_compilation_db/Makefile | 20 ++++++++++++++++--- .../clang_compilation_db/issues.exp | 3 +++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/infer/tests/build_systems/clang_compilation_db/Makefile b/infer/tests/build_systems/clang_compilation_db/Makefile index e9ef92a81..943b7b5b5 100644 --- a/infer/tests/build_systems/clang_compilation_db/Makefile +++ b/infer/tests/build_systems/clang_compilation_db/Makefile @@ -12,7 +12,7 @@ CMAKE_BUILD_DIR = $(CMAKE_DIR)/_build ANALYZER = infer CLEAN_EXTRA = $(CMAKE_BUILD_DIR) -INFER_OPTIONS = --report-custom-error --developer-mode --project-root $(CMAKE_DIR) --changed-files-index $(CMAKE_DIR)/index.txt +INFER_OPTIONS = --report-custom-error --developer-mode --project-root $(CMAKE_DIR) SOURCES = $(CMAKE_DIR)/hello.cpp OBJECTS = $(CMAKE_BUILD_DIR)/compile_commands.json INFERPRINT_OPTIONS = --issues-tests @@ -26,6 +26,20 @@ $(CMAKE_BUILD_DIR)/compile_commands.json: $(SOURCES) $(CMAKE_DIR)/CMakeLists.txt cd $(CMAKE_BUILD_DIR) && \ $(CMAKE) -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. -infer-out/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(INFER_BIN) $(SOURCES) +infer-out/report.json: + # make this target empty - since this test defines issues.exp.test directly + +infer-out-with-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(INFER_BIN) $(SOURCES) + $(call silent_on_success,\ + $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -o infer-out-with-index --changed-files-index $(CMAKE_DIR)/index.txt -- clang-compilation-database $<) + +infer-out-no-index/report.json: $(CMAKE_BUILD_DIR)/compile_commands.json $(INFER_BIN) $(SOURCES) $(call silent_on_success,\ - $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -- clang-compilation-database $<) + $(INFER_BIN) -a $(ANALYZER) $(INFER_OPTIONS) -o infer-out-no-index -- clang-compilation-database $<) + +issues.exp.test: infer-out-with-index/report.json infer-out-no-index/report.json + $(INFERPRINT_BIN) -q -a $(ANALYZER) $(INFERPRINT_OPTIONS) $@.with-index \ + --from-json-report infer-out-with-index/report.json + $(INFERPRINT_BIN) -q -a $(ANALYZER) $(INFERPRINT_OPTIONS) $@.no-index \ + --from-json-report infer-out-no-index/report.json + cat $@.with-index $@.no-index > $@ diff --git a/infer/tests/build_systems/clang_compilation_db/issues.exp b/infer/tests/build_systems/clang_compilation_db/issues.exp index 8c6294f0b..fbbf90b0e 100644 --- a/infer/tests/build_systems/clang_compilation_db/issues.exp +++ b/infer/tests/build_systems/clang_compilation_db/issues.exp @@ -1,2 +1,5 @@ hello.cpp, test0, 2, NULL_DEREFERENCE, [start of procedure test0()] hello.cpp, test1, 2, NULL_DEREFERENCE, [start of procedure test1(),start of procedure deref1()] +hello.cpp, test0, 2, NULL_DEREFERENCE, [start of procedure test0()] +hello.cpp, test1, 2, NULL_DEREFERENCE, [start of procedure test1(),start of procedure deref1()] +hello.cpp, test2, 2, NULL_DEREFERENCE, [start of procedure test2(),start of procedure deref2()]