Skip to content

Commit

Permalink
Add some missing testdata/ prefixes.
Browse files Browse the repository at this point in the history
This supports removing the hack of checking both paths.

PiperOrigin-RevId: 678280454
  • Loading branch information
graememorgan authored and Error Prone Team committed Sep 24, 2024
1 parent f82fb66 commit 50d0983
Show file tree
Hide file tree
Showing 148 changed files with 609 additions and 398 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void canPromoteToError() {
ErrorProneTestCompiler compiler =
builder.report(ScannerSupplier.fromBugCheckerClasses(WarningChecker.class)).build();
ImmutableList<JavaFileObject> sources =
forResources(getClass(), "CommandLineFlagTestFile.java");
forResources(getClass(), "testdata/CommandLineFlagTestFile.java");

Result exitCode = compiler.compile(sources);
assertThat(exitCode).isEqualTo(Result.OK);
Expand All @@ -185,7 +185,7 @@ public void canDemoteToWarning() {
ErrorProneTestCompiler compiler =
builder.report(ScannerSupplier.fromBugCheckerClasses(ErrorChecker.class)).build();
ImmutableList<JavaFileObject> sources =
forResources(getClass(), "CommandLineFlagTestFile.java");
forResources(getClass(), "testdata/CommandLineFlagTestFile.java");

Result exitCode = compiler.compile(sources);
assertThat(exitCode).isEqualTo(Result.ERROR);
Expand All @@ -201,7 +201,7 @@ public void canDisable() {
ErrorProneTestCompiler compiler =
builder.report(ScannerSupplier.fromBugCheckerClasses(DisableableChecker.class)).build();
ImmutableList<JavaFileObject> sources =
forResources(getClass(), "CommandLineFlagTestFile.java");
forResources(getClass(), "testdata/CommandLineFlagTestFile.java");

Result exitCode = compiler.compile(sources);
assertThat(exitCode).isEqualTo(Result.ERROR);
Expand All @@ -217,7 +217,7 @@ public void cantDisableNondisableableCheck() {
ErrorProneTestCompiler compiler =
builder.report(ScannerSupplier.fromBugCheckerClasses(NondisableableChecker.class)).build();
ImmutableList<JavaFileObject> sources =
forResources(getClass(), "CommandLineFlagTestFile.java");
forResources(getClass(), "testdata/CommandLineFlagTestFile.java");

InvalidCommandLineOptionException expected =
assertThrows(
Expand All @@ -230,7 +230,7 @@ public void cantDisableNondisableableCheck() {
public void cantOverrideNonexistentCheck() {
ErrorProneTestCompiler compiler = builder.build();
ImmutableList<JavaFileObject> sources =
forResources(getClass(), "CommandLineFlagTestFile.java");
forResources(getClass(), "testdata/CommandLineFlagTestFile.java");
List<String> badOptions =
Arrays.asList(
"-Xep:BogusChecker:ERROR",
Expand All @@ -251,7 +251,7 @@ public void cantOverrideNonexistentCheck() {
public void ignoreUnknownChecksFlagAllowsOverridingUnknownCheck() {
ErrorProneTestCompiler compiler = builder.build();
ImmutableList<JavaFileObject> sources =
forResources(getClass(), "CommandLineFlagTestFile.java");
forResources(getClass(), "testdata/CommandLineFlagTestFile.java");
List<String> badOptions =
Arrays.asList(
"-Xep:BogusChecker:ERROR",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ public class ArrayEqualsTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("ArrayEqualsPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayEqualsPositiveCases.java").doTest();
}

@Test
public void java7PositiveCase() {
compilationHelper.addSourceFile("ArrayEqualsPositiveCases2.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayEqualsPositiveCases2.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("ArrayEqualsNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayEqualsNegativeCases.java").doTest();
}

@Test
public void java7NegativeCase() {
compilationHelper.addSourceFile("ArrayEqualsNegativeCases2.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayEqualsNegativeCases2.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public class ArrayHashCodeTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("ArrayHashCodePositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayHashCodePositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("ArrayHashCodeNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayHashCodeNegativeCases.java").doTest();
}

/** Tests java.util.Objects hashCode methods, which are only in JDK 7 and above. */
@Test
public void java7NegativeCase() {
compilationHelper.addSourceFile("ArrayHashCodeNegativeCases2.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayHashCodeNegativeCases2.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public class ArrayToStringTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("ArrayToStringPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayToStringPositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("ArrayToStringNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/ArrayToStringNegativeCases.java").doTest();
}

@Test
Expand Down Expand Up @@ -194,22 +194,30 @@ void test(Exception e) {

@Test
public void positiveCompoundAssignment() {
compilationHelper.addSourceFile("ArrayToStringCompoundAssignmentPositiveCases.java").doTest();
compilationHelper
.addSourceFile("testdata/ArrayToStringCompoundAssignmentPositiveCases.java")
.doTest();
}

@Test
public void negativeCompoundAssignment() {
compilationHelper.addSourceFile("ArrayToStringCompoundAssignmentNegativeCases.java").doTest();
compilationHelper
.addSourceFile("testdata/ArrayToStringCompoundAssignmentNegativeCases.java")
.doTest();
}

@Test
public void positiveConcat() {
compilationHelper.addSourceFile("ArrayToStringConcatenationPositiveCases.java").doTest();
compilationHelper
.addSourceFile("testdata/ArrayToStringConcatenationPositiveCases.java")
.doTest();
}

@Test
public void negativeConcat() {
compilationHelper.addSourceFile("ArrayToStringConcatenationNegativeCases.java").doTest();
compilationHelper
.addSourceFile("testdata/ArrayToStringConcatenationNegativeCases.java")
.doTest();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public class AssertFalseTest {

@Test
public void negativeCase() {
compilationHelper.addSourceFile("AssertFalseNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/AssertFalseNegativeCases.java").doTest();
}

@Test
public void positiveCase() {
compilationHelper.addSourceFile("AssertFalsePositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/AssertFalsePositiveCases.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public class AsyncFunctionReturnsNullTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("AsyncFunctionReturnsNullPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/AsyncFunctionReturnsNullPositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("AsyncFunctionReturnsNullNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/AsyncFunctionReturnsNullNegativeCases.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public class BadComparableTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("BadComparablePositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/BadComparablePositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("BadComparableNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/BadComparableNegativeCases.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void foo() {

@Test
public void positive_nested() {
compilationTestHelper.addSourceFile("BadImportPositiveCases.java").doTest();
compilationTestHelper.addSourceFile("testdata/BadImportPositiveCases.java").doTest();
}

@Test
Expand Down Expand Up @@ -262,7 +262,7 @@ static class B {}

@Test
public void negative_nested() {
compilationTestHelper.addSourceFile("BadImportNegativeCases.java").doTest();
compilationTestHelper.addSourceFile("testdata/BadImportNegativeCases.java").doTest();
}

@Test
Expand All @@ -284,8 +284,8 @@ public void negative_badImportIsTopLevelClass() {
@Test
public void nestedFixes() {
refactoringTestHelper
.addInput("BadImportPositiveCases.java")
.addOutput("BadImportPositiveCases_expected.java")
.addInput("testdata/BadImportPositiveCases.java")
.addOutput("testdata/BadImportPositiveCases_expected.java")
.doTest(TestMode.AST_MATCH);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public class BadShiftAmountTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("BadShiftAmountPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/BadShiftAmountPositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("BadShiftAmountNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/BadShiftAmountNegativeCases.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public class BanClassLoaderTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("BanClassLoaderPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/BanClassLoaderPositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("BanClassLoaderNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/BanClassLoaderNegativeCases.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ public class BanJNDITest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("BanJNDIPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/BanJNDIPositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("BanJNDINegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/BanJNDINegativeCases.java").doTest();
}

@Test
public void negativeCaseUnchanged() {
refactoringHelper
.addInput("BanJNDINegativeCases.java")
.addInput("testdata/BanJNDINegativeCases.java")
.expectUnchanged()
.setArgs("-XepCompilingTestOnlyCode")
.doTest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ public class BanSerializableReadTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("BanSerializableReadPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/BanSerializableReadPositiveCases.java").doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("BanSerializableReadNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/BanSerializableReadNegativeCases.java").doTest();
}

@Test
public void negativeCaseUnchanged() {
refactoringHelper
.addInput("BanSerializableReadNegativeCases.java")
.addInput("testdata/BanSerializableReadNegativeCases.java")
.expectUnchanged()
.setArgs("-XepCompilingTestOnlyCode")
.doTest();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public class ByteBufferBackingArrayTest {

@Test
public void positiveCases() {
compilationHelper.addSourceFile("ByteBufferBackingArrayPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/ByteBufferBackingArrayPositiveCases.java").doTest();
}

@Test
public void negativeCases() {
compilationHelper.addSourceFile("ByteBufferBackingArrayNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/ByteBufferBackingArrayNegativeCases.java").doTest();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CannotMockFinalClassTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("CannotMockFinalClassPositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/CannotMockFinalClassPositiveCases.java").doTest();
}

@Test
Expand Down Expand Up @@ -64,11 +64,11 @@ record Record() {}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("CannotMockFinalClassNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/CannotMockFinalClassNegativeCases.java").doTest();
}

@Test
public void negativeCase2() {
compilationHelper.addSourceFile("CannotMockFinalClassNegativeCases2.java").doTest();
compilationHelper.addSourceFile("testdata/CannotMockFinalClassNegativeCases2.java").doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ public class ChainedAssertionLosesContextTest {

@Test
public void positiveCase() {
compilationHelper.addSourceFile("ChainedAssertionLosesContextPositiveCases.java").doTest();
compilationHelper
.addSourceFile("testdata/ChainedAssertionLosesContextPositiveCases.java")
.doTest();
}

@Test
public void negativeCase() {
compilationHelper.addSourceFile("ChainedAssertionLosesContextNegativeCases.java").doTest();
compilationHelper
.addSourceFile("testdata/ChainedAssertionLosesContextNegativeCases.java")
.doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public class ChainingConstructorIgnoresParameterTest {
@Test
public void positiveCase() {
compilationHelper
.addSourceFile("ChainingConstructorIgnoresParameterPositiveCases.java")
.addSourceFile("testdata/ChainingConstructorIgnoresParameterPositiveCases.java")
.doTest();
}

@Test
public void negativeCase() {
compilationHelper
.addSourceFile("ChainingConstructorIgnoresParameterNegativeCases.java")
.addSourceFile("testdata/ChainingConstructorIgnoresParameterNegativeCases.java")
.doTest();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class CheckReturnValueTest {

@Test
public void positiveCases() {
compilationHelper.addSourceFile("CheckReturnValuePositiveCases.java").doTest();
compilationHelper.addSourceFile("testdata/CheckReturnValuePositiveCases.java").doTest();
}

@Test
Expand Down Expand Up @@ -108,7 +108,7 @@ public void doIt() {

@Test
public void negativeCase() {
compilationHelper.addSourceFile("CheckReturnValueNegativeCases.java").doTest();
compilationHelper.addSourceFile("testdata/CheckReturnValueNegativeCases.java").doTest();
}

@Test
Expand Down
Loading

0 comments on commit 50d0983

Please sign in to comment.