Skip to content

fix(tests): Stop a hung test from consuming the whole CI job - #24162

Open
MartinZikmund wants to merge 10 commits into
masterfrom
dev/mazi/hr-test-timeout
Open

MartinZikmund wants to merge 10 commits into
masterfrom
dev/mazi/hr-test-timeout

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

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 Windows on build 7.0-dev.445 (job cancelled at its 60-minute limit, no results published).

What happened on that build

  1. A hot-reload session broke server-side: the dev-server's Roslyn EmitDifference started throwing NullReferenceException in DefinitionMap.GetPreviousMethodHandle, and every update in that session then failed the same way. Three tests in Given_FileAddUpdateRemove are 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.
  2. Every remaining test inside the HRApp waited out its own budget, so a run that takes ~90 seconds when healthy took 14–21 minutes.
  3. Nothing bounded that: RunTestApp waited on the app with a token that was CancellationToken.None at the call site and dropped inside ProcessHelpers.RunProcess.
  4. The harness retried the test three times → 48 minutes in one test.
  5. The job hit its 60-minute limit and was cancelled, so PublishTestResults found 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 with UNO_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 one AwaitWithBudget helper. 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 — SynchronouslyTickUIThread allows 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 TimeoutException itself, so a TimeoutException a test raises from one of its own waits — EventTester, Event, the cts.Token.Register helpers — 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 awaited WaitForExitAsync() with no token at all. Cancellation kills the process tree, because the app is started through dotnet run and abandoning the wait leaves an orphan still holding its dev-server connection; the app process is recorded before being waited on, so a hang leaves TestCleanup something to kill. A wedged run fails with NonRetryableTestFailureException, which the harness reports once without retrying — throwing TimeoutException (or a plain Assert.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 Debug under a category filtered to Warning, 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 unreadable UNO_TEST_DEFAULT_TIMEOUT_SECONDS says so rather than falling back silently.

Known limits, deliberately not fixed here

  • A cut-off abandons the body rather than cancelling it — nothing can stop a body that is not cooperating. A runaway test keeps touching the visual tree, so it is logged again if it ever finishes. Whether the harness should instead poison the run and flush results is a design decision worth its own discussion.
  • Only awaited work is bounded. A synchronous body, or a UI thread wedged before the first await, still escapes — the timer itself needs the loop to run. This is most acute on WASM, which is single-threaded.
  • A guarantee that survives every hang cause would be writing the NUnit file incrementally as tests complete, rather than after the loop. That is strictly stronger than any timeout and is worth a follow-up.

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):

  • Healthy path unchanged: Given_ContentPresenter 269/270 (one pre-existing inconclusive), and the run header reports Default test body budget: 00:10:00.
  • Negative control with UNO_TEST_DEFAULT_TIMEOUT_SECONDS=1 over Given_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.
  • Earlier, on Windows: Given_HotReloadWorkspace.When_HotReloadScenario passes 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 it on each, and no orphaned processes.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable) — n/a, this is the test harness; validated by running it, see above.
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features)
    • The cap is documented for test authors in .claude/rules/runtime-tests.md, including both limits it carries.
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

🤖 Generated with Claude Code

https://claude.ai/code/session_014LKUHFiW2J8nNFy7FmuCsd


Update (2026-09-23): rebased on master, review addressed

  • A wedged hot reload app is now non-retryable: running out of TestAppTimeout throws NonRetryableTestFailureException (new, Uno.Testing, derives from AssertFailedException), which the harness reports without retrying, like its own cut-offs. Previously Assert.Fail sent it through the ordinary retry branch.
  • Covered by Given_HotReloadWorkspace_Budget (short-budget, self-cancel, and in-budget cases).
  • Runtime, Skia desktop Release: the three new tests pass. A throwaway probe showed Retry 1/2 and Retry 2/2 for a plain Assert.Fail and no retry for NonRetryableTestFailureException.

Copilot AI lite review requested due to automatic review settings August 21, 2026 15:31
@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Aug 21, 2026
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 6m 1s —— View job


PR Review: fix(tests): Stop a hung test from consuming the whole CI job

Todo List

  • Gather context and understand the request
  • Read changed files and review code
  • Post inline review comments for findings
  • Post summary

Summary

Verdict: LGTM with minor notes. No blocking bugs found. The implementation correctly addresses all three root causes described in the PR.

What was reviewed

File Changes Assessment
UnitTestsControl.cs Default 5-min body timeout; TestBodyTimeoutException; retry suppression ✅ Correct
Given_HotReloadWorkspace.cs Layered CTS + outer [Timeout]; _testAppProcess assigned before wait ✅ Correct
ProcessHelpers.cs WaitForExitAsync; KillProcessTree (entireProcessTree: true) ✅ Correct, minor note

Specific findings (2 inline comments posted)

Low — ProcessHelpers.cs:108 — KillProcessTree calls the synchronous process.WaitForExit(10_000) from inside WaitForExitAsync's catch block (async context), blocking a thread-pool thread for up to 10 seconds on the error path. Acceptable in test infra, but flagged for awareness.

Informational — UnitTestsControl.cs:1362 — DefaultTestBodyTimeout only applies when test.Method.ReturnType == typeof(Task). Synchronous hanging tests are not covered (inherent .NET limitation — no portable thread-abort in modern .NET). The remarks could note this exclusion explicitly.

Cross-cutting observations

  • TestBodyTimeoutException / retry suppression: The distinction between TestBodyTimeoutException (harness-level, no retry) and TimeoutException (test-level, retryable) is exactly the right design. Tests that use EventTester, Event, or their own cts.Token still get the standard retry path.
  • Timer cleanup: Cancelling timeoutCts before await resultingTask correctly releases the Task.Delay timer as soon as the test body completes, preventing 5-minute lingering timer registrations per test. The using var disposes cleanly in all paths (normal exit and exception unwind).
  • CTS assignment before WaitForExitAsync: _testAppProcess = p now happens before await ProcessHelpers.WaitForExitAsync(...). This closes the original race where TestCleanupWrapper had nothing to kill on a hung run.
  • Layered timeouts: TestAppTimeout (6 min inner CTS) + [Timeout(8 * 60 * 1000)] (8 min MSTest outer backstop) is correct layering. The inner CTS converts OperationCanceledException into a readable TimeoutException with a diagnostic message; the outer catches anything the inner misses.
  • Conventional Commits: Both commits follow the fix(tests): convention. ✅
  • Async/cancellation discipline: No .Result / .GetAwaiter().GetResult(), no async void, CancellationToken is honoured throughout. ✅
  • Braces: All new if/catch blocks use braces. ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + KillProcessTree helpers.

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.

Copilot AI review requested due to automatic review settings August 21, 2026 15:39
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/hr-test-timeout branch from 7b16a7b to df4dc77 Compare August 21, 2026 15:39
@github-actions

github-actions Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 53s —— View job


PR Review: fix(tests): Stop a hung test from consuming the whole CI job

Todo List

  • Gather context and understand the request
  • Read changed files and review code
  • Post inline review comments for findings
  • Post summary

Summary

Verdict: LGTM with minor notes. No blocking bugs found. The three layers of protection are correctly implemented and compose well.

What was reviewed

File Changes Assessment
UnitTestsControl.cs Default 5-min body timeout; TestBodyTimeoutException; retry suppression ✅ Correct
Given_HotReloadWorkspace.cs Layered CTS + outer [Timeout]; _testAppProcess assigned before wait ✅ Correct, minor note
ProcessHelpers.cs WaitForExitAsync; KillProcessTree (entireProcessTree: true) ✅ Correct, minor note

Specific findings (2 inline comments posted)

Low — Given_HotReloadWorkspace.cs:150 — _testAppProcess is killed and nulled but never disposed. Process is IDisposable and holds OS handles for the redirected stdout/stderr pipes. Suggested fix: capture, null, kill, then Dispose().

Low — ProcessHelpers.cs:108 — process.WaitForExit(10_000) is a synchronous blocking call invoked from an async method's catch block, stalling a thread-pool thread for up to 10 s on the error path. Replacing with await process.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(10)) keeps the async discipline consistent.

Cross-cutting observations

  • TestBodyTimeoutException / retry suppression: The distinction between TestBodyTimeoutException (harness-level, no retry) and TimeoutException (test-level, retryable) is the correct design. Tests using EventTester, Event, or their own cts.Token still get the standard retry path.
  • Timer cleanup: Cancelling timeoutCts before the await resultingTask correctly releases the Task.Delay timer as soon as the test body completes — no lingering 5-minute timer per test. The using var disposes cleanly in all paths.
  • CTS assignment before WaitForExitAsync: _testAppProcess = p now happens before await ProcessHelpers.WaitForExitAsync(...), closing the race where TestCleanupWrapper had nothing to kill on a hung run.
  • Layered timeouts: Inner CTS (6 min) + [Timeout(8 * 60 * 1000, CooperativeCancellation = false)] (8 min MSTest backstop) is correct layering. The inner CTS converts the cancellation into a readable TimeoutException with a diagnostic message; the outer catches anything the inner misses.
  • DefaultTestBodyTimeout static initializer: Reads the env var once at class-load time via GetDefaultTestBodyTimeout(). Order is safe — DefaultTestBodyTimeoutFallback is declared before DefaultTestBodyTimeout so it's already set when the static initializer runs.
  • Sync-test coverage: DefaultTestBodyTimeout is only applied when test.Method.ReturnType == typeof(Task). A synchronous test body that hangs cannot be interrupted portably in modern .NET — this is an inherent .NET limitation, not a bug in the PR.
  • Conventional Commits: All three commits follow the fix(tests): / test: convention. ✅
  • Async/cancellation discipline: No .Result / .GetAwaiter().GetResult(), no async void, CancellationToken honoured throughout (except the one pre-existing sync WaitForExit noted above). ✅
  • Braces and code style: All new if/catch/using blocks use Allman braces. ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • TestCleanupWrapper kills the HRApp process but never disposes the Process instance, which can leak OS handles across retries/runs. Dispose it after the best-effort kill.
	[TestCleanup]
	public void TestCleanupWrapper()
	{
		ProcessHelpers.KillProcessTree(_testAppProcess);
		_testAppProcess = null;
	}

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings August 22, 2026 09:46
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/hr-test-timeout branch from df4dc77 to e5650d9 Compare August 22, 2026 09:46
@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 30s —— View job


PR Review: fix(tests): Stop a hung test from consuming the whole CI job

Todo List

  • Gather context and understand the request
  • Read changed files and review code
  • Post inline review comments for findings
  • Post summary

Summary

Verdict: 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:

  • UnitTestsControl — harness-level TestBodyTimeoutException (no retry) vs test-level TimeoutException (retryable) is the right distinction. Timer cleanup via timeoutCts.Cancel() before await resultingTask is correct. Static-initializer ordering (DefaultTestBodyTimeoutFallback before DefaultTestBodyTimeout) is safe.
  • Given_HotReloadWorkspace — _testAppProcess = p before WaitForExitAsync closes the cleanup race. The when (cts.IsCancellationRequested) guard correctly distinguishes the inner 6-minute budget CTS from any other cancellation. Layered timeouts (6-min inner CTS → TimeoutException → 8-min [Timeout] MSTest backstop) compose correctly.
  • ProcessHelpers — KillProcessTree(entireProcessTree: true) is the right choice for a dotnet run-launched child; the TOCTOU between HasExited and Kill is handled by the enclosing try/catch.

Inline findings (2 comments posted)

Severity File Line Issue
Low Given_HotReloadWorkspace.cs 149–150 Process killed and nulled but never Dispose()d — OS handles for redirected stdout/stderr pipes linger until GC
Low ProcessHelpers.cs 108 process.WaitForExit(10_000) is a synchronous blocking call inside an async catch block — blocks a thread-pool thread for up to 10 s on the timeout path

Both were flagged by earlier review rounds; neither is a blocker, but the disposal one is straightforward to fix (suggestion posted).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund changed the base branch from master to feature/breakingchanges August 22, 2026 14:39
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/hr-test-timeout branch from e5650d9 to 85fc385 Compare August 22, 2026 14:39
@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 12s —— View job


PR Review: fix(tests): Stop a hung test from consuming the whole CI job

Todo List

  • Gather context and understand the request
  • Read changed files and review code
  • Post inline review comments for findings
  • Post summary

Summary

Verdict: 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:

  • UnitTestsControl — TestBodyTimeoutException (harness cut-off, no retry) vs TimeoutException (test-raised, retryable) is the right distinction. The using var timeoutCts cancel-before-await pattern correctly prevents 5-minute lingering timers per test. Static-initializer ordering (DefaultTestBodyTimeoutFallback declared before DefaultTestBodyTimeout) is safe.
  • Given_HotReloadWorkspace — _testAppProcess = p before WaitForExitAsync closes the cleanup race. The when (cts.IsCancellationRequested) guard correctly scopes the conversion from OperationCanceledException to TimeoutException. Layered timeouts (6-min inner CTS → TimeoutException → 8-min [Timeout(…, CooperativeCancellation = false)] backstop) compose correctly; the inner fires first so the process is always killed before MSTest abandons the outer task.
  • ProcessHelpers — Kill(entireProcessTree: true) is the right choice for dotnet run-launched children. TOCTOU between HasExited and Kill is handled by the enclosing try/catch.

Inline findings (2 comments — both carryovers)

Severity File Line Issue
Low Given_HotReloadWorkspace.cs 149–150 Process killed and nulled but never Dispose()d — OS pipe handles linger until GC
Low ProcessHelpers.cs 108 process.WaitForExit(10_000) blocks a thread-pool thread for up to 10 s inside an async catch block

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235438 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Buttons.png-dark
    • Buttons.png
    • ClipboardTests.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • DisplayInformation.png-dark
    • ContextRequested.png-dark
    • ContextRequested.png
    • Focus_FocusVisual_Properties.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ImageIconPage.png-dark
  • skia-windows-screenshots: 2310 changed over 2498

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonTest.png
    • AnimatedIconPage.png-dark
    • AnimatedIconPage.png
    • AppBarToggleButtonTest.png
    • AppBarButtonTest.png-dark
    • AppBarButtonWithIconTest.png-dark
    • AppBar_KeyBoard.png
    • AppBarToggleButtonTest.png-dark
    • AppWindowClosing.png-dark
    • ApplicationViewMode.png-dark
    • AppWindowFeatures.png
    • AppWindowPresenters.png
    • AppWindowPresenters.png-dark
    • AppXamlDefinedResources.png
    • Arrange_Performance01.png
    • ArcSegment.png
    • Attributed_text_Supserscript.png
    • Attributed_text_Simple.png
    • Attributed_text_Supserscript.png-dark
    • AutoBorderStretchwithtopmargin.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/hr-test-timeout branch from 52ee436 to 02212f1 Compare September 25, 2026 22:26
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 25s —— View job


PR Review: fix(tests): Stop a hung test from consuming the whole CI job

Todo List

  • Gather context and understand the request (fresh pass on current HEAD after the latest sync commits, 02212f19)
  • Read changed files and review code
  • Post inline review comments for findings
  • Post summary

Verdict: LGTM, with one new medium-severity diagnostic gap worth a follow-up

This sync adds the non-retryable build cutoff, cut-off logging with the actual exception, and coverage in Given_HotReloadWorkspace_Budget.cs. Cross-checking against everything raised in prior rounds:

  • Resolved: Assert.Fail on a wedged app is no longer retryable (NonRetryableTestFailureException, excluded from the retry branch in UnitTestsControl.cs:1074 alongside TestBodyTimeoutException) — closes @morning4coffe-dev's CHANGES_REQUESTED.
  • Resolved: hung build path now throws NonRetryableTestFailureException instead of a plain InvalidOperationException (Given_HotReloadWorkspace.cs:269-274).
  • Resolved: Process disposal in TestCleanupWrapper and BuildTestApp's finally.
  • Resolved: late-fault logging now includes the actual exception message, not just t.Status.
  • Resolved: sync WaitForExit(10_000) in KillProcessTree is intentional and now commented (shared with the synchronous [TestCleanup] path).
  • Still open, non-blocking: BuildTestApp's cancellation→NonRetryableTestFailureException conversion duplicates RunWithinBudget<T>'s shape rather than reusing it (flagged 2026-09-24, DRY only, not correctness).

New finding (1 inline comment posted)

Given_HotReloadWorkspace.cs:47 — BuildTimeout (10 min) is longer than the only [Timeout] that ever wraps BuildTestApp() (the 8-minute [Timeout] on When_HotReloadScenario, via AwaitWithBudget around Initialize()). A hung build therefore always hits the generic outer cutoff first, so BuildTestApp's own catch — with its more actionable message and the captured build log — never actually fires. The 2026-09-23/24 rounds treated this same numeric relationship purely as a retry-safety question and closed it by making both paths non-retryable; that fix didn't correct the ordering, so the diagnostic goal this PR is built around (a hang naming its own cause) is still silently defeated for a hung build specifically. The file's own reasoning for TestAppTimeout (kept below the outer bound on purpose, per the comment at line 71-72) should apply symmetrically to BuildTimeout.

Cross-cutting observations

  • Three-layer protection (default body/initialize budget via AwaitWithBudget/TestBodyTimeoutException, non-retryable RunWithinBudget for both the HRApp run and the build, ProcessHelpers.KillProcessTree) is otherwise sound and composes correctly through the initialize→build→run→cleanup lifecycle.
  • New tests in Given_HotReloadWorkspace_Budget.cs correctly exercise RunWithinBudget's three cases (short-budget/non-retryable, self-cancel/propagates, in-budget/returns) using the already-established Assert.ThrowsExactlyAsync pattern.
  • .claude/rules/runtime-tests.md accurately documents the default budget and both stated limitations.
  • Async/cancellation discipline, Conventional Commits, and braces/style all check out.
  • Screenshot-diff bot noise earlier in the thread is unrelated to this test-harness change.
    · branch dev/mazi/hr-test-timeout

/// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix this →

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 235811 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ContextRequested.png-dark
    • DisplayInformation.png-dark
    • ContextRequested.png
    • Buttons.png-dark
    • Buttons.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • ImageIconPage.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
  • skia-windows-screenshots: 2310 changed over 2500

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonTest.png-dark
    • ApplicationViewMode.png-dark
    • AppWindowFeatures.png-dark
    • AppWindowPresenters.png
    • ArcSegment.png-dark
    • AuthenticationBroker_Demo.png-dark
    • AutoBorderStretchwithtopmargin.png-dark
    • AutomationProperties_Name.png
    • AutoSuggestBox_Description.png
    • AutoSuggestBox_Icons.png-dark
    • Basics Pivot Test.png-dark
    • Basics Pivot Test.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • BorderVersusPanelClipping.png-dark
    • BorderVersusPanelClipping.png
    • Border_BorderThickness.png-dark
    • Border_BorderThickness.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@unodevops

Copy link
Copy Markdown
Contributor

MartinZikmund and others added 10 commits October 3, 2026 10:48
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
Copilot AI lite review requested due to automatic review settings October 3, 2026 08:48
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/hr-test-timeout branch from 02212f1 to b088cef Compare October 3, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Medium severity

Open (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)]
@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 3m 21s —— View job


PR Review: fix(tests): Stop a hung test from consuming the whole CI job

Todo List

  • Gather context and understand the request (fresh review on current HEAD, commit b088cefa)
  • Read changed files and review code
  • Post inline review comments for findings
  • Post summary

Verdict: LGTM, with one confirmed open issue carried forward from prior rounds

This sync (d27a3442→b088cefa) adds non-retryable reporting for a wedged hot-reload run, test coverage for the budget classification (Given_HotReloadWorkspace_Budget.cs), and richer late-fault logging. Checking against everything raised in earlier rounds:

  • Resolved: Assert.Fail on a wedged app is no longer retryable — NonRetryableTestFailureException is excluded from the retry branch (UnitTestsControl.cs:1074) alongside TestBodyTimeoutException, closing @morning4coffe-dev's CHANGES_REQUESTED.
  • Resolved: the hung-build path now throws NonRetryableTestFailureException instead of a plain InvalidOperationException.
  • Resolved: Process disposal (TestCleanupWrapper, BuildTestApp's finally), the "faulted after cut-off" log now including the actual exception, and the comment justifying the intentional synchronous WaitForExit(10_000).
  • Still open (1 inline comment posted): BuildTimeout (10 min) is still longer than the outer [Timeout(8 * 60 * 1000)] that bounds Initialize()/BuildTestApp() — unchanged since it was first flagged on 2026-09-23. The retry-safety half is fixed, but the ordering isn't: because the harness abandons (doesn't cancel) a cut-off task, a hung build process now outlives the outer cutoff by up to ~2 minutes as an untracked orphan (it's a local variable, not a field TestCleanupWrapper can reach), competing with whatever test runs next in the shard. Full detail and a suggested fix in the inline comment on Given_HotReloadWorkspace.cs:47.

Cross-cutting observations

  • The three-layer protection (default body/initialize budget via AwaitWithBudget/TestBodyTimeoutException, non-retryable RunWithinBudget for both the app-run and build phases, ProcessHelpers.KillProcessTree) is otherwise sound and composes correctly through the initialize→build→run→cleanup lifecycle.
  • Given_HotReloadWorkspace_Budget.cs's three new tests correctly exercise RunWithinBudget's short-budget/non-retryable, self-cancel/propagates, and in-budget/returns cases.
  • .claude/rules/runtime-tests.md accurately documents the default budget and both stated limitations.
  • Minor, non-blocking carryover from the 2026-09-24 round: BuildTestApp's cancellation→NonRetryableTestFailureException conversion still duplicates RunWithinBudget<T>'s shape rather than reusing it (DRY only, not correctness) — not re-flagged inline since it was already raised and is cosmetic.
  • Conventional Commits, braces/tabs, and async/cancellation discipline (no .Result/.GetAwaiter().GetResult(), no unguarded async void, CancellationToken honored end-to-end) all check out.
  • Screenshot-diff bot noise earlier in the thread is unrelated to this test-harness change.
    · branch dev/mazi/hr-test-timeout

/// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TestBodyTimeoutException and moved on to [TestCleanup] (TestCleanupWrapper, line 163), then to the next test in the shard.
  • TestCleanupWrapper only knows about _testAppProcess (the app-run process) — the build process in BuildTestApp is a local variable, never tracked in a field, so cleanup can't kill it.
  • The orphaned dotnet build keeps running for up to ~2 more minutes, competing for CPU/disk/the dev-server port with whatever test runs next in the shard, until BuildTestApp's own cts finally fires and kills it via ProcessHelpers.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.

Fix this →

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 237171 found UI Test snapshots differences: skia-linux-screenshots: 119, skia-windows-screenshots: 122

Details
  • skia-linux-screenshots: 119 changed over 2454

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Examples.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • ImageBrush_Formats.png-dark
    • ImageBrush_Formats.png
    • DynamicFont.png-dark
    • DynamicFont.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
  • skia-windows-screenshots: 122 changed over 2456

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • ClipboardTests.png-dark
    • ClipboardTests.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Focus_FocusVisual_Properties.png-dark
    • DisplayInformation.png-dark
    • ElementLevelTheme.png-dark
    • Gamepad_CurrentReading.png-dark
    • Gamepad_Enumeration.png-dark
    • ImageSourceUrlMsAppDataScheme.png-dark
    • ImageSourceUrlMsAppDataScheme.png
    • Examples.png
    • ImageIconPage.png-dark
    • ImageIconPage.png
    • ImageBrush_Stretch.png-dark
    • ImageBrush_Stretch.png

@mergify

mergify Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A hung runtime test with no [Timeout] discards the whole shard's results

5 participants