diff --git a/Makefile b/Makefile index a57a1abe0..519932e04 100644 --- a/Makefile +++ b/Makefile @@ -93,7 +93,7 @@ ifneq ($(ANT),no) BUILD_SYSTEMS_TESTS += ant endif ifneq ($(BUCK),no) -BUILD_SYSTEMS_TESTS += buck genrule +BUILD_SYSTEMS_TESTS += buck genrule buck_javac_jar # Introduce the dependency only if the two tests are going to be built in parallel, so that they do # not run in parallel (otherwise Buck has a bad time). This works by checking if one of the main # testing targets was passed as a goal on the command line. diff --git a/infer/lib/python/inferlib/bucklib.py b/infer/lib/python/inferlib/bucklib.py index 9f58f6ba6..a1c124559 100644 --- a/infer/lib/python/inferlib/bucklib.py +++ b/infer/lib/python/inferlib/bucklib.py @@ -278,10 +278,13 @@ class Wrapper: else: self.timer.start('Running Buck ...') buck_config = [ - '--config', 'tools.javac=' + infer_script, '--config', 'client.id=infer.java', '--config', 'java.abi_generation_mode=class', '--config', 'infer.no_custom_javac=true', + '--config', 'tools.javac=' + infer_script, + # make sure the javac_jar option is disabled to + # avoid conficts with the javac option + '--config', 'tools.javac_jar=', ] buck_cmd = self.buck_cmd + buck_config subprocess.check_call(buck_cmd) diff --git a/infer/tests/build_systems/buck_javac_jar/.buckconfig b/infer/tests/build_systems/buck_javac_jar/.buckconfig new file mode 100644 index 000000000..8f67ce98e --- /dev/null +++ b/infer/tests/build_systems/buck_javac_jar/.buckconfig @@ -0,0 +1,2 @@ +[tools] + javac_jar = /dev/null diff --git a/infer/tests/build_systems/buck_javac_jar/Makefile b/infer/tests/build_systems/buck_javac_jar/Makefile new file mode 100644 index 000000000..1824d6e06 --- /dev/null +++ b/infer/tests/build_systems/buck_javac_jar/Makefile @@ -0,0 +1,27 @@ +# Copyright (c) 2018-present, Facebook, Inc. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +TESTS_DIR = ../.. +ROOT_DIR = $(TESTS_DIR)/../.. + +ANALYZER = checkers +TARGET = //src:target +SOURCES = src/UsingJavacJar.java +OBJECTS = buck-out/gen/src/lib__target__output/target.jar +BUCKCONFIG = .buckconfig +INFER_OPTIONS = --eradicate-only +INFERPRINT_OPTIONS = --issues-tests +CLEAN_EXTRA = buck-out + +include $(TESTS_DIR)/infer.make + +$(OBJECTS): $(SOURCES) $(BUCKCONFIG) + $(BUCK) build --config tools.javac_jar= $(TARGET) + +infer-out/report.json: $(SOURCES) $(BUCKCONFIG) + $(REMOVE_DIR) buck-out && \ + $(call silent_on_success,Testing Buck Java integration with javac_jar,\ + INFER_BIN=$(INFER_BIN) \ + $(INFER_BIN) $(INFER_OPTIONS) -- $(BUCK) build $(TARGET)) diff --git a/infer/tests/build_systems/buck_javac_jar/issues.exp b/infer/tests/build_systems/buck_javac_jar/issues.exp new file mode 100644 index 000000000..b12a1f123 --- /dev/null +++ b/infer/tests/build_systems/buck_javac_jar/issues.exp @@ -0,0 +1 @@ +src/UsingJavacJar.java, Object UsingJavacJar.foo(), 0, ERADICATE_RETURN_NOT_NULLABLE, no_bucket, WARNING, [origin,Method `foo()` may return null but it is not annotated with `@Nullable`. (Origin: null constant at line 10)] diff --git a/infer/tests/build_systems/buck_javac_jar/src/BUCK b/infer/tests/build_systems/buck_javac_jar/src/BUCK new file mode 100644 index 000000000..b40bf5cc9 --- /dev/null +++ b/infer/tests/build_systems/buck_javac_jar/src/BUCK @@ -0,0 +1,4 @@ +java_library( + name = 'target', + srcs = glob(['*.java']), +) diff --git a/infer/tests/build_systems/buck_javac_jar/src/UsingJavacJar.java b/infer/tests/build_systems/buck_javac_jar/src/UsingJavacJar.java new file mode 100644 index 000000000..79fa040c9 --- /dev/null +++ b/infer/tests/build_systems/buck_javac_jar/src/UsingJavacJar.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +public class UsingJavacJar { + + Object foo() { + return null; + } +}