From de8356e4b06081e25cce1497bcb0ba56b92bb6ba Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Thu, 15 Dec 2016 09:02:24 -0800 Subject: [PATCH] [tests] move javac test to a Makefile Reviewed By: jberdine Differential Revision: D4329635 fbshipit-source-id: 143ea87 --- Makefile | 2 +- .../build_systems/build_integration_tests.py | 5 ++--- .../expected_outputs/javac_report.json | 7 ------- infer/tests/build_systems/javac/Makefile | 18 ++++++++++++++++++ infer/tests/build_systems/javac/issues.exp | 1 + infer/tests/javac.make | 5 ++++- 6 files changed, 26 insertions(+), 12 deletions(-) delete mode 100644 infer/tests/build_systems/expected_outputs/javac_report.json create mode 100644 infer/tests/build_systems/javac/Makefile create mode 100644 infer/tests/build_systems/javac/issues.exp diff --git a/Makefile b/Makefile index 361d9a419..3481fa750 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ endif BUILD_SYSTEMS_TESTS = \ assembly ck_analytics ck_imports clang_translation delete_results_dir fail_on_issue gradle \ - linters project_root_rel + javac 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 2166e97b8..f61484662 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 = [ - 'javac', 'locale', 'make', 'multiclang', @@ -316,7 +315,7 @@ def test(name, class BuildIntegrationTest(unittest.TestCase): - def test_javac_integration( + def _test_javac_integration( self, enabled=None, root=os.path.join(ROOT_DIR, 'examples'), @@ -437,7 +436,7 @@ class BuildIntegrationTest(unittest.TestCase): enabled=True, root=os.path.join(utf8_in_pwd_path, 'gradle'), report_fname='utf8_in_pwd_gradle_report.json') - self.test_javac_integration( + self._test_javac_integration( enabled=True, root=os.path.join(utf8_in_pwd_path), report_fname='utf8_in_pwd_javac_report.json') diff --git a/infer/tests/build_systems/expected_outputs/javac_report.json b/infer/tests/build_systems/expected_outputs/javac_report.json deleted file mode 100644 index 32cd14214..000000000 --- a/infer/tests/build_systems/expected_outputs/javac_report.json +++ /dev/null @@ -1,7 +0,0 @@ -[ - { - "bug_type": "NULL_DEREFERENCE", - "file": "Hello.java", - "procedure": "int Hello.test()" - } -] \ No newline at end of file diff --git a/infer/tests/build_systems/javac/Makefile b/infer/tests/build_systems/javac/Makefile new file mode 100644 index 000000000..69f293369 --- /dev/null +++ b/infer/tests/build_systems/javac/Makefile @@ -0,0 +1,18 @@ +# 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 +INFER_OPTIONS = +INFERPRINT_OPTIONS = --issues-tests + +PROJECT_ROOT = $(ROOT_DIR)/examples +SOURCES = $(PROJECT_ROOT)/Hello.java + +include $(TESTS_DIR)/javac.make diff --git a/infer/tests/build_systems/javac/issues.exp b/infer/tests/build_systems/javac/issues.exp new file mode 100644 index 000000000..d86a11a32 --- /dev/null +++ b/infer/tests/build_systems/javac/issues.exp @@ -0,0 +1 @@ +Hello.java, int Hello.test(), 2, NULL_DEREFERENCE, [start of procedure test()] diff --git a/infer/tests/javac.make b/infer/tests/javac.make index 1fc122a44..f02854e70 100644 --- a/infer/tests/javac.make +++ b/infer/tests/javac.make @@ -17,9 +17,12 @@ OBJECTS = $(patsubst %.java,%.class,$(SOURCES)) include $(TESTS_DIR)/java.make include $(TESTS_DIR)/base.make +PROJECT_ROOT ?= $(TESTS_DIR) + $(OBJECTS): $(SOURCES) javac -cp $(CLASSPATH) $(SOURCES) infer-out/report.json: $(JAVA_DEPS) $(SOURCES) $(call silent_on_success,\ - $(INFER_BIN) --project-root $(TESTS_DIR) --inferconfig-home . $(INFER_OPTIONS) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(SOURCES)) + $(INFER_BIN) -a $(ANALYZER) --inferconfig-home . --project-root $(PROJECT_ROOT) $(INFER_OPTIONS) -- \ + javac -cp $(CLASSPATH) $(SOURCES))