Skip to content

Commit 350815a

Browse files
cushonError Prone Team
authored and
Error Prone Team
committed
Use text blocks for more Error Prone test outputs
I skipped reformatted these ones, because reformatting would cause some tests to fail, because of examples like ``` // BUG: Diagnostic contains @OverRide void f() {} ``` ``` // BUG: Diagnostic contains @OverRide void f() {} // <- the diagnostic is actually on this line ``` PiperOrigin-RevId: 674341306
1 parent af9fdd2 commit 350815a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+12740
-10066
lines changed

core/src/test/java/com/google/errorprone/ErrorProneCompilerIntegrationTest.java

+48-32
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ public void ignoreGeneratedSuperInvocations() {
278278
compiler.compile(
279279
Arrays.asList(
280280
forSourceLines(
281-
"Test.java", //
282-
"public class Test {",
283-
" public Test() {}",
284-
"}")));
281+
"Test.java",
282+
"""
283+
public class Test {
284+
public Test() {}
285+
}
286+
""")));
285287

286288
assertWithMessage("[SuperCallMatcher]")
287289
.that(diagnosticHelper.getDiagnostics())
@@ -301,10 +303,12 @@ public void invalidFlagCausesCmdErrResult() {
301303
args,
302304
Arrays.asList(
303305
forSourceLines(
304-
"Test.java", //
305-
"public class Test {",
306-
" public Test() {}",
307-
"}"))));
306+
"Test.java",
307+
"""
308+
public class Test {
309+
public Test() {}
310+
}
311+
"""))));
308312
}
309313

310314
@Test
@@ -494,12 +498,14 @@ public void crashSourcePosition() {
494498
Arrays.asList(
495499
forSourceLines(
496500
"test/Test.java",
497-
"package Test;",
498-
"class Test {",
499-
" void f() {",
500-
" return;",
501-
" }",
502-
"}")));
501+
"""
502+
package Test;
503+
class Test {
504+
void f() {
505+
return;
506+
}
507+
}
508+
""")));
503509
assertWithMessage(outputStream.toString()).that(exitCode).isEqualTo(Result.ERROR);
504510
assertThat(diagnosticHelper.getDiagnostics()).hasSize(1);
505511
Diagnostic<? extends JavaFileObject> diag =
@@ -530,9 +536,11 @@ public void compilePolicy_byfile() {
530536
new String[] {"-XDcompilePolicy=byfile"},
531537
Arrays.asList(
532538
forSourceLines(
533-
"Test.java", //
534-
"package test;",
535-
"class Test {}")));
539+
"Test.java",
540+
"""
541+
package test;
542+
class Test {}
543+
""")));
536544
outputStream.flush();
537545
assertWithMessage(outputStream.toString()).that(exitCode).isEqualTo(Result.OK);
538546
}
@@ -544,9 +552,11 @@ public void compilePolicy_simple() {
544552
new String[] {"-XDcompilePolicy=simple"},
545553
Arrays.asList(
546554
forSourceLines(
547-
"Test.java", //
548-
"package test;",
549-
"class Test {}")));
555+
"Test.java",
556+
"""
557+
package test;
558+
class Test {}
559+
""")));
550560
outputStream.flush();
551561
assertWithMessage(outputStream.toString()).that(exitCode).isEqualTo(Result.OK);
552562
}
@@ -573,10 +583,12 @@ public void compilationWithError() {
573583
Arrays.asList(
574584
forSourceLines(
575585
"Test.java",
576-
"package test;",
577-
"public class Test {",
578-
" Object f() { return new NoSuch(); }",
579-
"}")));
586+
"""
587+
package test;
588+
public class Test {
589+
Object f() { return new NoSuch(); }
590+
}
591+
""")));
580592
outputStream.flush();
581593
String output = diagnosticHelper.getDiagnostics().toString();
582594
assertThat(output).contains("error: cannot find symbol");
@@ -616,10 +628,12 @@ public void checkerWithFlags() {
616628
Arrays.asList(
617629
forSourceLines(
618630
"Test.java",
619-
"package test;",
620-
"public class Test {",
621-
" Object f() { return \"XYLOPHONE\"; }",
622-
"}"));
631+
"""
632+
package test;
633+
public class Test {
634+
Object f() { return "XYLOPHONE"; }
635+
}
636+
"""));
623637

624638
compilerBuilder.report(ScannerSupplier.fromBugCheckerClasses(ForbiddenString.class));
625639
compiler = compilerBuilder.build();
@@ -636,10 +650,12 @@ public void flagsAreResetOnNextCompilation() {
636650
Arrays.asList(
637651
forSourceLines(
638652
"Test.java",
639-
"package test;",
640-
"public class Test {",
641-
" Object f() { return \"BANANAS\"; }",
642-
"}"));
653+
"""
654+
package test;
655+
public class Test {
656+
Object f() { return "BANANAS"; }
657+
}
658+
"""));
643659

644660
// First compile forbids "bananas", should fail.
645661
compilerBuilder.report(ScannerSupplier.fromBugCheckerClasses(ForbiddenString.class));

0 commit comments

Comments
 (0)