-
Notifications
You must be signed in to change notification settings - Fork 105
Tests need to be refactored; failures from master with various EOL formats. #241
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
Comments
Oye. Thanks for looking into this further. |
On my end, with cobalt 0.8.0, Cobalt produces Unix EOL files, I don't know if it should produce OS dependant files or not though So either force one style of EOL through a .gitattributes file, or make Cobalt produces OS dependant EOL file should fix this |
The thing that confuses me about this is that I don't think cobalt deals with line endings, it just preserves whatever is in the source file. For the tests, this means the fixture and target would both be changed to CRLF and should work. When we validate a test run, we generate a diff using a specific EOL. I thought this was just advisory only. Either way, it should treat the two files the same. |
Either way, I'm fine with adding a Ideally, the editorconfig file would also say to not strip trailing whitespace. That is an easy way for people to mess up the tests. |
I've normalize EOL in assert_dirs_eq and it solves many tests but some are still broken. While investigating these, I've notice a weirdness in the produced file: We have a mix of EOL: this is the product from excerpts test, While my EDIT: but this is not the cause of test failure |
The failing tests are:
For excerpts test, it seems that having the md file with CRLF changes the output of the except :-/ I'll try to fix excerpts (so nobody is working on the same thing) |
The default value for excerpt_separator is "\n\n" that's why we have different output if the markdown file is in Windows EOL mode. I don't know how to manage it, because on an OS, we can encounter different EOL anyway so we should not rely on the OS to determine the default excerpt separator. May be a detection? Like looking at the first EOL? And if ever we have a mixed file, the user should normalize (and we spit a warning) |
So that answers why the tests fail with normalized whitespace
So we have several options
The newline-based separator is nice for a post that immediately goes into content because its a lot more natural. So I somewhat lean towards keeping that. The next question is how many users will be mixing platforms to a degree that we need auto-detection vs documentation? Any other thoughts? |
We still have the question of why we need to normalize whitespace with autocrlf. See #335 |
I'd like to keep the newline separator too. On the other hand, we can't force people to use one type of EOL. If Windows user manually create a md file, it will be with CRLF. I tend to go for auto detect. The question is: per file detection or just OS detection? |
Before we decide on a solution, I feel like we need to better understand the problem: why is there a newline discrepancy in the first place. If we auto-detect, what is it changing about our output? |
I need to investigate this, I suspect a hardcoded "\n" somewhere ^^ |
Thanks for being willing to look into that! |
Ok I had a quick look and here my findings:
I think we need to change them with something consistent across the website being processed and forbid mixed EOL in a website. Maybe add an option in the config file? |
When you made the tests normalize the line endings, that left the RSS tests failing. I thought you said it was because the excerpts weren't correctly extracted because of |
For the excerpt separator, I think we need both: documentation and auto detection. I'm not comfortable with a hardcoded value for it. for the rss/json feed, I need to see what's happening in the test, I haven't check, you may be right that the excerpt bug is making them failing though :) |
Found it! Or at least another form of "it". When we parse things with markdown, the line endings are being converted! I confirmed this by converting an I also suspect syntect is doing the same thing for syntax highlighting. |
Well done! I hope there's no other occurrence of this bug. To summarize, we need:
BTW, where it this occurrence? |
btw this crate might be handy |
markdown is handled at https://github.com/cobalt-org/cobalt.rs/blob/master/src/document.rs#L324 |
So I'm re-evaluating things and playing with options in my head
So we need to weigh out
Overall, I'm wondering how valuable preserving and consistency are. For simplicity, I worry how much we'll be playing whack-a-mole either preserving the user's line endings or normalizing them to Thoughts? Sorry if it feels like I'm yanking you in different directions. This journey has been valuable for us to make an informed decision. |
No need to apologies here :) I think that we just need to be consistent on the output. As for the test failing, either putting back #335 or a |
If for no other reason than for if someone later has a question on why we did something, why are you keen on this solution? |
I think it's the easiest way to get rid of this issue ^^' |
So we agree on this solution? I will have some free time next week to work on cobalt so I will begin by solve this before working on the theming subject :) |
Sorry, been rushing too much on these cobalt / liquid changes, haven't been spending much time thinking on other things.
That is one of the assumptions my post listing out options above is re-evaluating. I'm wondering if we should, for now, just leave things be. Maybe its not all that bad to just normalize the whitespace in the tests? |
No need to apologies, I haven't work on cobalt for weeks myself ;) Normalizing the EOL in tests will not solve the tests where excerpts are involved :-/ |
in order to solve this, we need 2 things:
I'll wait #346 to land in order to incorporate the changes in cobalt.rs into my refactor. |
This is my recommendation for tests that use the excerpt
|
With my fix, the "\r\n" change is not needed, I'm normalizing the file :) This is more friendly, isn't it? The test will makes sure that the produced result will be "\n" Not sure I'm clear enough here ^^' |
I have added some tests: basically copy pasted |
split build() into smaller functions uses normalize end line crate Add tests for CRLF case
split build() into smaller functions uses normalize end line crate Add tests for CRLF case fmt issue Fix conflict fix fmt Fix clippy Compil fix clippy
Closes cobalt-org#241 add editorconfig add gitattributes
Closes cobalt-org#241 add editorconfig add gitattributes
Closes cobalt-org#241 add editorconfig add gitattributes
Closes cobalt-org#241 add editorconfig add gitattributes
The tests |
How do you clone? Do you use a GUI? GitKraken for instance have its own autocrlf setting and ignore global one and even What is your OS? Still Fedora? I don't have a Fedora to test :-/ |
@Geobert I clone from the command line directly. And no, I switched to Arch Linux last July. You can quite literally explore my workstation:
There's nothing I've done, no setting I've configured, that should cause this issue. I've experienced test failures (due to line endings) with this project under fresh installs of Debian, Windows, Fedora, and Arch Linux. I'm curious what platform the project contributors use. |
Can you please give me the EOL encoding of:
|
Uh oh!
There was an error while loading. Please reload this page.
I'm on Fedora 25 (64-bit), using kernel
v4.11.3-202
.I am unable to successfully run
cargo test
frommaster
of this repository, usingrustc 1.17.0 (56124baa99 2017-04-24)
andcargo 0.18.0 (fe7b0cdcf 2017-04-24)
. For sanity checking, I have attempted to clone the repository with the git configurationcore.autocrlf
set to its various values:This issue was originally surfaced in #209 under Windows 10, so the issue does not seem to be limited to my machine.
The text was updated successfully, but these errors were encountered: