diff --git a/Makefile b/Makefile index dc066a9a7..361d9a419 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ ifeq ($(IS_FACEBOOK_TREE),yes) endif BUILD_SYSTEMS_TESTS = \ - assembly ck_analytics ck_imports clang_translation delete_results_dir fail_on_issue linters \ - project_root_rel + assembly ck_analytics ck_imports clang_translation delete_results_dir fail_on_issue gradle \ + 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 5ba4cc3ff..2166e97b8 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 = [ - 'gradle', 'javac', 'locale', 'make', @@ -328,7 +327,7 @@ class BuildIntegrationTest(unittest.TestCase): enabled=enabled, report_fname=report_fname) - def test_gradle_integration( + def _test_gradle_integration( self, enabled=None, root=os.path.join(ROOT_DIR, 'examples', 'java_hello'), @@ -434,7 +433,7 @@ class BuildIntegrationTest(unittest.TestCase): enabled=True, root=os.path.join(utf8_in_pwd_path, 'cmake'), report_fname='utf8_in_pwd_cmake_report.json') - self.test_gradle_integration( + self._test_gradle_integration( enabled=True, root=os.path.join(utf8_in_pwd_path, 'gradle'), report_fname='utf8_in_pwd_gradle_report.json') diff --git a/infer/tests/build_systems/expected_outputs/gradle_report.json b/infer/tests/build_systems/expected_outputs/gradle_report.json deleted file mode 100644 index b3f642cea..000000000 --- a/infer/tests/build_systems/expected_outputs/gradle_report.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "bug_type": "NULL_DEREFERENCE", - "file": "Hello.java", - "procedure": "void Hello.mayCauseNPE()" - }, - { - "bug_type": "RESOURCE_LEAK", - "file": "Hello.java", - "procedure": "void Hello.mayLeakResource()" - }, - { - "bug_type": "RESOURCE_LEAK", - "file": "Hello.java", - "procedure": "void Hello.twoResources()" - } -] \ No newline at end of file diff --git a/infer/tests/build_systems/gradle/Makefile b/infer/tests/build_systems/gradle/Makefile new file mode 100644 index 000000000..4ea92eed4 --- /dev/null +++ b/infer/tests/build_systems/gradle/Makefile @@ -0,0 +1,26 @@ +# 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 = ../.. +ROOT_DIR = $(TESTS_DIR)/../.. + +ANALYZER = infer +SOURCES_DIR = $(ROOT_DIR)/examples/java_hello +SOURCES = $(wildcard $(SOURCES_DIR)/*.java) +# no objects since we only run a mock gradle that cannot compile Java sources +OBJECTS = +INFERPRINT_OPTIONS = --issues-tests + +include $(TESTS_DIR)/java.make +include $(TESTS_DIR)/base.make + +infer-out/report.json: $(JAVA_DEPS) $(SOURCES) +# mock version of gradle + PATH=$(CURDIR)/../mock:"$$PATH"; \ + cd $(SOURCES_DIR) && \ + $(call silent_on_success,\ + $(INFER_BIN) -a $(ANALYZER) --results-dir $(CURDIR)/infer-out -- gradle build) diff --git a/infer/tests/build_systems/gradle/issues.exp b/infer/tests/build_systems/gradle/issues.exp new file mode 100644 index 000000000..b98fd771a --- /dev/null +++ b/infer/tests/build_systems/gradle/issues.exp @@ -0,0 +1,3 @@ +Hello.java, void Hello.mayCauseNPE(), 4, NULL_DEREFERENCE, [start of procedure mayCauseNPE(),start of procedure mayReturnNull(...),Taking false branch,return from a call to Pointers$A Pointers.mayReturnNull(int)] +Hello.java, void Hello.mayLeakResource(), 7, RESOURCE_LEAK, [start of procedure mayLeakResource(),start of procedure allocateResource(),return from a call to FileOutputStream Resources.allocateResource(),Taking false branch] +Hello.java, void Hello.twoResources(), 11, RESOURCE_LEAK, [start of procedure twoResources(),exception java.io.IOException,Switch condition is true. Entering switch case,Taking true branch,exception java.io.IOException]