Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace \r\n with \n on windows #73

Merged
merged 3 commits into from
Oct 21, 2021

Conversation

zepatrik
Copy link
Contributor

Depending on how you setup git on windows, it might convert between line separators. For Github actions it seems to be the case that \n is replaced by \r\n, as we have a constant failure here: https://github.com/ory/x/runs/3937200972 but the content is identical when copied and compared via diff.
In contrast, a run with this fix as a replacement succeeds: https://github.com/ory/x/runs/3937395472

@bradleyjkemp
Copy link
Owner

Interesting issue! I've definitely not seen anyone else report this before.

I don't think this is particularly a bug in cupaloy nor can it safely be fixed within the library—say if someone is trying to snapshot test something which outputs \r\n characters?

What I think you're running into is this problem: actions/checkout#135
By running

git config --system core.autocrlf false
git config --system core.eol lf

before checkout, git won't re-write your snapshot files and so the tests should pass

Alternatively I think you can set only your snapshot files to remain un-modified using a .gitattributes file: https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#per-repository-settings

Could you try and see if one of those fixes the problem?

@zepatrik
Copy link
Contributor Author

zepatrik commented Oct 20, 2021

True, that should fix it. Test run: https://github.com/ory/x/pull/412/checks?check_run_id=3952501267

@zepatrik
Copy link
Contributor Author

I will add a section to the README in case that fixes the problem.

@zepatrik
Copy link
Contributor Author

So yeah, setting the git config fixed it. I added a short debug help section to the readme.

@bradleyjkemp
Copy link
Owner

Amazing thanks for adding that 🙂 just one tiny comment: it looks like you linked the same GitHub Actions issue twice?

@zepatrik
Copy link
Contributor Author

Ah, wanted to link this PR 😅 fixed it

@bradleyjkemp
Copy link
Owner

Thanks @zepatrik ❤️

@bradleyjkemp bradleyjkemp merged commit 23b79b2 into bradleyjkemp:master Oct 21, 2021
@zepatrik zepatrik deleted the fix/windows-line-endings branch October 21, 2021 09:49
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.

None yet

2 participants