All the regex parsing tests in their own branch.#25520
All the regex parsing tests in their own branch.#25520jcouv merged 63 commits intodotnet:features/embeddedRegexfrom
Conversation
|
@dotnet-bot retest windows_debug_vs-integration_prtest please |
| Assert.True(regex.GetGroupNames().Where(v => !int.TryParse(v, out _)).OrderBy(v => v).SequenceEqual( | ||
| tree.CaptureNamesToSpan.Keys.OrderBy(v => v))); | ||
| } | ||
| catch (IndexOutOfRangeException) |
There was a problem hiding this comment.
Try/catching seems too loose. Can tests that trigger those cases pass a parameter to signal their expectation? #Closed
There was a problem hiding this comment.
sure. i can do that. #Closed
There was a problem hiding this comment.
Ok. I did this. Tests now need to explicitly state if they expect hte regex constructor to throw. Also, we only wrap creating the .net regex in a try/catch. That way we're only checking for exceptions in it, and we're not accidentally catching exceptions in the roslyn regex system. #Closed
| Assert.Null(tree); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Maybe I missed it, but do we check round-tripping? #Closed
There was a problem hiding this comment.
I don't. But that's a good idea. I will add that to the tests! #Closed
There was a problem hiding this comment.
Oh, nevermind. I do that test that. Those are the CheckInvariants and CheckCharacters calls that we make. #Closed
There was a problem hiding this comment.
I'm thinking just a ToString() call on RegexTree and comparing with the known string. #Closed
There was a problem hiding this comment.
I'd prefer to not create a ToString (yet) that isn't used anywhere but tests. We already enforce hte invariants here through the supported API. #Closed
| } | ||
|
|
||
| [Collection(nameof(MyCollection))] | ||
| public partial class CSharpRegexParserTests |
There was a problem hiding this comment.
CSharpRegexParserTests [](start = 25, length = 22)
From reading the doc on Collection, I expected to find some tests (annotated with [Fact]) in this class.
Is this meant to only be run manually? #Closed
There was a problem hiding this comment.
Yup. This was all done manyally for generatin tests. (hence _TestGeneration). #Closed
There was a problem hiding this comment.
Ok. It seems useful to keep this file, but please add some documentation.
In reply to: 212121143 [](ancestors = 212121143)
There was a problem hiding this comment.
Given that this code already provides a way of regenerating the baselines. What do you think of better representing spans?
In reply to: 212122968 [](ancestors = 212122968,212121143)
Such spans are not very useful (reviewer cannot verify). I would have recommended quoting the text of that span... :-S #Closed Refers to: src/Workspaces/CSharpTest/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs:166 in 7767ce6. [](commit_id = 7767ce6, deletion_comment = False) |
To update so many test baselines, Fred has a tool which could be useful (with some adaptation). The basic flow:
I feel pretty strongly about doing something to improve the readability of these spans, but I'd be ok if it's done separately. In reply to: 415178848 [](ancestors = 415178848) Refers to: src/Workspaces/CSharpTest/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs:166 in 7767ce6. [](commit_id = 7767ce6, deletion_comment = False) |
Another idea would be to fix the test framework so that any test that is added or updated from now on would include more details, but all those initial tests would be left as-is. In reply to: 415182382 [](ancestors = 415182382,415178848) Refers to: src/Workspaces/CSharpTest/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs:166 in 7767ce6. [](commit_id = 7767ce6, deletion_comment = False) |
Is it possible to use digits for capture names? For instance, Refers to: src/Workspaces/CSharpTest/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs:105 in 7767ce6. [](commit_id = 7767ce6, deletion_comment = False) |
In general, I didn't understand the separation of tests: "Basic", "DotnetNegative" and "Reference". Could you clarify? Refers to: src/Workspaces/CSharpTest/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs:8 in 7767ce6. [](commit_id = 7767ce6, deletion_comment = False) |
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (iteration 54).
I think something should be done about validation of spans in captures. We can discuss some options.
I need some overview for "TestGeneration" file, so that I can effectively review it.
I would be ok with that. :) |
Yes. You can see that in ReferenceTest123. |
I can comment. "basic" is me going through every codepath in the lexer/parser and trying to hit it. |
This file was used by me for some times when i had to go update like a thousand tests at once. It was easier to basically run the existing tests through a helper funciton that then spat out the new test baselines. I don't really need it anymore and it can be removed. For anything that has spans right now (for example Captures, or Diagnostics), i'm happy to make it include text. In that regard, TestGeneration would likely be useful to respit out all the test baselines again. |
SGTM. I'll do so tonight. I'll leave the spans in, but i'll also give the text those spans represent. Does that work for you? |
Yes, that sounds good. Thanks! |
|
@jcouv I've updated all the baselines (yaay for having a tool to do that) :) Let me know what you think. |
Awesome. That's much better! In reply to: 415183243 [](ancestors = 415183243,415182382,415178848) Refers to: src/Workspaces/CSharpTest/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs:166 in 7767ce6. [](commit_id = 7767ce6, deletion_comment = False) |
jcouv
left a comment
There was a problem hiding this comment.
LGTM (iteration 63).
Thanks a lot for addressing the span issue!
Also, a super great reason to keep around the baseline regenerator :D |
|
@jcouv can you merge in? |
Followup to #23984. I've pulled out the tests to make that PR easier to review.