From 257f4976f07124ddfed1267f2f49d44ba3fcb053 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Tue, 30 Aug 2016 23:56:33 -0700 Subject: [PATCH] Convert java tracing tests to new direct format. Reviewed By: jeremydubreil Differential Revision: D3791189 fbshipit-source-id: ce0b7d6 --- .buckconfig | 2 +- Makefile | 5 +- infer/tests/codetoanalyze/java/infer/BUCK | 12 +--- .../codetoanalyze/java/tracing/.inferconfig | 25 +++++++ ...ArrayIndexOutOfBoundsExceptionExample.java | 10 +-- .../java/tracing/ArrayOutOfBounds.java | 1 + infer/tests/codetoanalyze/java/tracing/BUCK | 42 ------------ .../tracing/ClassCastExceptionExample.java | 8 +-- .../java/tracing/ClassCastExceptions.java | 1 + .../tracing/CloseableAsResourceExample.java | 1 + .../tracing/LazyDynamicDispatchExample.java | 12 ++-- .../LocallyDefinedExceptionExample.java | 6 +- .../tests/codetoanalyze/java/tracing/Makefile | 42 ++++++++++++ .../java/tracing/NeverNullSource.java | 1 + .../tracing/NullPointerExceptionExample.java | 4 +- .../java/tracing/NullPointerExceptions.java | 1 + .../java/tracing/ReportOnMainExample.java | 2 +- .../java/tracing/SkippedSourceFile.java | 1 + .../java/tracing/SomeLibrary.java | 1 + infer/tests/codetoanalyze/java/tracing/T.java | 18 +---- .../tests/codetoanalyze/java/tracing/T2.java | 17 +++++ .../tracing/UnavoidableExceptionExample.java | 8 +-- .../codetoanalyze/java/tracing/Utils.java | 1 + .../codetoanalyze/java/tracing/issues.exp | 57 ++++++++++++++++ infer/tests/endtoend/BUCK | 3 - .../ArrayIndexOutOfBoundsExceptionTest.java | 56 ---------------- infer/tests/endtoend/java/comparison/BUCK | 16 ----- .../comparison/ClassCastExceptionTest.java | 59 ---------------- .../comparison/NullPointerExceptionTest.java | 67 ------------------- infer/tests/endtoend/java/infer/BUCK | 1 + .../ArrayIndexOutOfBoundsExceptionTest.java | 61 ----------------- infer/tests/endtoend/java/tracing/BUCK | 16 ----- .../java/tracing/ClassCastExceptionTest.java | 56 ---------------- .../java/tracing/LazyDynamicDispatchTest.java | 59 ---------------- .../tracing/LocallyDefinedExceptionTest.java | 58 ---------------- .../tracing/NullPointerExceptionTest.java | 62 ----------------- .../java/tracing/ReportOnMainTest.java | 58 ---------------- .../tracing/UnavoidableExceptionTest.java | 60 ----------------- 38 files changed, 182 insertions(+), 728 deletions(-) create mode 100644 infer/tests/codetoanalyze/java/tracing/.inferconfig create mode 120000 infer/tests/codetoanalyze/java/tracing/ArrayOutOfBounds.java delete mode 100644 infer/tests/codetoanalyze/java/tracing/BUCK create mode 120000 infer/tests/codetoanalyze/java/tracing/ClassCastExceptions.java create mode 120000 infer/tests/codetoanalyze/java/tracing/CloseableAsResourceExample.java create mode 100644 infer/tests/codetoanalyze/java/tracing/Makefile create mode 120000 infer/tests/codetoanalyze/java/tracing/NeverNullSource.java create mode 120000 infer/tests/codetoanalyze/java/tracing/NullPointerExceptions.java create mode 120000 infer/tests/codetoanalyze/java/tracing/SkippedSourceFile.java create mode 120000 infer/tests/codetoanalyze/java/tracing/SomeLibrary.java mode change 100644 => 120000 infer/tests/codetoanalyze/java/tracing/T.java create mode 100644 infer/tests/codetoanalyze/java/tracing/T2.java create mode 120000 infer/tests/codetoanalyze/java/tracing/Utils.java create mode 100644 infer/tests/codetoanalyze/java/tracing/issues.exp delete mode 100644 infer/tests/endtoend/java/comparison/ArrayIndexOutOfBoundsExceptionTest.java delete mode 100644 infer/tests/endtoend/java/comparison/BUCK delete mode 100644 infer/tests/endtoend/java/comparison/ClassCastExceptionTest.java delete mode 100644 infer/tests/endtoend/java/comparison/NullPointerExceptionTest.java delete mode 100644 infer/tests/endtoend/java/tracing/ArrayIndexOutOfBoundsExceptionTest.java delete mode 100644 infer/tests/endtoend/java/tracing/BUCK delete mode 100644 infer/tests/endtoend/java/tracing/ClassCastExceptionTest.java delete mode 100644 infer/tests/endtoend/java/tracing/LazyDynamicDispatchTest.java delete mode 100644 infer/tests/endtoend/java/tracing/LocallyDefinedExceptionTest.java delete mode 100644 infer/tests/endtoend/java/tracing/NullPointerExceptionTest.java delete mode 100644 infer/tests/endtoend/java/tracing/ReportOnMainTest.java delete mode 100644 infer/tests/endtoend/java/tracing/UnavoidableExceptionTest.java diff --git a/.buckconfig b/.buckconfig index 866bf4653..df24b7af3 100644 --- a/.buckconfig +++ b/.buckconfig @@ -16,8 +16,8 @@ java_libraries = //dependencies/java:java_libraries +# TODO: this line exists only to support buck integration in infer/tests/build_systems/build_integration_tests.py infer = //infer/tests/endtoend/java/infer:infer - tracing = //infer/tests/endtoend/java/tracing:tracing linters = //infer/tests/endtoend:linters componentkit = //infer/tests/endtoend:componentkit diff --git a/Makefile b/Makefile index 11fb8ca19..68e0c8b1a 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ TARGETS_TO_TEST += c cpp endif ifeq ($(BUILD_JAVA_ANALYZERS),yes) TARGETS_TO_TEST += java -DIRECT_TESTS += java_checkers_test java_eradicate_test java_infer_test +DIRECT_TESTS += java_checkers_test java_eradicate_test java_infer_test java_tracing_test endif ifneq ($(XCODE_SELECT),no) TARGETS_TO_TEST += objc objcpp @@ -106,6 +106,9 @@ java_eradicate_test: java_infer_test: make -C ./infer/tests/codetoanalyze/java/infer test +java_tracing_test: + make -C ./infer/tests/codetoanalyze/java/tracing test + buck_test: infer make $(DIRECT_TESTS) diff --git a/infer/tests/codetoanalyze/java/infer/BUCK b/infer/tests/codetoanalyze/java/infer/BUCK index 388a14acf..0ad06f27c 100644 --- a/infer/tests/codetoanalyze/java/infer/BUCK +++ b/infer/tests/codetoanalyze/java/infer/BUCK @@ -1,3 +1,4 @@ +# TODO: this file exists only to support buck integration in infer/tests/build_systems/build_integration_tests.py sources = glob(['**/*.java']) dependencies = [ @@ -47,14 +48,3 @@ genrule( 'PUBLIC', ], ) - -genrule( - name = 'tracing', - out = 'comparison_report.csv', - cmd = analysis_cmd('tracing'), - deps = dependencies + [':infer'], - srcs = sources, - visibility = [ - 'PUBLIC', - ], -) diff --git a/infer/tests/codetoanalyze/java/tracing/.inferconfig b/infer/tests/codetoanalyze/java/tracing/.inferconfig new file mode 100644 index 000000000..afe8db3e3 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/.inferconfig @@ -0,0 +1,25 @@ +{ + "never_returning_null": [ + { + "language": "Java", + "source_contains": "_AUTOMATICALLY_GENERATED_" + }, + { + "language": "Java", + "class": "codetoanalyze.java.infer.SomeLibrary", + "method": "get" + } + ], + "infer-blacklist-files-containing": [ + "@generated" + ], + "enable_checks": [ + "UNSAFE_GUARDED_BY_ACCESS" + ], + "skip_translation": [ + { + "language": "Java", + "source_contains": "_SHOULD_BE_SKIPPED_" + } + ] +} diff --git a/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java index ba8cb4412..d8fb96bcd 100644 --- a/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java @@ -13,14 +13,14 @@ import com.facebook.infer.annotation.Verify; public class ArrayIndexOutOfBoundsExceptionExample { - void callMethodFromArray(T[] array, int index) { + void callMethodFromArray(T2[] array, int index) { if (array[index] != null) { array[index].f(); } } @Verify - public void missingCheckOnIndex(T[] array, int index) { + public void missingCheckOnIndex(T2[] array, int index) { if (array != null) { if (index < array.length) { callMethodFromArray(array, index); @@ -29,17 +29,17 @@ public class ArrayIndexOutOfBoundsExceptionExample { } void callOutOfBound() { - T[] array = new T[42]; + T2[] array = new T2[42]; callMethodFromArray(array, -5); } - void withFixedIndex(T[] array) { + void withFixedIndex(T2[] array) { int index = 9; callMethodFromArray(array, index); } void arrayIndexOutOfBoundsInCallee() { - T[] array = new T[8]; + T2[] array = new T2[8]; withFixedIndex(array); } diff --git a/infer/tests/codetoanalyze/java/tracing/ArrayOutOfBounds.java b/infer/tests/codetoanalyze/java/tracing/ArrayOutOfBounds.java new file mode 120000 index 000000000..4834b4d54 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/ArrayOutOfBounds.java @@ -0,0 +1 @@ +../infer/ArrayOutOfBounds.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/BUCK b/infer/tests/codetoanalyze/java/tracing/BUCK deleted file mode 100644 index 45ee94071..000000000 --- a/infer/tests/codetoanalyze/java/tracing/BUCK +++ /dev/null @@ -1,42 +0,0 @@ -sources = glob(['**/*.java']) - -dependencies = [ - '//infer/annotations:annotations', -] - -java_library( - name = 'tracing', - srcs = sources, - deps = dependencies, - visibility = [ - 'PUBLIC' - ] -) - -out = 'out' -clean_cmd = ' '.join(['rm', '-rf', out]) -classpath = ':'.join([('$(classpath ' + path + ')') for path in dependencies]) -infer_cmd = ' '.join([ - 'infer', - '--no-progress-bar', - '--absolute-paths', - '-o', out, - '-a', 'tracing', - '--', - 'javac', - '-cp', classpath, - '$SRCS', -]) -copy_cmd = ' '.join(['cp', out + '/report.csv', '$OUT']) -command = ' && '.join([clean_cmd, infer_cmd, copy_cmd]) - -genrule( - name = 'analyze', - srcs = sources, - out = 'report.csv', - cmd = command, - deps = dependencies + [':tracing'], - visibility = [ - 'PUBLIC', - ] -) diff --git a/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java index 665e6563a..4a40c3193 100644 --- a/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java @@ -11,21 +11,21 @@ package codetoanalyze.java.tracing; import com.facebook.infer.annotation.Verify; -class S extends T {} +class S extends T2 {} public class ClassCastExceptionExample { - S cast(T t) { + S cast(T2 t) { return (S) t; } void foo() { - T t = new T(); + T2 t = new T2(); S s = cast(t); s.toString(); } - T m; + T2 m; @Verify public S bar(int x) { diff --git a/infer/tests/codetoanalyze/java/tracing/ClassCastExceptions.java b/infer/tests/codetoanalyze/java/tracing/ClassCastExceptions.java new file mode 120000 index 000000000..d3bc93083 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/ClassCastExceptions.java @@ -0,0 +1 @@ +../infer/ClassCastExceptions.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/CloseableAsResourceExample.java b/infer/tests/codetoanalyze/java/tracing/CloseableAsResourceExample.java new file mode 120000 index 000000000..1410eb022 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/CloseableAsResourceExample.java @@ -0,0 +1 @@ +../infer/CloseableAsResourceExample.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java b/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java index e263928d8..07b8efc39 100644 --- a/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java +++ b/infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java @@ -10,20 +10,20 @@ package codetoanalyze.java.tracing; interface I { - T get(); + T2 get(); } class A implements I { - public T get() { - return new T(); + public T2 get() { + return new T2(); } } class B extends A { - public T get() { + public T2 get() { return null; } @@ -31,11 +31,11 @@ class B extends A { public class LazyDynamicDispatchExample { - static T fromSupertype(A a) { + static T2 fromSupertype(A a) { return a.get(); } - static T fromInterface(I i) { + static T2 fromInterface(I i) { return i.get(); } diff --git a/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java index 47c6ed2bd..e0b208b0a 100644 --- a/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java @@ -22,14 +22,14 @@ class LocallyDefinedException extends RuntimeException { public class LocallyDefinedExceptionExample { - T t; + T2 t; public LocallyDefinedExceptionExample() { - this.t = new T(); + this.t = new T2(); this.t.x = 42; } - void setT(T t) { + void setT(T2 t) { this.t = t; } diff --git a/infer/tests/codetoanalyze/java/tracing/Makefile b/infer/tests/codetoanalyze/java/tracing/Makefile new file mode 100644 index 000000000..997b25d80 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/Makefile @@ -0,0 +1,42 @@ +# 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. + +include ../Makefile + +ANALYZER = tracing + +FILES_FOR_TRACING = \ + T2.java \ + \ + ArrayIndexOutOfBoundsExceptionExample.java \ + ClassCastExceptionExample.java \ + LazyDynamicDispatchExample.java \ + LocallyDefinedExceptionExample.java \ + NullPointerExceptionExample.java \ + ReportOnMainExample.java \ + UnavoidableExceptionExample.java \ + \ + +FILES_LINKED_FROM_INFER = \ + T.java \ + SkippedSourceFile.java \ + SomeLibrary.java \ + Utils.java \ + CloseableAsResourceExample.java \ + NeverNullSource.java \ + \ + ArrayOutOfBounds.java \ + ClassCastExceptions.java \ + NullPointerExceptions.java \ + +FILES = $(FILES_FOR_TRACING) $(FILES_LINKED_FROM_INFER) + +compile: + javac -cp $(CLASSPATH) $(FILES) + +analyze: + $(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null diff --git a/infer/tests/codetoanalyze/java/tracing/NeverNullSource.java b/infer/tests/codetoanalyze/java/tracing/NeverNullSource.java new file mode 120000 index 000000000..321604bad --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/NeverNullSource.java @@ -0,0 +1 @@ +../infer/NeverNullSource.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java index 2ea4f71ab..fb721439c 100644 --- a/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java @@ -13,12 +13,12 @@ import com.facebook.infer.annotation.Verify; public class NullPointerExceptionExample { - void deref(T t) { + void deref(T2 t) { t.f(); } @Verify - void callDeref(T t, boolean condition) { + void callDeref(T2 t, boolean condition) { if (condition) { deref(t); } diff --git a/infer/tests/codetoanalyze/java/tracing/NullPointerExceptions.java b/infer/tests/codetoanalyze/java/tracing/NullPointerExceptions.java new file mode 120000 index 000000000..6396d3f82 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/NullPointerExceptions.java @@ -0,0 +1 @@ +../infer/NullPointerExceptions.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java b/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java index 400f3ff8a..a7e719b63 100644 --- a/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java +++ b/infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java @@ -11,7 +11,7 @@ package codetoanalyze.java.tracing; public class ReportOnMainExample { - T t; + T2 t; native boolean test(); diff --git a/infer/tests/codetoanalyze/java/tracing/SkippedSourceFile.java b/infer/tests/codetoanalyze/java/tracing/SkippedSourceFile.java new file mode 120000 index 000000000..f5238c9ef --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/SkippedSourceFile.java @@ -0,0 +1 @@ +../infer/SkippedSourceFile.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/SomeLibrary.java b/infer/tests/codetoanalyze/java/tracing/SomeLibrary.java new file mode 120000 index 000000000..69f36e7ae --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/SomeLibrary.java @@ -0,0 +1 @@ +../infer/SomeLibrary.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/T.java b/infer/tests/codetoanalyze/java/tracing/T.java deleted file mode 100644 index d5ba32490..000000000 --- a/infer/tests/codetoanalyze/java/tracing/T.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - - -package codetoanalyze.java.tracing; - -public class T { - int x; - void f() { - } -} diff --git a/infer/tests/codetoanalyze/java/tracing/T.java b/infer/tests/codetoanalyze/java/tracing/T.java new file mode 120000 index 000000000..41bf7ace8 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/T.java @@ -0,0 +1 @@ +../infer/T.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/T2.java b/infer/tests/codetoanalyze/java/tracing/T2.java new file mode 100644 index 000000000..7d99a1388 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/T2.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2015 - 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. + */ + + +package codetoanalyze.java.tracing; + +public class T2 { + int x; + void f() { + } +} diff --git a/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java b/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java index 857d79576..45956899a 100644 --- a/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java +++ b/infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java @@ -11,22 +11,22 @@ package codetoanalyze.java.tracing; public class UnavoidableExceptionExample { - static T create() { + static T2 create() { return null; } static void cannotAvoidNPE() { - T t = create(); + T2 t = create(); t.f(); } static void unavoidableNPEWithParameter(boolean b) { - T t = create(); + T2 t = create(); t.f(); } void virtualMethodWithUnavoidableNPE(boolean b) { - T t = create(); + T2 t = create(); t.f(); } diff --git a/infer/tests/codetoanalyze/java/tracing/Utils.java b/infer/tests/codetoanalyze/java/tracing/Utils.java new file mode 120000 index 000000000..f39bb1c18 --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/Utils.java @@ -0,0 +1 @@ +../infer/Utils.java \ No newline at end of file diff --git a/infer/tests/codetoanalyze/java/tracing/issues.exp b/infer/tests/codetoanalyze/java/tracing/issues.exp new file mode 100644 index 000000000..7f9e2a0df --- /dev/null +++ b/infer/tests/codetoanalyze/java/tracing/issues.exp @@ -0,0 +1,57 @@ +ArrayIndexOutOfBoundsExceptionExample.java, void ArrayIndexOutOfBoundsExceptionExample.arrayIndexOutOfBoundsInCallee(), 3, java.lang.ArrayIndexOutOfBoundsException +ArrayIndexOutOfBoundsExceptionExample.java, void ArrayIndexOutOfBoundsExceptionExample.callOutOfBound(), 3, java.lang.ArrayIndexOutOfBoundsException +ArrayIndexOutOfBoundsExceptionExample.java, void ArrayIndexOutOfBoundsExceptionExample.missingCheckOnIndex(codetoanalyze.java.tracing.T2[],int), 6, java.lang.ArrayIndexOutOfBoundsException +ArrayOutOfBounds.java, int ArrayOutOfBounds.arrayOutOfBounds(), 2, java.lang.ArrayIndexOutOfBoundsException +ClassCastExceptionExample.java, S ClassCastExceptionExample.bar(int), 4, java.lang.ClassCastException +ClassCastExceptionExample.java, void ClassCastExceptionExample.foo(), 4, java.lang.ClassCastException +ClassCastExceptions.java, int ClassCastExceptions.classCastExceptionImplementsInterface(), 0, java.lang.ClassCastException +ClassCastExceptions.java, void ClassCastExceptions.classCastException(), 3, java.lang.ClassCastException +ClassCastExceptions.java, void ClassCastExceptions.openHttpURLConnection(), 4, java.lang.ClassCastException +CloseableAsResourceExample.java, T CloseableAsResourceExample.sourceOfNullWithResourceLeak(), 1, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.failToCloseWithCloseQuietly(), 5, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.leakFoundWhenIndirectlyImplementingCloseable(), 1, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingCloseable(), 1, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingWrapper(), 2, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.skippedVritualCallDoesNotCloseResourceOnReceiver(), 2, RESOURCE_LEAK +CloseableAsResourceExample.java, void CloseableAsResourceExample.withException(), 4, RESOURCE_LEAK +LazyDynamicDispatchExample.java, void LazyDynamicDispatchExample.callWithSubtype(), 3, java.lang.NullPointerException +LazyDynamicDispatchExample.java, void LazyDynamicDispatchExample.shouldReportLocalVarTypeIsKnown(), 3, java.lang.NullPointerException +LocallyDefinedExceptionExample.java, void LocallyDefinedExceptionExample.fieldInvariant(), 8, codetoanalyze.java.tracing.LocallyDefinedException +NullPointerExceptionExample.java, void NullPointerExceptionExample.callDeref(T2,boolean), 4, java.lang.NullPointerException +NullPointerExceptionExample.java, void NullPointerExceptionExample.callLeadToNpe(), 2, java.lang.NullPointerException +NullPointerExceptionExample.java, void NullPointerExceptionExample.npeOnBothBranches(int), 6, java.lang.NullPointerException +NullPointerExceptionExample.java, void NullPointerExceptionExample.npeOnBothBranches(int), 6, java.lang.NullPointerException +NullPointerExceptions.java, String NullPointerExceptions.testSystemGetPropertyArgument(), 1, NULL_DEREFERENCE +NullPointerExceptions.java, int NullPointerExceptions.nullListFiles(String), 3, java.lang.NullPointerException +NullPointerExceptions.java, int NullPointerExceptions.nullPointerException(), 2, java.lang.NullPointerException +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionInterProc(), 2, java.lang.NullPointerException +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithAChainOfFields(NullPointerExceptions$C), 2, java.lang.NullPointerException +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithAChainOfFields(NullPointerExceptions$C), 2, java.lang.NullPointerException +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithArray(), 3, java.lang.NullPointerException +NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithExceptionHandling(boolean), 5, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions$$$Class$Name$With$Dollars.npeWithDollars(), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.badCheckShouldCauseNPE(), 2, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.derefNonThisGetterAfterCheckShouldNotCauseNPE(), 5, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.derefNull(), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.derefUndefNullableRetWrapper(), 2, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterLoopOnList(NullPointerExceptions$L), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterLoopOnList(NullPointerExceptions$L), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock1(Lock), 5, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock1(Lock), 5, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock2(Lock), 7, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock2(Lock), 7, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionArrayLength(), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionCallArrayReadMethod(), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionCallArrayReadMethod(), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFailingFileOutputStreamConstructor(), 9, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFaillingResourceConstructor(), 8, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionUnlessFrameFails(), 6, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullArrayParameter(), 2, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullObjectParameter(), 2, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.someNPEAfterResourceLeak(), 3, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.stringConstantEqualsFalseNotNPE_FP(), 11, java.lang.NullPointerException +NullPointerExceptions.java, void NullPointerExceptions.testSystemGetPropertyReturn(), 3, java.lang.NullPointerException +ReportOnMainExample.java, void ReportOnMainExample.main(java.lang.String[]), 3, java.lang.NullPointerException +UnavoidableExceptionExample.java, void UnavoidableExceptionExample.cannotAvoidNPE(), 3, java.lang.NullPointerException +UnavoidableExceptionExample.java, void UnavoidableExceptionExample.unavoidableNPEWithParameter(boolean), 3, java.lang.NullPointerException +UnavoidableExceptionExample.java, void UnavoidableExceptionExample.virtualMethodWithUnavoidableNPE(boolean), 3, java.lang.NullPointerException diff --git a/infer/tests/endtoend/BUCK b/infer/tests/endtoend/BUCK index d6b31ec3c..7b897c1bf 100644 --- a/infer/tests/endtoend/BUCK +++ b/infer/tests/endtoend/BUCK @@ -9,7 +9,6 @@ tests_dependencies = [ '//infer/tests/utils:utils', '//infer/tests/codetoanalyze/java/crashcontext:crashcontext', '//infer/tests/codetoanalyze/java/infer:infer', - '//infer/tests/codetoanalyze/java/tracing:tracing', ] # ############### C endtoend tests ######################## @@ -66,8 +65,6 @@ java_test( '//infer/tests/endtoend/java/infer:infer', '//infer/tests/endtoend/java/crashcontext:crashcontext', '//infer/tests/endtoend/java/harness:harness', - '//infer/tests/endtoend/java/tracing:tracing', - '//infer/tests/endtoend/java/comparison:comparison', ], visibility=[ 'PUBLIC', diff --git a/infer/tests/endtoend/java/comparison/ArrayIndexOutOfBoundsExceptionTest.java b/infer/tests/endtoend/java/comparison/ArrayIndexOutOfBoundsExceptionTest.java deleted file mode 100644 index 161f8427e..000000000 --- a/infer/tests/endtoend/java/comparison/ArrayIndexOutOfBoundsExceptionTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - - -package endtoend.java.comparison; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ArrayIndexOutOfBoundsExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java"; - - public static final String ARRAY_OUT_OF_BOUNDS = "java.lang.ArrayIndexOutOfBoundsException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingComparisonResults( - ArrayIndexOutOfBoundsExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void whenInferRunsOnArrayOutOfBoundsThenErrorIsFound() - throws IOException, InterruptedException, InferException { - String[] methods = { - "arrayOutOfBounds", - }; - assertThat( - "Results should contain out of bounds error.", inferResults, - containsExactly( - ARRAY_OUT_OF_BOUNDS, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/comparison/BUCK b/infer/tests/endtoend/java/comparison/BUCK deleted file mode 100644 index 3462ed5b2..000000000 --- a/infer/tests/endtoend/java/comparison/BUCK +++ /dev/null @@ -1,16 +0,0 @@ -java_test( - name='comparison', - srcs=glob(['*.java']), - deps=[ - '//dependencies/java/guava:guava', - '//dependencies/java/junit:hamcrest', - '//dependencies/java/junit:junit', - '//infer/tests/utils:utils', - ], - resources=[ - '//infer/tests/codetoanalyze/java/infer:tracing', - ], - visibility=[ - 'PUBLIC', - ], -) diff --git a/infer/tests/endtoend/java/comparison/ClassCastExceptionTest.java b/infer/tests/endtoend/java/comparison/ClassCastExceptionTest.java deleted file mode 100644 index 742ae0c29..000000000 --- a/infer/tests/endtoend/java/comparison/ClassCastExceptionTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.java.comparison; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ClassCastExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java"; - - public static final String CLASS_CAST_EXCEPTION = - "java.lang.ClassCastException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingComparisonResults( - ClassCastExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "classCastException", - "classCastExceptionImplementsInterface", - "openHttpURLConnection", - }; - assertThat( - "Results should contain " + CLASS_CAST_EXCEPTION, - inferResults, - containsExactly( - CLASS_CAST_EXCEPTION, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/comparison/NullPointerExceptionTest.java b/infer/tests/endtoend/java/comparison/NullPointerExceptionTest.java deleted file mode 100644 index b91bb6dd0..000000000 --- a/infer/tests/endtoend/java/comparison/NullPointerExceptionTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - - -package endtoend.java.comparison; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsTheseErrors.contains; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class NullPointerExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java"; - - public static final String NPE = - "java.lang.NullPointerException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingComparisonResults( - NullPointerExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void errorsFoundByInferExpectedToBeFoundInTracingMode() - throws IOException, InterruptedException, InferException { - String[] methods = { - "nullPointerException", - "nullPointerExceptionInterProc", - "nullPointerExceptionWithExceptionHandling", - "nullPointerExceptionWithArray", - "nullPointerExceptionWithNullObjectParameter", - "nullPointerExceptionWithNullArrayParameter", - "nullPointerExceptionFromFaillingResourceConstructor", - "nullPointerExceptionFromFailingFileOutputStreamConstructor", - "nullPointerExceptionUnlessFrameFails", - }; - assertThat( - "Results should contain " + NPE, - inferResults, - contains( - NPE, - SOURCE_FILE, - methods - ) - ); - } - - -} diff --git a/infer/tests/endtoend/java/infer/BUCK b/infer/tests/endtoend/java/infer/BUCK index d18e118a7..d2580c8b2 100644 --- a/infer/tests/endtoend/java/infer/BUCK +++ b/infer/tests/endtoend/java/infer/BUCK @@ -1,3 +1,4 @@ +# TODO: this file exists only to support buck integration in infer/tests/build_systems/build_integration_tests.py java_test( name='infer', srcs=glob(['*.java']), diff --git a/infer/tests/endtoend/java/tracing/ArrayIndexOutOfBoundsExceptionTest.java b/infer/tests/endtoend/java/tracing/ArrayIndexOutOfBoundsExceptionTest.java deleted file mode 100644 index 84a3f1ab2..000000000 --- a/infer/tests/endtoend/java/tracing/ArrayIndexOutOfBoundsExceptionTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - - -package endtoend.java.tracing; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ArrayIndexOutOfBoundsExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/tracing/ArrayIndexOutOfBoundsExceptionExample.java"; - - public static final String ARRAY_OUT_OF_BOUND = - "java.lang.ArrayIndexOutOfBoundsException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingResults( - ArrayIndexOutOfBoundsExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "callOutOfBound", - "missingCheckOnIndex", - "arrayIndexOutOfBoundsInCallee", - }; - assertThat( - "Results should contain " + ARRAY_OUT_OF_BOUND, - inferResults, - containsExactly( - ARRAY_OUT_OF_BOUND, - SOURCE_FILE, - methods - ) - ); - } - - -} diff --git a/infer/tests/endtoend/java/tracing/BUCK b/infer/tests/endtoend/java/tracing/BUCK deleted file mode 100644 index c763f2155..000000000 --- a/infer/tests/endtoend/java/tracing/BUCK +++ /dev/null @@ -1,16 +0,0 @@ -java_test( - name='tracing', - srcs=glob(['*.java']), - deps=[ - '//dependencies/java/guava:guava', - '//dependencies/java/junit:hamcrest', - '//dependencies/java/junit:junit', - '//infer/tests/utils:utils', - ], - resources=[ - '//infer/tests/codetoanalyze/java/tracing:analyze', - ], - visibility=[ - 'PUBLIC', - ], -) diff --git a/infer/tests/endtoend/java/tracing/ClassCastExceptionTest.java b/infer/tests/endtoend/java/tracing/ClassCastExceptionTest.java deleted file mode 100644 index be49265a4..000000000 --- a/infer/tests/endtoend/java/tracing/ClassCastExceptionTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.java.tracing; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ClassCastExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/tracing/ClassCastExceptionExample.java"; - - public static final String CLASS_CAST_EXCEPTION = - "java.lang.ClassCastException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingResults( - ClassCastExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = {"foo", "bar"}; - assertThat( - "Results should contain " + CLASS_CAST_EXCEPTION, - inferResults, - containsExactly( - CLASS_CAST_EXCEPTION, - SOURCE_FILE, - methods - ) - ); - } - - -} diff --git a/infer/tests/endtoend/java/tracing/LazyDynamicDispatchTest.java b/infer/tests/endtoend/java/tracing/LazyDynamicDispatchTest.java deleted file mode 100644 index 09c927951..000000000 --- a/infer/tests/endtoend/java/tracing/LazyDynamicDispatchTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - - -package endtoend.java.tracing; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class LazyDynamicDispatchTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/tracing/LazyDynamicDispatchExample.java"; - - public static final String NPE = - "java.lang.NullPointerException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingResults( - LazyDynamicDispatchTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "callWithSubtype", - "shouldReportLocalVarTypeIsKnown", - }; - assertThat( - "Results should contain " + NPE, - inferResults, - containsExactly( - NPE, - SOURCE_FILE, - methods - ) - ); - } - -} diff --git a/infer/tests/endtoend/java/tracing/LocallyDefinedExceptionTest.java b/infer/tests/endtoend/java/tracing/LocallyDefinedExceptionTest.java deleted file mode 100644 index d6418b71f..000000000 --- a/infer/tests/endtoend/java/tracing/LocallyDefinedExceptionTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.java.tracing; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class LocallyDefinedExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/tracing/LocallyDefinedExceptionExample.java"; - - public static final String LOCALLY_DEFINED_EXCEPTION = - "codetoanalyze.java.tracing.LocallyDefinedException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingResults( - LocallyDefinedExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "fieldInvariant" - }; - assertThat( - "Results should contain " + LOCALLY_DEFINED_EXCEPTION, - inferResults, - containsExactly( - LOCALLY_DEFINED_EXCEPTION, - SOURCE_FILE, - methods - ) - ); - } - - -} diff --git a/infer/tests/endtoend/java/tracing/NullPointerExceptionTest.java b/infer/tests/endtoend/java/tracing/NullPointerExceptionTest.java deleted file mode 100644 index 943d83e1b..000000000 --- a/infer/tests/endtoend/java/tracing/NullPointerExceptionTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - - -package endtoend.java.tracing; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class NullPointerExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/tracing/NullPointerExceptionExample.java"; - - public static final String NPE = - "java.lang.NullPointerException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingResults( - NullPointerExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "callDeref", - "callLeadToNpe", - "npeOnBothBranches", - }; - assertThat( - "Results should contain " + NPE, - inferResults, - containsExactly( - NPE, - SOURCE_FILE, - methods - ) - ); - } - - - -} diff --git a/infer/tests/endtoend/java/tracing/ReportOnMainTest.java b/infer/tests/endtoend/java/tracing/ReportOnMainTest.java deleted file mode 100644 index 553494116..000000000 --- a/infer/tests/endtoend/java/tracing/ReportOnMainTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - -package endtoend.java.tracing; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class ReportOnMainTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/tracing/ReportOnMainExample.java"; - - public static final String NPE = - "java.lang.NullPointerException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingResults( - ReportOnMainTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "main" - }; - assertThat( - "Results should contain " + NPE, - inferResults, - containsExactly( - NPE, - SOURCE_FILE, - methods - ) - ); - } - - -} diff --git a/infer/tests/endtoend/java/tracing/UnavoidableExceptionTest.java b/infer/tests/endtoend/java/tracing/UnavoidableExceptionTest.java deleted file mode 100644 index cc22e7940..000000000 --- a/infer/tests/endtoend/java/tracing/UnavoidableExceptionTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015 - 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. - */ - - -package endtoend.java.tracing; - -import static org.hamcrest.MatcherAssert.assertThat; -import static utils.matchers.ResultContainsExactly.containsExactly; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.IOException; - -import utils.InferException; -import utils.InferResults; - -public class UnavoidableExceptionTest { - - public static final String SOURCE_FILE = - "infer/tests/codetoanalyze/java/tracing/UnavoidableExceptionExample.java"; - - public static final String NPE = - "java.lang.NullPointerException"; - - private static InferResults inferResults; - - @BeforeClass - public static void loadResults() throws InterruptedException, IOException { - inferResults = InferResults.loadTracingResults( - UnavoidableExceptionTest.class, - SOURCE_FILE); - } - - @Test - public void matchErrors() - throws IOException, InterruptedException, InferException { - String[] methods = { - "cannotAvoidNPE", - "unavoidableNPEWithParameter", - "virtualMethodWithUnavoidableNPE", - }; - assertThat( - "Results should contain " + NPE, - inferResults, - containsExactly( - NPE, - SOURCE_FILE, - methods - ) - ); - } - -}