-
Notifications
You must be signed in to change notification settings - Fork 5k
Add parser tests from nim-regex #62093
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
Tagging subscribers to this area: @eerhardt, @dotnet/area-system-text-regularexpressions Issue DetailsContributes to #61895 What we really care about is the functional tests, but getting this part committed separately.
|
src/libraries/System.Text.RegularExpressions/tests/RegexParserTests.cs
Outdated
Show resolved
Hide resolved
@$" [InlineData(@""{pattern}"", RegexOptions.{options.ToString()}, RegexParseError.{error.ToString()}, {offset})]"; | ||
|
||
// File.AppendAllText(@"/tmp/out.cs", s + "\n"); // for updating baseline | ||
} |
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.
I don't understand... what's the purpose of this method?
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.
It updates the baseline: I can take a bunch of presumably-invalid regex inputs from someplace, and turn them into this format:
[InlineData("SOMEREGEX1", RegexOptions.None, null)]
[InlineData("SOMEREGEX2", RegexOptions.None, null)]
...
I paste those into the test, uncomment this line, and run the test, and it emits into that file exactly what I need to paste in eg
[InlineData(@"SOMEREGEX1", RegexOptions.None, RegexParseError.UnrecognizedEscape, 3)]
[InlineData(@"SOMEREGEX2", RegexOptions.None, InsufficientClosingParentheses, 2)]
...
I then replace what I pasted in with those, and I have my updated test.
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.
is that OK? I'm finding this a useful approach: have the test construct the baseline.
Of course, I'll eyeball to satisfy myself that the results are good. In some cases, I'm emitting in a different format locally to diff against the original test output as well.
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.
Added a comment.
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.
Is it possible to do easily as a standalone, commented out test? I think what I'm objecting to is it's modifying other tests with dead code that is almost certain to rot.
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.
Sure, I can change it to that.
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.
Other than the CI failures from a couple of the new tests, LGTM.
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.
LGTM, Thanks Dan.
I'll do that cleanup in my next PR. |
Contributes to #61895
What we really care about is the functional tests, but getting this part committed separately.