Skip to content

Make unfinished dependency regression independent of scheduling - #7567

Merged
thomhurst merged 1 commit into
mainfrom
issue-7564-dependency-regression
Nov 4, 2026
Merged

thomhurst merged 1 commit into
mainfrom
issue-7564-dependency-regression

Conversation

@thomhurst

@thomhurst thomhurst commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Test3 assumed Test1 would still be running after a five-second delay, so scheduling could make the unfinished-test assertion fail. Retrieve Test3 itself instead: its result is guaranteed to be unfinished while its body runs, exercising the same guard without timing assumptions.

Closes #7564

Validation: Release/net10.0 targeted DependsOnTests2 runs pass (3 tests each) in generated and reflection modes with --maximum-parallel-tests 4, and in generated mode with one parallel slot. Existing analyzer and nullable build warnings are tracked in #7410.

Summary by CodeRabbit

  • Tests
    • Updated a test to check that querying a test’s own dependencies throws the expected exception while the test is running.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Test3 regression test now checks that querying its own dependencies throws the unfinished-tests exception. A comment states that Test3 remains unfinished while its body runs.

Changes: Unfinished dependency check

Layer / File(s) Summary
Check the running test
tests/TUnit.TestProject/DependsOnTests2.cs
Test3 now queries its own dependencies and expects the unfinished-tests exception. A comment states that the test is unfinished while its body runs.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other · Severity of issue fixed: Low

Merge Risk: Minimal · up to ceb12

No actionable merge-blocking risk was found in the reviewed change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the unfinished-dependency regression test no longer depends on scheduling timing. The raw summary confirms Test3 now queries its own dependencies while running, instea…
Linked Issues check Passed [#7564] The issue requires a deterministic regression check for unfinished dependency access. It names two options: synchronize the tests, or move the check into focused unit coverage. The PR uses a t…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes one file, tests/TUnit.TestProject/DependsOnTests2.cs. It changes two lines: the GetTests argument in Test3 (from nameof(Test1) to `nameof(Test3…
Docstring Coverage Passed 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. Documentat…
Full details: Title check

Explanation

The title names the main change: the unfinished-dependency regression test no longer depends on scheduling timing. The raw summary confirms Test3 now queries its own dependencies while running, instead of querying Test1 and relying on it still being unfinished. The title is concise, specific, and matches the linked issue #7564 and the PR objectives.

Full details: Linked Issues check

Explanation

[#7564] The issue requires a deterministic regression check for unfinished dependency access. It names two options: synchronize the tests, or move the check into focused unit coverage. The PR uses a third approach that meets the stated objective. In tests/TUnit.TestProject/DependsOnTests2.cs, Test3 now calls TestContext.Current!.Dependencies.GetTests(nameof(Test3)) instead of GetTests(nameof(Test1)). Test3 is the running test, so its result is unfinished for the whole body. The expected exception and message are unchanged. The check no longer depends on Test1 timing, so the scheduling race described in the issue is removed. The author reports passing Release/net10.0 runs in reflection and generated modes with --maximum-parallel-tests 4, and in generated mode with one slot. Those runs support the deterministic behavior. I did not read the dependency guard implementation itself, so the self-query behavior rests on the PR description and the reported runs. The [After(Class)] start-time assertion and the Test1/Test2 ordering are untouched and are not part of this issue.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes one file, tests/TUnit.TestProject/DependsOnTests2.cs. It changes two lines: the GetTests argument in Test3 (from nameof(Test1) to nameof(Test3)) and one explanatory comment. Both changes directly implement #7564. No production code, unrelated tests, or configuration files change.

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.

Share

A rabbit checks the test at play,
“My own dependencies,” it says today.
While Test3 runs, it stays unfinished,
The exception check is now distinguished.
Then hops away beneath the moon.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 675d64c3-171e-43f0-8089-7ffb12a7cd6d
Commits

Reviewing files that changed from the base of the PR and between 38b7f77 and ceb12cb.

Files selected for processing: 1
  • tests/TUnit.TestProject/DependsOnTests2.cs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@thomhurst

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T11:55:58.981969Z ceb12cb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Review

Approve. This is a one-line test fix and I found no problems.

  • Root cause: the old Test3 called GetTests(nameof(Test1)) and expected Test1 to still be running. Test1 only sleeps for 5 seconds, so the assertion depended on scheduling.
  • Fix: Test3 now asks for itself. In src/TUnit.Core/TestContext.Dependencies.cs, all three GetTests overloads throw when any matched test has Result == null. The running test's own result is null for the whole body, so the exception is guaranteed.
  • Lookup: GetTests(string) passes empty parameter lists. Test3 has no parameters, so it matches exactly itself. Test1 has parameters, which is also why the old code only matched it loosely.
  • Coverage kept: the Test1 to Test2 [DependsOn] timing check in AssertStartTimes is unchanged.

The PR description says it ran this in both generated and reflection modes, which is what the repo's rules ask for.

Optional: the new comment could name the invariant it relies on, which is that Result stays null until the test completes. That would help a reader who wonders why the test queries itself.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 876e64c7ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Makes the unfinished-test regression independent of scheduling.

  • Test3 checks the unfinished-test rule without relying on timing.

Reviews (2) · Last reviewed commit: "Fix unfinished dependency regression sch..." · Reviewed by Greptile

@thomhurst

Copy link
Copy Markdown
Owner Author

Reviewed all review surfaces for 876e64c: Claude and Codex approve, Greptile reports safe to merge, and there are no inline findings or unresolved threads. Keeping the current explanatory comment: it states the unfinished-test invariant needed by this regression; naming the internal Result field is optional. Promoting to ready for CI and the ready-for-review Claude run.

@thomhurst
thomhurst marked this pull request as ready for review November 4, 2026 06:50
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Review: LGTM.

The old Test3 assumed Test1 was still inside its 5s delay, which is a timing race. The new version asks for Test3 itself. I checked TestContext.Dependencies.GetTests(string) in src/TUnit.Core: it throws the same "Cannot get unfinished tests" error whenever any matching test has Result == null. A running test has no result yet, so the throw is guaranteed and doesn't depend on scheduling. It still exercises the same guard.

The change is test-only and small, and the comment explains why the new target is safe. It also doesn't disturb AssertStartTimes, which only depends on Test1 and Test2.

Nothing else to flag. I didn't run the tests myself; the PR description reports passing runs in both generated and reflection modes.

@thomhurst
thomhurst force-pushed the issue-7564-dependency-regression branch from 876e64c to ceb12cb Compare November 4, 2026 11:54
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Review: LGTM.

The change removes the timing assumption from Test3. The old version needed Test1 to still be running after a 5s delay, which depended on scheduling. The new version looks up Test3 itself. GetTests(string) in src/TUnit.Core/TestContext.Dependencies.cs throws when any matched test has Result == null, and the running test's own result is null for the whole of its body. So the guard is exercised every time, with no race.

Test3 has no parameters and the lookup passes empty parameter arrays, so it matches Test3 only. The expected message is unchanged and matches the source.

No design concerns. This is a test-only change that fixes the flake in #7564.

@thomhurst
thomhurst merged commit f3fb950 into main Nov 4, 2026
27 checks passed
@thomhurst
thomhurst deleted the issue-7564-dependency-regression branch November 4, 2026 12:57

This branch was previously deployed

1 inactive deployment
Pull Requests — ceb12cb4 Deployed Nov 4, 2026 by thomhurst via modularpipeline (ubuntu-latest) #21169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unfinished dependency regression assumes Test3 starts before Test1 finishes

1 participant