-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add regex "unit tests" test project #65944
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: @dotnet/area-system-text-regularexpressions Issue DetailsThis follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
|
src/libraries/System.Text.RegularExpressions/tests/UnitTests/Stubs.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/tests/UnitTests/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer code. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate. I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.
src/libraries/System.Text.RegularExpressions/System.Text.RegularExpressions.sln
Outdated
Show resolved
Hide resolved
You don't have to do this in your PR, but When creating these I did feel like they were more unit-test type of tests as opposed to the rest of our functional tests. I can, in a follow up PR, move these to the UnitTest project and use RegexRunner directly as opposed to using reflection to get fields/properties/methods |
...em.Text.RegularExpressions/tests/FunctionalTests/System.Text.RegularExpressions.Tests.csproj
Outdated
Show resolved
Hide resolved
...stem.Text.RegularExpressions/tests/UnitTests/System.Text.RegularExpressions.UnitTests.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/System.Text.RegularExpressions.sln
Outdated
Show resolved
Hide resolved
edfa221 to
17059b5
Compare
Are these intended to be running in PR right now? The libraries test build just looks for runtime/src/libraries/tests.proj Line 371 in d9eafd0
Other existing unit tests do |
Well that's annoying :-) Thanks for noticing. Will fix. |
|
Oh I missed that! I would’ve sworn it was doing *Tests.csproj |
This follows the convention used by the networking tests, which typically have two distinct test projects per library: functional tests and unit tests. The former are what we typically refer to as our tests for a library, whereas the latter build product source into the test project in order to directly validate internals (an alternative to this is to use InternalsVisibleTo, but that negatively impacts trimming and makes it more challenging to maintain a property boundary for the functional tests). All the existing tests are moved unedited into the FunctionalTests, and a new UnitTests project is added with some initial tests for the RegexTreeAnalyzer and RegexFindOptimizations code; we can expand them further subsequently. The generator parser tests were also consolidated into the functional tests, as there's no longer a good reason for those few tests to be separate.
I fixed a few bugs in RegexTreeAnalyzer as a result. In particular, we were over-annotating things as potentially containing captures or backtracking because in the implementation we were using the lookup APIs meant to be used only once all analysis was complete. This doesn't have a negative functional impact, but it does negatively impact perf of compiled / source generator, which then generate unnecessary code. We were also incorrectly conflating atomicity conferred by a grandparent with atomicity conferred by a parent; we need MayBacktracks to reflect only the atomicity directly contributed by a node, not by its parent's influence, as we need the parent to be able to understand whether the child might backtrack.