-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix regex-redux tests to consistently remove newlines #44361
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
Conversation
Need to check for \r\n as well as \n.
|
PTAL @sandreenko Suspect this is a result of #43736. Not sure why the current version is passing in CI, perhaps we are enabling old behavior there still? |
It shouldn't be, as regex uses ordinal by default. |
Maybe when the data files got checked out locally, they got rewritten with \r\n? |
Maybe, though this is new behavior and I don't recall changing any config settings. |
|
Presumably the test is failing without your change? |
|
Locally, yes... That last |
|
fwiw, I see the same failure as Andy. And the .txt files all have \r\n on my file system. Did something change in the moving of the test tree? #38058 E.g., were the files previously marked binary? Presumably Andy's change allows the tests to work no matter what the newline format is, so is general goodness? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change LGTM, but I agree with Bruce it would be useful to understand what has changed and why it is passing in CI.
Maybe when the data files got checked out locally, they got rewritten with \r\n?
These files had /r/n from the beginning according to my Notepad++, do not know if it is possible to show it on GitHub.
Not in the git repo: using System;
using System.Net.Http;
using var c = new HttpClient();
Console.WriteLine((await c.GetByteArrayAsync("https://raw.githubusercontent.com/dotnet/runtime/master/src/tests/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25.txt")).AsSpan().IndexOf((byte)'\r'));
Console.WriteLine((await c.GetByteArrayAsync("https://raw.githubusercontent.com/dotnet/runtime/master/src/tests/JIT/Performance/CodeQuality/BenchmarksGame/regex-redux/regexdna-input25000.txt")).AsSpan().IndexOf((byte)'\r'));outputs: |
|
I think I found the problem: .gitattributes didn't get updated when the tests moved -- they still point at the old files: cc @trylek It's unfortunate that the tests are dependent on the specific line endings and require this configuration. |
No '\r's in that one either 😄 |
My only hesitancy in changing them is it moves away from how regex redux is defined: If the goal of having the test here is to match that, we should be wary of changing it. If the goal of having the test here is just to have a meaty regex test, then changing it is fine. |
|
My apologies about the missing .gitattributes path renames, I'll send out a PR to fix these. |
|
For simplicity, we should probably keep these as close to possible as the "official" code, so we'll just need to live with the config to force LF line endings for the test input. |
|
Ah, I remember creating those gitattributes, long ago. Updating them makes sense, so I think we can abandon this PR. Still not clear how the tests are passing in CI. Any explanation for that? I suppose we are shipping files around so perhaps we're building on one OS and running on another? |
|
In the CI we always (?) build tests on Mac, so its |
|
Correct - well, in fact I recently switched that over to Linux as the lab Macs have become much slower but your argument still holds. |
Need to check for \r\n as well as \n.