Skip to content

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

Merged
merged 8 commits into from
Dec 3, 2021
Merged

Conversation

danmoseley
Copy link
Member

Contributes to #61895

What we really care about is the functional tests, but getting this part committed separately.

@ghost
Copy link

ghost commented Nov 27, 2021

Tagging subscribers to this area: @eerhardt, @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

Issue Details

Contributes to #61895

What we really care about is the functional tests, but getting this part committed separately.

Author: danmoseley
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: -

@$" [InlineData(@""{pattern}"", RegexOptions.{options.ToString()}, RegexParseError.{error.ToString()}, {offset})]";

// File.AppendAllText(@"/tmp/out.cs", s + "\n"); // for updating baseline
}
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a comment.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

@stephentoub stephentoub left a 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.

@joperezr joperezr self-assigned this Nov 29, 2021
Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks Dan.

@joperezr joperezr added the needs-author-action An issue or pull request that requires more info or actions from the author. label Nov 29, 2021
@danmoseley
Copy link
Member Author

I'll do that cleanup in my next PR.

@ghost ghost removed the needs-author-action An issue or pull request that requires more info or actions from the author. label Dec 3, 2021
@danmoseley danmoseley merged commit c9f9697 into dotnet:main Dec 3, 2021
@danmoseley danmoseley deleted the nim.tests branch December 3, 2021 19:52
@ghost ghost locked as resolved and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants