Skip to content

Conversation

@nedtwigg
Copy link
Member

Spotless' CI only run on Linux, so it doesn't run on Windows very often. Spotless doesn't have any known Windows bugs, but if you checkout the Spotless repo and ran the tests, a lot of them would fail because of line-endings issues.

This fixes them.

… and windows, we'll write a .gitattributes file to the root directory of every test folder.
…solutionTest in the past, but it's not necessary anymore.
@jbduncan
Copy link
Member

Wow, thank you very much for having a go at this @nedtwigg. I was having quite a bit of trouble resolving this issue myself, so I'm glad that a working PR has been submitted.

Apart from one thing which I'm confused about and will go over in a forthcoming review, I think this PR looks good. 👍

@Before
public void gitAttributes() throws IOException {
write(".gitattributes", "* text eol=lf");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not so clear on what writing this .gitattributes file does. What do the other tests do with it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default line ending behavior is to match git. We have a .gitattributes file so that spotless will checkout with \n on every platform.

Our GradleIntegrationTests create a folder in a temp folder, and run a gradle build there. Because those test folders don't have a .gitattributes file, git (on windows) will default to \r\n. So now if you read a test file from the spotless test resources, and compare it to a build result, the line endings won't match. We used to fix this in ResourceHarness by switching line endings to UNIX, which was dangerous. Now we do it buy sticking this .gitattributes file into the test directory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, that makes sense to me now. Thanks for clarifying things for me!

In that case, this whole PR LGTM. 👍

@jbduncan
Copy link
Member

Given the clarification in #180 (comment), I now fully understand and approve this PR.

Ship it :shipit:, as some people would say. :)

@nedtwigg nedtwigg merged commit 3ebb666 into master Dec 25, 2017
@nedtwigg nedtwigg deleted the feature/windowsNewlines branch December 25, 2017 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants