Repository navigation
fix(tests): Stop a hung test from consuming the whole CI job - #24162
MartinZikmund wants to merge 10 commits into
Conversation
|
Claude finished @MartinZikmund's task in 6m 1s —— View job PR Review: fix(tests): Stop a hung test from consuming the whole CI jobTodo List
SummaryVerdict: LGTM with minor notes. No blocking bugs found. The implementation correctly addresses all three root causes described in the PR. What was reviewed
Specific findings (2 inline comments posted)Low — Informational — Cross-cutting observations
|
There was a problem hiding this comment.
Pull request overview
This PR hardens the runtime-test harness against hangs so a single stuck test (or Hot Reload test app run) can’t consume an entire CI shard and prevent publishing results.
Changes:
- Add a default 5-minute timeout for test bodies without an explicit
[Timeout], and skip retries when the harness itself times a test out. - Bound the Hot Reload test app run with a cancellation token and ensure timed-out runs kill the spawned process tree.
- Refactor Hot Reload process waiting/termination into
WaitForExitAsync+KillProcessTreehelpers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Uno.UI.RuntimeTests/Tests/HotReload/ProcessHelpers.cs | Adds cancellation-aware wait and process-tree kill helper for Hot Reload app runs. |
| src/Uno.UI.RuntimeTests/Tests/HotReload/Given_HotReloadWorkspace.cs | Applies an overall timeout budget to the HRApp run and uses the new kill/wait helpers. |
| src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UnitTest/UnitTestsControl.cs | Enforces a default test-body timeout and avoids retrying harness-cutoff timeouts. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
7b16a7b to
df4dc77
Compare
|
Claude finished @MartinZikmund's task in 4m 53s —— View job PR Review: fix(tests): Stop a hung test from consuming the whole CI jobTodo List
SummaryVerdict: LGTM with minor notes. No blocking bugs found. The three layers of protection are correctly implemented and compose well. What was reviewed
Specific findings (2 inline comments posted)Low — Low — Cross-cutting observations
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/Uno.UI.RuntimeTests/Tests/HotReload/Given_HotReloadWorkspace.cs:151
TestCleanupWrapperkills the HRApp process but never disposes theProcessinstance, which can leak OS handles across retries/runs. Dispose it after the best-effort kill.
[TestCleanup]
public void TestCleanupWrapper()
{
ProcessHelpers.KillProcessTree(_testAppProcess);
_testAppProcess = null;
}
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24162/wasm-skia-net9/index.html |
df4dc77 to
e5650d9
Compare
|
Claude finished @MartinZikmund's task in 4m 30s —— View job PR Review: fix(tests): Stop a hung test from consuming the whole CI jobTodo List
SummaryVerdict: LGTM with two low-severity notes (both carryovers from prior review rounds, still unaddressed). No new or blocking issues found in this sync. The three-layer protection strategy is correctly structured:
Inline findings (2 comments posted)
Both were flagged by earlier review rounds; neither is a blocker, but the disposal one is straightforward to fix (suggestion posted). |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24162/wasm-skia-net9/index.html |
e5650d9 to
85fc385
Compare
|
Claude finished @MartinZikmund's task in 3m 12s —— View job PR Review: fix(tests): Stop a hung test from consuming the whole CI jobTodo List
SummaryVerdict: LGTM with two low-severity notes (both are carryovers from prior rounds; neither is a blocker). The three-layer protection strategy is sound and correctly implemented:
Inline findings (2 comments — both carryovers)
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24162/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24162/docs/index.html |
|
The build 235438 found UI Test snapshots differences: Details
|
52ee436 to
02212f1
Compare
|
Claude finished @MartinZikmund's task in 5m 25s —— View job PR Review: fix(tests): Stop a hung test from consuming the whole CI jobTodo List
Verdict: LGTM, with one new medium-severity diagnostic gap worth a follow-upThis sync adds the non-retryable build cutoff, cut-off logging with the actual exception, and coverage in
New finding (1 inline comment posted)
Cross-cutting observations
|
| /// Budget for building the app. This runs from <c>[TestInitialize]</c>, so a hang here is only bounded | ||
| /// by whatever the harness applies to initialize — never leave it unbounded. | ||
| /// </summary> | ||
| private static readonly TimeSpan BuildTimeout = TimeSpan.FromMinutes(10); |
There was a problem hiding this comment.
BuildTimeout (10 min) is longer than the only [Timeout] that ever wraps a call to BuildTestApp() — the [Timeout(8 * 60 * 1000)] on When_HotReloadScenario (line 73), which bounds Initialize() (and therefore BuildTestApp()) via UnitTestsControl's AwaitWithBudget. Since this class has only one [TestMethod], a hung build will always hit the outer 8-minute cutoff first.
That means the catch (OperationCanceledException e) when (cts.IsCancellationRequested) block at line 269-274 — and the specific message it builds, including the captured build output (builder) — is unreachable for a genuine build hang. What actually surfaces is the outer, generic TestBodyTimeoutException: "[TestInitialize] of When_HotReloadScenario timed out after 00:08:00", without the build log that would tell you why.
This is the same numeric relationship flagged in an earlier review round for a different reason (retry-safety, now fixed via NonRetryableTestFailureException on both layers). But that fix only addressed retryability — it didn't correct the ordering, so the diagnostic goal of this PR (a build hang naming its own cause) is still defeated in practice. The doc comment above (line 44-46: "a hang here is only bounded by whatever the harness applies to initialize — never leave it unbounded") and the sibling reasoning for TestAppTimeout (line 71-72: "It must stay above TestAppTimeout so the app is killed and reported before the harness abandons the test") both point at the same invariant this value violates: BuildTimeout needs to stay below the outer [Timeout], not above it.
Suggest lowering BuildTimeout to something under 8 minutes (mirroring TestAppTimeout's relationship to the outer bound), so the build-specific NonRetryableTestFailureException — with its captured build log — fires before the generic initialize cutoff does.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24162/wasm-skia-net9/index.html |
|
The build 235811 found UI Test snapshots differences: Details
|
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24162/docs/index.html |
Only 2 of 4675 [TestMethod]s carried [Timeout], and GetTestTimeout returned null otherwise, so the harness awaited the test body bare. A single hung test therefore consumed the whole 60-minute CI job and the run produced no results file at all, losing the outcome of every other test in the shard. Release builds now fall back to a 5 minute per-body timeout, overridable with UNO_TEST_DEFAULT_TIMEOUT_SECONDS (non-positive opts out). DEBUG keeps the unbounded behaviour so local debugging under a breakpoint is unaffected. Also cancel the timeout delay once a test completes, so a run no longer keeps one pending timer per test alive for the whole timeout window. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Tj7eBARpKztfeLfaLTWde7
A bounded body still costs the shard three times over: the harness retries a failed test up to config.Attempts, so a stuck test burned three full timeout windows before the run moved on. Cut off tests now skip the retries. The signal is a harness-private exception type rather than TimeoutException itself, so a TimeoutException a test raises from one of its own waits — EventTester, Event, the various cts.Token.Register helpers — stays an ordinary, retryable failure. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MQfvkH3k6HdkmtNATbfVL1
RunTestApp waited on the HRApp with a token that was CancellationToken.None at the call site and dropped inside ProcessHelpers.RunProcess, so the run had no bound at all. When a hot-reload session breaks server-side, every remaining test in the app burns its own five-minute budget instead, and a run that takes ninety seconds when healthy took twenty minutes — three attempts of which consumed the entire CI job. Give the run a six-minute budget, honour the token by killing the process tree rather than abandoning an orphan that keeps holding its dev-server connection, and record the app before waiting on it so the cleanup can reach it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01MQfvkH3k6HdkmtNATbfVL1
Review found the change did not cover the case that motivated it: the budget wrapped only the returned body Task, while `[TestInitialize]` was awaited bare — and the hot reload hang lives in initialize, which builds an app. Both awaits now go through one `AwaitWithBudget` helper, which also replaces the duplicated WhenAny/Delay shape. The Release default moves from 5 to 10 minutes. Five collided with the harness's own waits: `SynchronouslyTickUIThread` alone allows five minutes *per tick*, so a healthy multi-tick test could be cut off and its own diagnostic lost. Also from the panel: the resolved budget is reported once per run so a cut-off is attributable, an unreadable `UNO_TEST_DEFAULT_TIMEOUT_SECONDS` says so instead of falling back silently, the value is clamped below `Timer.MaxSupportedTimeout` (which would otherwise throw on every test), and an abandoned body names itself if it ever finishes, since it keeps touching the visual tree. The cap is now documented where test authors will meet it, including both limits it carries: a cut-off abandons rather than cancels, and only awaited work is bounded — a synchronous body or a wedged UI thread still escapes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014LKUHFiW2J8nNFy7FmuCsd
The app budget threw a `TimeoutException`, which the harness retries — so a broken session still cost three attempts, contradicting the commit that introduced the retry rule. It now fails through `Assert.Fail`, leaving the harness `[Timeout]` as the single bound that decides the outcome, reported once. `BuildTestApp` was the remaining unbounded wait: it runs from `[TestInitialize]`, awaited `WaitForExitAsync()` with no token, and never reaped the build. It gets its own budget, kills the tree on expiry, and disposes the process. Diagnostics the CI log could not show before: the kill-failure path logged at Debug under a category filtered to Warning, so the one line explaining "the next attempt fought a surviving app" was invisible; a tree still alive after the grace period was silent; and cleanup now says when it had to kill an app that never exited on its own. `$"..." + args.Data ?? "<Empty>"` parsed as `(concat) ?? ...`, so the fallback was dead and a null line logged a bare prefix. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014LKUHFiW2J8nNFy7FmuCsd
…ific log call `typeof(UnitTestsControl).Log()` broke the WinAppSDK build: this file compiles against two logging APIs, and outside `HAS_UNO` `_log` is an `Microsoft.Extensions.Logging.ILogger` where that extension does not resolve. The parse stays pure and records the rejected value instead; the run header reports it through `_log`, which both flavours already use. Also drops a `string?` that the file's non-nullable context rejected. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_014LKUHFiW2J8nNFy7FmuCsd
The app budget failed through Assert.Fail, which the harness retries, so a wedged session was rebuilt and relaunched twice more. It now raises NonRetryableTestFailureException, which the harness reports without retrying, as it already does for its own cut-offs. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01WHHcu5U9N25wvKGNFCrpJm
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01WHHcu5U9N25wvKGNFCrpJm
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
02212f1 to
b088cef
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The harness timeout can abandon BuildTestApp before its build timeout, potentially leaving a dotnet build process running without cleanup.
Review effort: Lite
Findings: 1
Resolved since last review (3)
| [TestMethod] | ||
| // Raises the harness default for this test, which builds an app before it runs one. It must stay above | ||
| // TestAppTimeout so the app is killed and reported before the harness abandons the test. | ||
| [Timeout(8 * 60 * 1000)] |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-24162/docs/index.html |
|
Claude finished @MartinZikmund's task in 3m 21s —— View job PR Review: fix(tests): Stop a hung test from consuming the whole CI jobTodo List
Verdict: LGTM, with one confirmed open issue carried forward from prior roundsThis sync (
Cross-cutting observations
|
| /// Budget for building the app. This runs from <c>[TestInitialize]</c>, so a hang here is only bounded | ||
| /// by whatever the harness applies to initialize — never leave it unbounded. | ||
| /// </summary> | ||
| private static readonly TimeSpan BuildTimeout = TimeSpan.FromMinutes(10); |
There was a problem hiding this comment.
This is the same BuildTimeout (10 min) vs. outer [Timeout(8 * 60 * 1000)] (line 73) ordering flagged in the 2026-09-23/25 review rounds, and it's still unresolved in this sync — BuildTimeout has never been changed from 10 minutes across the PR's history. The retry-safety half of that finding is fixed (BuildTestApp now throws NonRetryableTestFailureException), but the ordering is not, and it has a sharper consequence than "lost diagnostics":
Initialize() (which calls BuildTestApp()) is bounded by the outer 8‑minute budget via AwaitWithBudget in UnitTestsControl.cs. AwaitWithBudget abandons the task rather than cancelling it (by design, per its own doc comment), so when the outer cutoff fires at 8 minutes, BuildTestApp's own CancellationTokenSource(BuildTimeout) (line 257) is still running — it won't fire until the 10‑minute mark. In between:
- The harness has already reported
TestBodyTimeoutExceptionand moved on to[TestCleanup](TestCleanupWrapper, line 163), then to the next test in the shard. TestCleanupWrapperonly knows about_testAppProcess(the app-run process) — the buildprocessinBuildTestAppis a local variable, never tracked in a field, so cleanup can't kill it.- The orphaned
dotnet buildkeeps running for up to ~2 more minutes, competing for CPU/disk/the dev-server port with whatever test runs next in the shard, untilBuildTestApp's ownctsfinally fires and kills it viaProcessHelpers.WaitForExitAsync's catch.
This is exactly the failure mode the PR sets out to prevent for the app-run phase (TestAppTimeout = 6 min is deliberately kept below the 8‑minute outer bound so the process is killed promptly) — but the build phase has the relationship inverted. Suggest lowering BuildTimeout to something under 8 minutes, mirroring TestAppTimeout.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24162/wasm-skia-net9/index.html |
|
The build 237171 found UI Test snapshots differences: Details
|
|
Tick the box to add this pull request to the merge queue (same as
|


GitHub Issue: closes #24471; also #24111 (addresses item 2 only — the macOS native-peer defects of item 1 are #24112, so this deliberately does not auto-close that one). Supersedes #24472.
PR Type:
🏗️ Build or CI related changes
What changed? 🚀
Addresses item 2 of #24111 — "Test bodies have no timeout, so one hang costs the entire shard" — after it took down
Tests - Desktop Skia Windowson build7.0-dev.445(job cancelled at its 60-minute limit, no results published).What happened on that build
EmitDifferencestarted throwingNullReferenceExceptioninDefinitionMap.GetPreviousMethodHandle, and every update in that session then failed the same way. Three tests inGiven_FileAddUpdateRemoveare already[Ignore]d with exactly this message, so it is a known-bad area of Edit-and-Continue rather than anything the PR under test changed.RunTestAppwaited on the app with a token that wasCancellationToken.Noneat the call site and dropped insideProcessHelpers.RunProcess.PublishTestResultsfound nothing — every other test in the shard reported nothing.The changes
A default bound on every awaited test step. The harness only bounded Initialize/Cleanup steps; the body was awaited bare unless it carried an explicit
[Timeout], which one of ~4,600[TestMethod]s does. Release builds now apply a default per-step budget, overridable withUNO_TEST_DEFAULT_TIMEOUT_SECONDS(non-positive opts out); DEBUG stays unbounded so local debugging under a breakpoint is unaffected.The budget covers
[TestInitialize]as well as the body — both go through oneAwaitWithBudgethelper. That matters here specifically: this PR's own motivating hang lives in initialize, which builds an app.The default is 10 minutes, not 5. Five collides with the harness's own waits —
SynchronouslyTickUIThreadallows five minutes per tick, so a healthy multi-tick test could be cut off and its own, more useful, diagnostic lost. The default has to exceed the longest wait a test can legitimately perform.Not retrying a test the harness cut off. A bounded body still cost the shard three times over. Cut-off tests now skip the retries. The signal is a harness-private exception type rather than
TimeoutExceptionitself, so aTimeoutExceptiona test raises from one of its own waits —EventTester,Event, thects.Token.Registerhelpers — stays an ordinary, retryable failure.Bounding the hot-reload app. A six-minute budget on a single HRApp run (4× the healthy ~90s), and a separate budget on the build, which runs from
[TestInitialize]and previously awaitedWaitForExitAsync()with no token at all. Cancellation kills the process tree, because the app is started throughdotnet runand abandoning the wait leaves an orphan still holding its dev-server connection; the app process is recorded before being waited on, so a hang leavesTestCleanupsomething to kill. A wedged run fails withNonRetryableTestFailureException, which the harness reports once without retrying — throwingTimeoutException(or a plainAssert.Fail) there would have been retried three times, contradicting the point above.Diagnostics the CI log could not show. The kill-failure path logged at
Debugunder a category filtered toWarning, so the one line explaining "the next attempt fought a surviving app" was invisible. A process tree still alive after the grace period was silent. Cleanup now says when it had to kill an app that never exited. The resolved budget is reported once per run, so a cut-off five minutes into a shard is attributable, and an unreadableUNO_TEST_DEFAULT_TIMEOUT_SECONDSsays so rather than falling back silently.Known limits, deliberately not fixed here
await, still escapes — the timer itself needs the loop to run. This is most acute on WASM, which is single-threaded.Effect
The same wedged session costs one bounded attempt instead of 48 minutes of retries — and, the part that actually matters, the shard still publishes results for everything else, with the failing test naming its own cause.
Not addressed: the underlying Roslyn Edit-and-Continue
NullReferenceException, an upstream compiler defect.Validation
Skia desktop, Release (what CI builds and runs):
Given_ContentPresenter269/270 (one pre-existing inconclusive), and the run header reportsDefault test body budget: 00:10:00.UNO_TEST_DEFAULT_TIMEOUT_SECONDS=1overGiven_ListViewBase: 6 tests cut off, each naming itself and its budget; 0 retries; app exit 0 — and the results XML is still written (146 total, 138 passed, 7 failed). That last property is the one that was missing when the job was cancelled.Given_HotReloadWorkspace.When_HotReloadScenariopasses in 82 s against a ~90 s CI baseline, and a negative control with the app budget cut to 20 s showed 3 bounded attempts,HRApp did not exit in time, killing iton each, and no orphaned processes.PR Checklist ✅
.claude/rules/runtime-tests.md, including both limits it carries.Screenshots Compare Test Runresults.🤖 Generated with Claude Code
https://claude.ai/code/session_014LKUHFiW2J8nNFy7FmuCsd
Update (2026-09-23): rebased on master, review addressed
TestAppTimeoutthrowsNonRetryableTestFailureException(new,Uno.Testing, derives fromAssertFailedException), which the harness reports without retrying, like its own cut-offs. PreviouslyAssert.Failsent it through the ordinary retry branch.Given_HotReloadWorkspace_Budget(short-budget, self-cancel, and in-budget cases).Retry 1/2andRetry 2/2for a plainAssert.Failand no retry forNonRetryableTestFailureException.