diff --git a/Makefile b/Makefile index 4720d7c41..dc066a9a7 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ ifeq ($(IS_FACEBOOK_TREE),yes) endif BUILD_SYSTEMS_TESTS = \ - assembly ck_analytics ck_imports clang_translation delete_results_dir linters project_root_rel + assembly ck_analytics ck_imports clang_translation delete_results_dir fail_on_issue linters \ + project_root_rel ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant endif diff --git a/infer/tests/build_systems/build_integration_tests.py b/infer/tests/build_systems/build_integration_tests.py index 2bfbe0302..5ba4cc3ff 100755 --- a/infer/tests/build_systems/build_integration_tests.py +++ b/infer/tests/build_systems/build_integration_tests.py @@ -61,7 +61,6 @@ CODETOANALYZE_DIR = os.path.join(SCRIPT_DIR, 'codetoanalyze') EXPECTED_OUTPUTS_DIR = os.path.join(SCRIPT_DIR, 'expected_outputs') ALL_TESTS = [ - 'fail', 'gradle', 'javac', 'locale', @@ -472,13 +471,6 @@ class BuildIntegrationTest(unittest.TestCase): {'compile': ['analyze'], 'infer_args': ['--reactive']}]) - def test_fail_on_issue(self): - test('fail', '--fail-on-issue flag', - CODETOANALYZE_DIR, - [{'compile': ['clang', '-c', 'hello.c'], - 'infer_args': ['--fail-on-issue']}], - should_fail=2) - def test_pmd_xml_output(self): def pmd_check(infer_out): assert os.path.exists(os.path.join(infer_out, 'report.xml')) diff --git a/infer/tests/build_systems/expected_outputs/fail_report.json b/infer/tests/build_systems/expected_outputs/fail_report.json deleted file mode 100644 index a6ed10eff..000000000 --- a/infer/tests/build_systems/expected_outputs/fail_report.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "bug_type": "NULL_DEREFERENCE", - "file": "hello.c", - "procedure": "test" - } -] \ No newline at end of file diff --git a/infer/tests/build_systems/fail_on_issue/Makefile b/infer/tests/build_systems/fail_on_issue/Makefile new file mode 100644 index 000000000..921a37f60 --- /dev/null +++ b/infer/tests/build_systems/fail_on_issue/Makefile @@ -0,0 +1,44 @@ +# 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. + +TESTS_DIR = ../.. + +ANALYZER = infer + +CODETOANALYZE_DIR = ../codetoanalyze + +CLANG_OPTIONS = -c +INFER_OPTIONS = --project-root $(CODETOANALYZE_DIR) --fail-on-issue +INFERPRINT_OPTIONS = --issues-tests + +SOURCES = $(CODETOANALYZE_DIR)/hello.c +OBJECTS = $(foreach source,$(SOURCES),$(basename $(source)).o) + +ROOT_DIR = $(TESTS_DIR)/../.. + +include $(ROOT_DIR)/Makefile.config + +default: compile + +issues.exp.test: $(CLANG_DEPS) $(SOURCES) + $(call silent_on_success,\ + ($(INFER_BIN) --fail-on-issue -- clang $(CLANG_OPTIONS) $(SOURCES); \ + echo "infer exit code: $$?" > $@)) + +.PHONY: compile +compile: $(OBJECTS) + +.PHONY: print +print: issues.exp.test + +.PHONY: test +test: issues.exp.test + diff -u issues.exp issues.exp.test + +.PHONY: clean +clean: + rm -rf issues.exp.test infer-out $(OBJECTS) diff --git a/infer/tests/build_systems/fail_on_issue/issues.exp b/infer/tests/build_systems/fail_on_issue/issues.exp new file mode 100644 index 000000000..b90f8c3ed --- /dev/null +++ b/infer/tests/build_systems/fail_on_issue/issues.exp @@ -0,0 +1 @@ +infer exit code: 2