Skip to content

Commit a60e060

Browse files
committed
Compare line-ending-neutral in the two tests that failed on Windows
The first Windows run of the plugin tests failed three cases, none of them in the native formatter. The Windows checkout gives example1.patch CRLF line endings, so parsing it as git output found no files; git itself prints a diff with LF, so the test now reads the fixture that way. And Spotless writes the platform's line endings, CRLF on Windows, which the Spotless test compared against a text block with LF; it now compares ignoring line endings.
1 parent e530bbe commit a60e060

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/FormatDiffTest.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ class FormatDiffTest {
5151

5252
@Test
5353
void parsing_git_diff_output_works() throws IOException {
54+
// A Windows checkout gives the fixture CRLF line endings, while git prints a diff with LF.
5455
String example1 = Files.readString(
55-
Paths.get("src/test/resources/com/palantir/javaformat/java/FormatDiffCliTest/example1.patch"));
56+
Paths.get("src/test/resources/com/palantir/javaformat/java/FormatDiffCliTest/example1.patch"))
57+
.replace("\r\n", "\n");
5658

5759
List<String> strings = FormatDiff.parseGitDiffOutput(example1)
5860
.map(FormatDiff.SingleFileDiff::toString)

‎gradle-open-java-format/src/test/java/com/palantir/javaformat/gradle/PalantirJavaFormatSpotlessPluginTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ palantirJavaFormat files(file("%s").text.split(File.pathSeparator))
9090

9191
BuildResult result = project.succeeds("spotlessApply", "--info");
9292

93-
assertThat(project.readFile(MAIN_JAVA)).isEqualTo(validJavaFile());
93+
// Spotless writes the platform's line endings, CRLF on Windows.
94+
assertThat(project.readFile(MAIN_JAVA)).isEqualToNormalizingNewlines(validJavaFile());
9495
assertThat(result.getOutput()).contains(expectedOutput);
9596
}
9697

0 commit comments

Comments
 (0)