[tests] port gradle test to a Makefile

Reviewed By: jberdine

Differential Revision: D4329630

fbshipit-source-id: ae49e3e
master
Jules Villard 8 years ago committed by Facebook Github Bot
parent ebb75d6171
commit 5ffd9e3a7b

@ -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

@ -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')

@ -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()"
}
]

@ -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)

@ -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]
Loading…
Cancel
Save