Repository navigation
test: make SharedType.None leakage tests independent of build order - #7385
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Replace fixed ID assertions with ownership checks tests/TUnit.TestProject/ClassDataSourceSharedNoneRegressionTests.cs |
The tests remove the ID-counter reset and session hook. They track instance ID ownership with a concurrent dictionary, check that each instance starts with a mutation value of zero, and retain distinct mutation values for each test. The comments now state that construction order is not fixed. |
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Other · Severity of issue fixed: Low
Merge Risk: 
Minimal · up to 9bc85
-
No merge-blocking risk is established by the supplied evidence.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#7250requires the three SharedType.None tests to verify unique, unmutated instances without relying on construction order. The reviewed code records each InstanceId in ConcurrentDictionary, rejects an ID owned by another test, checks MutationValue is zero, and mutates each instance after the checks. It removes the fixed 1/2/3 assertions and the counter reset. These changes satisfy the linked coding requirements.
Full details: Out of Scope Changes check
-
Explanation
The changes are limited to the regression tests and their test helper state in ClassDataSourceSharedNoneRegressionTests.cs. The ConcurrentDictionary, mutation checks, ID tracking, and removal of the obsolete reset support the requirements in issue
#7250. No unrelated implementation change is present in the reviewed diff.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks each ID with care
No fixed order waits among them there
Each instance starts at zero
Then takes its test’s own value
The counters rest; the checks stay fair
And flaky runs hop out of sight
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ReviewThis is a sound fix for the flaky test. The old tests assumed a fixed ID order (1/2/3) from a static counter, which depends on when instances are built. Checking that no ID is received by two different tests, plus a zero Observations (none blocking):
LGTM. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
ReviewThis fixes the flaky test (#7250) properly. The old tests assumed a fixed construction order (
Minor, non-blocking:
LGTM. |
[Low impact] The PR appears safe to merge. SummaryThe PR makes the leakage tests independent of construction order.
Reviews (1) · Last reviewed commit: "test: assert distinct SharedType.None in..." · Reviewed by Greptile |
Summary
ClassDataSourceSharedNoneNoLeakageTests.Test1/2/3_GetsUniqueInstanceassertedInstanceId == 1/2/3from a static counter. When the instances are built relative to the tests that run them is not fixed, so the tests failed intermittently.Each test now records the ID of the instance it received in a static dictionary. It fails if another test already received that ID (a shared instance) or if
MutationValueis non-zero (leaked mutation). All three tests now mutate the instance. I removed the[Before(TestSession)]counter reset. It is not needed now, and a reset that ran after an instance was built could have produced duplicate IDs.Validation
dotnet run -c Release -f net10.0 -- --treenode-filter "/*/*/ClassDataSourceSharedNone*/*", 4 runs in source-generated mode and 4 with--reflection: 5/5 passed in every run.SharedType.PerClass, and the new assertions failed withExpected to be equal to "Test1_GetsUniqueInstance".Closes #7250
Summary by CodeRabbit