From fa4f9ef5f363a7dd80f9289fe025eef80cac0f6e Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Thu, 5 Mar 2020 06:14:34 -0800 Subject: [PATCH] [tests] remove genrule test Summary: This is fragile and redundant. Reviewed By: ezgicicek Differential Revision: D20249041 fbshipit-source-id: fc22bc0fb --- .gitignore | 1 - Makefile | 2 +- infer/tests/build_systems/genrule/.buckconfig | 9 --- .../tests/build_systems/genrule/.buckversion | 1 - infer/tests/build_systems/genrule/DEFS | 52 -------------- infer/tests/build_systems/genrule/Makefile | 27 ------- .../build_systems/genrule/annotations/BUCK | 7 -- .../genrule/annotations/Nullable.java | 9 --- infer/tests/build_systems/genrule/issues.exp | 10 --- .../tests/build_systems/genrule/module1/BUCK | 10 --- .../build_systems/genrule/module1/Class1.java | 41 ----------- .../module1/SkipImplementationClass1.java | 23 ------ .../tests/build_systems/genrule/module2/BUCK | 8 --- .../build_systems/genrule/module2/Class2.java | 70 ------------------- 14 files changed, 1 insertion(+), 269 deletions(-) delete mode 100644 infer/tests/build_systems/genrule/.buckconfig delete mode 120000 infer/tests/build_systems/genrule/.buckversion delete mode 100644 infer/tests/build_systems/genrule/DEFS delete mode 100644 infer/tests/build_systems/genrule/Makefile delete mode 100644 infer/tests/build_systems/genrule/annotations/BUCK delete mode 100644 infer/tests/build_systems/genrule/annotations/Nullable.java delete mode 100644 infer/tests/build_systems/genrule/issues.exp delete mode 100644 infer/tests/build_systems/genrule/module1/BUCK delete mode 100644 infer/tests/build_systems/genrule/module1/Class1.java delete mode 100644 infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java delete mode 100644 infer/tests/build_systems/genrule/module2/BUCK delete mode 100644 infer/tests/build_systems/genrule/module2/Class2.java diff --git a/.gitignore b/.gitignore index 1ff494e87..42089bca0 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,6 @@ duplicates.txt /infer/tests/build_systems/diff_*/src /infer/tests/build_systems/differential_*/**/*.class /infer/tests/build_systems/differential_*/**/Diff*.java -/infer/tests/build_systems/genrule/report.json /infer/tests/build_systems/incremental_analysis_remove_file/src /infer/tests/build_systems/incremental_analysis_cost_change/src /infer/tests/build_systems/incremental_analysis_add_procedure/src diff --git a/Makefile b/Makefile index 4823b3dbc..698d07f47 100644 --- a/Makefile +++ b/Makefile @@ -189,7 +189,7 @@ endif ifneq ($(BUCK),no) -BUILD_SYSTEMS_TESTS += genrule genrulecapture +BUILD_SYSTEMS_TESTS += genrulecapture endif ifneq ($(MVN),no) BUILD_SYSTEMS_TESTS += mvn diff --git a/infer/tests/build_systems/genrule/.buckconfig b/infer/tests/build_systems/genrule/.buckconfig deleted file mode 100644 index 250f76f47..000000000 --- a/infer/tests/build_systems/genrule/.buckconfig +++ /dev/null @@ -1,9 +0,0 @@ -[buildfile] - includes = //DEFS - -[project] - ignore = .git, .ml, .mli - -[java] - source_level = 8 - target_level = 8 \ No newline at end of file diff --git a/infer/tests/build_systems/genrule/.buckversion b/infer/tests/build_systems/genrule/.buckversion deleted file mode 120000 index 0a46cf46a..000000000 --- a/infer/tests/build_systems/genrule/.buckversion +++ /dev/null @@ -1 +0,0 @@ -../../../../.buckversion \ No newline at end of file diff --git a/infer/tests/build_systems/genrule/DEFS b/infer/tests/build_systems/genrule/DEFS deleted file mode 100644 index bebab3220..000000000 --- a/infer/tests/build_systems/genrule/DEFS +++ /dev/null @@ -1,52 +0,0 @@ -import os - -original_java_library = java_library -def java_library( - name, - srcs=[], - **kwargs - ): - - original_java_library( - name=name, - srcs=srcs, - **kwargs - ) - - create_infer_genrule(name, srcs) - -original_android_library = android_library -def android_library( - name, - srcs=[], - **kwargs - ): - - original_android_library( - name=name, - srcs=srcs, - **kwargs - ) - - create_infer_genrule(name, srcs) - -def create_infer_genrule( - name, - srcs - ): - genrule_name = name + '_infer' - genrule( - name = genrule_name, - srcs=srcs, - cmd = ' '.join([ - os.getenv('INFER_BIN', 'infer'), - '--genrule-mode', - '--project-root', os.getenv('PROJECT_ROOT', os.environ['PWD']), - '--eradicate-only', - '--results-dir', '$OUT', - '--classpath', '$(classpath :{})'.format(name), - '--sourcepath', '$SRCDIR', - '--generated-classes', '$(location :{})'.format(name), - ]), - out = 'infer_out', - ) diff --git a/infer/tests/build_systems/genrule/Makefile b/infer/tests/build_systems/genrule/Makefile deleted file mode 100644 index 8b43cb77e..000000000 --- a/infer/tests/build_systems/genrule/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -TESTS_DIR = ../.. - -BUCK_TARGET = //module2:module2 -INFER_TARGET = $(BUCK_TARGET)_infer -INFERPRINT_OPTIONS = --issues-tests -SOURCES = $(shell find . -name '*.java') -CLEAN_EXTRA = buck-out -INFER_OUT = buck-out/gen/module2/module2_infer/infer_out -JSON_REPORT = $(INFER_OUT)/report.json - -include $(TESTS_DIR)/java.make -include $(TESTS_DIR)/infer.make - -$(JSON_REPORT): $(JAVA_DEPS) $(SOURCES) $(MAKEFILE_LIST) - $(QUIET)$(REMOVE_DIR) buck-out && \ - $(call silent_on_success,Testing Buck genrule for Java integration,\ - INFER_BIN="$(INFER_BIN)" $(BUCK) build --no-cache $(INFER_TARGET)) - $(QUIET)touch $@ - -issues.exp.test$(TEST_SUFFIX): $(JSON_REPORT) $(INFER_BIN) - $(QUIET)$(INFER_BIN) report -q \ - $(INFERPRINT_OPTIONS) $@ --from-json-report $(JSON_REPORT) diff --git a/infer/tests/build_systems/genrule/annotations/BUCK b/infer/tests/build_systems/genrule/annotations/BUCK deleted file mode 100644 index bc0b50a7f..000000000 --- a/infer/tests/build_systems/genrule/annotations/BUCK +++ /dev/null @@ -1,7 +0,0 @@ -java_library( - name='annotations', - srcs=['Nullable.java'], - visibility=[ - 'PUBLIC' - ], -) diff --git a/infer/tests/build_systems/genrule/annotations/Nullable.java b/infer/tests/build_systems/genrule/annotations/Nullable.java deleted file mode 100644 index f87c223c5..000000000 --- a/infer/tests/build_systems/genrule/annotations/Nullable.java +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -package genrule.annotations; - -public @interface Nullable {} diff --git a/infer/tests/build_systems/genrule/issues.exp b/infer/tests/build_systems/genrule/issues.exp deleted file mode 100644 index 56a293eb3..000000000 --- a/infer/tests/build_systems/genrule/issues.exp +++ /dev/null @@ -1,10 +0,0 @@ -module2/Class2.java, genrule.module2.Class2$Sub.subtypingInconsistency(java.lang.Object):java.lang.Object, 0, ERADICATE_INCONSISTENT_SUBCLASS_PARAMETER_ANNOTATION, no_bucket, WARNING, [First parameter `object` of method `Class2$Sub.subtypingInconsistency(...)` is missing `@Nullable` declaration when overriding `Class1$Sub.subtypingInconsistency(...)`. The parent method declared it can handle `null` for this param, so the child should also declare that.] -module2/Class2.java, genrule.module2.Class2$Sub.subtypingInconsistency(java.lang.Object):java.lang.Object, 0, ERADICATE_INCONSISTENT_SUBCLASS_RETURN_ANNOTATION, no_bucket, WARNING, [Child method `Class2$Sub.subtypingInconsistency(...)` is not substitution-compatible with its parent: the return type is declared as nullable, but parent method `Class1$Sub.subtypingInconsistency(...)` is missing `@Nullable` declaration. Either mark the parent as `@Nullable` or ensure the child does not return `null`.] -module2/Class2.java, genrule.module2.Class2.dereferenceInterTargetField1Bad(genrule.module1.Class1):void, 0, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`class1.field1` is nullable and is not locally checked for null when calling `toString()`.] -module2/Class2.java, genrule.module2.Class2.dereferenceInterTargetField2Bad(genrule.module1.Class1):int, 0, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`class1.field2` is nullable and is not locally checked for null when accessing field `Class1.x`.] -module2/Class2.java, genrule.module2.Class2.dereferenceLocalNullableFieldBad():void, 0, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`Class2.field` is nullable and is not locally checked for null when calling `toString()`.] -module2/Class2.java, genrule.module2.Class2.followMethodDeclarationOnlyBad(genrule.module1.SkipImplementationClass1):void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`obj2` is nullable and is not locally checked for null when calling `toString()`: call to annotatedNullable() at line 39.] -module2/Class2.java, genrule.module2.Class2.interTargetAbstractNPEBad(genrule.module1.Class1):void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`obj` is nullable and is not locally checked for null when calling `toString()`: call to abstractMayReturnNull() at line 29.] -module2/Class2.java, genrule.module2.Class2.interTargetNPEBad():void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`obj` is nullable and is not locally checked for null when calling `toString()`: call to returnsNull() at line 24.] -module2/Class2.java, genrule.module2.Class2.interTargetNativeNPEBad(genrule.module1.Class1):void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [`obj` is nullable and is not locally checked for null when calling `toString()`: call to nativeMayReturnNull() at line 34.] -module2/Class2.java, genrule.module2.Class2.localNPE2Bad():void, 1, ERADICATE_NULLABLE_DEREFERENCE, no_bucket, WARNING, [NullPointerException will be thrown at this line! `obj` is `null` and is dereferenced via calling `toString()`: null constant at line 19.] diff --git a/infer/tests/build_systems/genrule/module1/BUCK b/infer/tests/build_systems/genrule/module1/BUCK deleted file mode 100644 index 4ac82ec7d..000000000 --- a/infer/tests/build_systems/genrule/module1/BUCK +++ /dev/null @@ -1,10 +0,0 @@ -java_library( - name='module1', - srcs=glob(["*.java"]), - deps=[ - '//annotations:annotations', - ], - visibility=[ - 'PUBLIC' - ], -) diff --git a/infer/tests/build_systems/genrule/module1/Class1.java b/infer/tests/build_systems/genrule/module1/Class1.java deleted file mode 100644 index 418840bc7..000000000 --- a/infer/tests/build_systems/genrule/module1/Class1.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package genrule.module1; - -import genrule.annotations.Nullable; - -public abstract class Class1 { - - public @Nullable Object field1; - - public int x; - public @Nullable Class1 field2; - - public static @Nullable String returnsNull() { - return null; - } - - void localNPE1() { - Object obj = null; - obj.toString(); - } - - public abstract @Nullable Object abstractMayReturnNull(); - - public native @Nullable Object nativeMayReturnNull(); - - public Object unannotatedReturnNull() { - return null; - } - - public static class Sub { - public Object subtypingInconsistency(@Nullable Object object) { - return new Object(); - } - } -} diff --git a/infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java b/infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java deleted file mode 100644 index d5b060418..000000000 --- a/infer/tests/build_systems/genrule/module1/SkipImplementationClass1.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// _SHOULD_SKIP_IMPLEMENTATION_ - -package genrule.module1; - -import genrule.annotations.Nullable; - -public class SkipImplementationClass1 { - - public @Nullable Object annotatedNullable() { - return new Object(); - } - - public Object notAnnotatedNullable() { - return null; - } -} diff --git a/infer/tests/build_systems/genrule/module2/BUCK b/infer/tests/build_systems/genrule/module2/BUCK deleted file mode 100644 index 33f3d881f..000000000 --- a/infer/tests/build_systems/genrule/module2/BUCK +++ /dev/null @@ -1,8 +0,0 @@ -java_library( - name='module2', - srcs=glob(["*.java"]), - deps=[ - '//module1:module1', - '//annotations:annotations', - ] -) diff --git a/infer/tests/build_systems/genrule/module2/Class2.java b/infer/tests/build_systems/genrule/module2/Class2.java deleted file mode 100644 index 013577507..000000000 --- a/infer/tests/build_systems/genrule/module2/Class2.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package genrule.module2; - -import genrule.annotations.Nullable; -import genrule.module1.Class1; -import genrule.module1.SkipImplementationClass1; - -public class Class2 { - - @Nullable Object field; - - void localNPE2Bad() { - Object obj = null; - obj.toString(); - } - - void interTargetNPEBad() { - Object obj = Class1.returnsNull(); - obj.toString(); - } - - void interTargetAbstractNPEBad(Class1 class1) { - Object obj = class1.abstractMayReturnNull(); - obj.toString(); - } - - void interTargetNativeNPEBad(Class1 class1) { - Object obj = class1.nativeMayReturnNull(); - obj.toString(); - } - - void followMethodDeclarationOnlyBad(SkipImplementationClass1 obj1) { - Object obj2 = obj1.annotatedNullable(); - obj2.toString(); - } - - void followMethodDeclarationOnlyOk(SkipImplementationClass1 obj1) { - Object obj2 = obj1.notAnnotatedNullable(); - obj2.toString(); - } - - void dereferenceLocalNullableFieldBad() { - field.toString(); - } - - void dereferenceInterTargetField1Bad(Class1 class1) { - class1.field1.toString(); - } - - int dereferenceInterTargetField2Bad(Class1 class1) { - return class1.field2.x; - } - - void dereferenceUnannotatedMethodReturningNullBad(Class1 class1) { - class1.unannotatedReturnNull().toString(); - } - - static class Sub extends Class1.Sub { - @Override - public @Nullable Object subtypingInconsistency(Object object) { - return null; - } - } -}