Skip to content

fix(tests): Hot Reload runtime test correctness - #24129

Merged
MartinZikmund merged 5 commits into
masterfrom
dev/mazi/hotreload-test-fixes-master
Aug 19, 2026
Merged

MartinZikmund merged 5 commits into
masterfrom
dev/mazi/hotreload-test-fixes-master

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24124

PR Type:

🏗️ Build or CI related changes

What changed? 🚀

Four Hot Reload runtime-test defects, one commit each. Originally raised against feature/breakingchanges in #24125; retargeted here because three of the four are missing from master entirely, and the fourth is a latent break that master still carries. feature/breakingchanges picks these up through the normal master sync.

test(hotreload): only cross-check the platform when a RID was stamped

The RID mapping fell through to "skia" for any unrecognised runtime identifier. The CoreCLR-on-Android host never sets RUNTIME_IDENTIFIER, so the test expected skia while the product correctly reported android — failing 100% of android-skia-coreclr runs since 2026-07-21. Only recognised RID families are mapped now; anything else means no independent oracle is available, and the desktop family is matched explicitly instead of by fallthrough. This also drops the [PlatformCondition(Exclude, SkiaAndroid)] workaround, which was over-broad — SkiaAndroid covers the Mono head too, where the test passes.

test(hotreload): stop the workspace scenario passing without running

On a CI retry the filter is rebuilt from the published failed-tests list, which carries fully qualified names, but the outer test stripped itself by comparing bare identifiers only. …Given_HotReloadWorkspace.When_HotReloadScenario was therefore forwarded to an HRApp that has no such test: it ran nothing, returned an empty result set, and the outer test reported success because there were no failures to collect. Now matches the fully qualified forms and fails explicitly when the HRApp returns no results, mirroring the fail-empty guard the CI scripts already apply to the outer run.

test(hotreload): fail fast when a file edit matches nothing

The replacement is performed server-side, so a search string matching nothing is a silent no-op: no file change, no reload, and a test that asserts against content it never updated. HotReloadHelper now verifies the text is present before asking the server to replace it, naming the file and the caller when it is not. The check is skipped when the source is not readable from the test process, so the server stays the authority rather than a new failure mode appearing.

The *AndRevert helpers also undo only when an edit actually happened — reverting a file that was never modified trips the same guard from a finally block, which would replace the original failure with a confusing one.

test(hotreload): drive the pause test with text the page contains

When_VisualTree_Paused_Then_ReloadCompleted_StillFires replaced "Hello" with "PausedTest", and HR_Frame_Pages_Page1.xaml contains neither — its TextBlocks are FirstPageTextBlock (Text="First page") and a {Binding TitleText} one. The edit matched nothing, so no reload was requested and the drain had nothing to apply.

This one has to land with the guard above. Once a no-op edit is a hard error, the stale "Hello" search stops being invisible and starts failing the stage. Verified by reverting just this commit and re-running:

Test When_VisualTree_Paused_Then_ReloadCompleted_StillFires() failed with
System.InvalidOperationException: 'Hello' was not found in
'…/HR_Frame_Pages_Page1.xaml' (requested by
When_VisualTree_Paused_Then_ReloadCompleted_StillFires@80).
The edit would have silently done nothing.

When_HotReload_Succeeds_Then_ReloadCompleted_ReportsSuccess needs no change here — it was already corrected on master (Frame host, element re-resolved from the live tree, because a reloadable-type update replaces the page instance rather than mutating it).

Validation

Runtime-validated on Skia Desktop Win32, running the real harness — DevServer host plus the spawned HRApp child process — via Given_HotReloadWorkspace:

Run Inner HRApp result
This branch 35 passed / 11 skipped / 0 failed
Negative control (pause-test commit reverted) 1 failed, with the guard message quoted above

Both Given_HotReloadResilience tests are among the 35 that ran and passed — confirmed against the HRApp's own NUnit result file, so the outer pass is not the vacuous one described above.

PR Checklist ✅

MartinZikmund and others added 4 commits August 19, 2026 15:21
The RID mapping fell through to "skia" for every unrecognised runtime
identifier. The CoreCLR-on-Android host never sets RUNTIME_IDENTIFIER, so
RuntimeInformation.RuntimeIdentifier reports "unknown", the test expected
"skia" and the product correctly reported "android". It failed on 100% of
android-skia-coreclr runs since 2026-07-21 — deterministic, not flaky.

Map only recognised RID families and treat anything else as "no independent
oracle available", still asserting that a platform was reported. The desktop
family is now matched explicitly (win/linux/osx/freebsd) instead of by
fallthrough, so a genuinely unexpected RID can no longer be silently accepted
as desktop.

This also drops the [PlatformCondition(Exclude, SkiaAndroid)] workaround, which
was over-broad: SkiaAndroid covers both the Mono head, where the test passes,
and the CoreCLR head, so the exclusion was removing working coverage.

Runtime-validated on Skia Desktop Win32 (RID win-x64), which now exercises the
new explicit desktop branch: passes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Tj7eBARpKztfeLfaLTWde7
On a CI retry the filter is rebuilt from the published failed-tests list, which
carries fully qualified names. The outer test stripped itself from the forwarded
filter by comparing against the bare identifiers only, so
"…Given_HotReloadWorkspace.When_HotReloadScenario" was passed through to the
HRApp. The HRApp has no such test, ran nothing, produced an empty result set,
and the outer test reported success because there were no failures to collect.

Match the fully qualified forms too, and fail explicitly when the HRApp returns
no results at all — mirroring the fail-empty guard the CI scripts already apply
to the outer run.

Verified by inspection against the real filter round-trip
(SampleChooserViewModel base64-decodes the pipe-separated list, UnitTestsControl
rejoins it with ';'), plus a table check that the predicate strips all four
spellings of the outer test while leaving inner HRApp test names untouched.
Compile-validated; the end-to-end path needs the Windows/macOS Skia CI leg.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Tj7eBARpKztfeLfaLTWde7
The hot reload file replacement is applied server-side, so a search string that
matches nothing is a silent no-op: no file change, no reload, and a test that
proceeds to assert against content it never updated. That is how the stale
"Hello"/"tb1" expectations in Given_HotReloadResilience survived undetected.

Verify the text is present before asking the server to replace it, and name the
file and the caller when it is not. The check is skipped when the source is not
readable from the test process, so the server stays the authority rather than a
new failure mode appearing.

Undo the edit only when one was actually made: reverting a file that was never
modified trips the same guard from a finally block, which would replace the
original failure with a confusing one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xn8SQpybcpmMCwFmbCzSWt
`When_VisualTree_Paused_Then_ReloadCompleted_StillFires` replaced "Hello"
with "PausedTest", and `HR_Frame_Pages_Page1.xaml` contains neither. The
edit matched nothing, so no reload was requested and the drain had nothing
to apply.

This becomes a hard failure once the no-op edit guard is in place, so the
two must land together.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012yChS9evZTBdTJ77wWw2mY
Copilot AI lite review requested due to automatic review settings August 19, 2026 13:29
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

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


Review — 2 findings (1 medium, 1 low)

  • Gather context and understand the PR
  • Read changed files
  • Review code for correctness, style, and guidelines
  • Post inline comments for findings
  • Post summary

Overall verdict: fix-first on the medium finding; the low finding is discretionary.

Cross-cutting notes

The four fixes are well-reasoned and correctly targeted:

  • The RID platform mapping in Given_ClientHotReloadProcessor is now precise — the explicit desktop-family match replaces the unsafe fallthrough, and the null-oracle path gracefully handles unknown RIDs instead of asserting a wrong platform.
  • The IsOuterTestFilter logic in Given_HotReloadWorkspace correctly covers both bare and fully-qualified retry-filter forms, and the empty-result guard closes the vacuous-pass hole.
  • EnsureOriginalTextIsPresent is well-placed (after the null-message guard, before the network send), and the edited flag pattern in the two *AndRevert helpers correctly prevents revert-on-no-edit exception shadowing.
  • The text fix in Given_HotReloadResilience matches HR_Frame_Pages_Page1.xaml (Text="First page"), verified by reading the file.

Findings

Medium — exception shadowing in When_VisualTree_Paused_Then_ReloadCompleted_StillFires (line 97)

The manual try/finally in this test does not apply the edited flag that this PR introduces in UpdateProjectFileAndRevert / UpdateServerFileAndRevert<T>. If the initial edit throws (e.g., a future XAML change removes "First page"), the finally will also throw (EnsureOriginalTextIsPresent on "Paused page" fails), shadowing the original failure. The UpdateServerFileAndRevert<T> helper can't be used here because the pause context must span the edit, but the edited flag pattern should be applied to the manual try/finally.

Low — File.ReadAllText may throw for locked/inaccessible files (line 236)

EnsureOriginalTextIsPresent's remarks say the check is skipped "when the source is not readable", but only File.Exists is guarded. A locked file (IOException) or a permissions change (UnauthorizedAccessException) would propagate as a confusing non-assertion exception rather than being silently skipped. Adding catch (IOException) / catch (UnauthorizedAccessException) around the ReadAllText call would honour the stated intent.

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 improves the correctness and failure signaling of the Hot Reload runtime test harness, preventing false-green outcomes and making no-op edits fail deterministically so real regressions surface reliably.

Changes:

  • Fixes HRApp filter forwarding so the outer workspace test can’t pass without the inner HRApp running any tests.
  • Makes RID/platform cross-checking conditional on having a meaningful RID “oracle”, avoiding deterministic failures on hosts that report unknown.
  • Adds a guard that fails fast when a requested server-side file edit would be a silent no-op, and updates the pause test to edit text that actually exists.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Uno.UI.RuntimeTests/Tests/HotReload/Given_HotReloadWorkspace.cs Improves filter handling and fails when the inner HRApp reports zero test results.
src/Uno.UI.RuntimeTests/Tests/HotReload/Given_ClientHotReloadProcessor.cs Tightens RID→platform mapping and avoids asserting against non-oracle RIDs.
src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/HotReloadHelper.cs Adds no-op edit detection and avoids undoing edits that didn’t occur.
src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_HotReloadResilience.cs Updates pause-test edit strings to match actual page content and revert reliably.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

Two review points on the guard added in this PR.

`EnsureOriginalTextIsPresent` documented that it steps aside when the source is
not readable, but only checked `File.Exists` — a locked or inaccessible file
still reached `File.ReadAllText` and surfaced as an `IOException` from a helper
that is supposed to be invisible unless the search text is genuinely absent. The
read now falls back for exactly that case, which also subsumes the existence
check.

The pause test reverted its edit unconditionally. The revert is skipped when no
edit landed, so it can no longer trip the guard it is meant to complement, and
it now also covers the assertion inside the pause block — previously a failure
there left the file on "Paused page" for every later test.

Runtime-validated on Skia Desktop Win32: 35 passed / 11 skipped / 0 failed.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_012yChS9evZTBdTJ77wWw2mY
Copilot AI review requested due to automatic review settings August 19, 2026 14:56
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

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


Review — re-check after d3a587e

  • Gather context and understand the PR synchronize event
  • Read the updated changed files (esp. d3a587e changes)
  • Verify both prior findings are resolved
  • Check for any new issues introduced
  • Post inline comments for any new findings
  • Post summary

Both prior findings are resolved. No new findings.

Prior findings — resolved

Medium (exception shadowing in When_VisualTree_Paused_Then_ReloadCompleted_StillFires) — Fixed in d3a587e.
edited = false is declared before the try, set to true after UpdateServerFile returns on line 85, and the finally revert is guarded by if (edited). As MartinZikmund noted, the exact shadowing path in the original comment couldn't occur (the UpdateServerFile call sits above the try), but the real gap — the assertion inside the using throwing after an edit had landed, leaving the file on "Paused page" for every subsequent test — is now closed by the same flag pattern.

Low (File.ReadAllText may throw for locked/inaccessible files) — Fixed in d3a587e.
ReadAllText is now wrapped in a try/catch (Exception e) when (e is IOException or UnauthorizedAccessException or NotSupportedException) that returns early, handing control back to the server. The separate File.Exists pre-check is gone: since FileNotFoundException and DirectoryNotFoundException both derive from IOException, the catch already covers the not-found case without the TOCTOU race the pre-check introduced.

Cross-cutting check

The four original fixes (RID mapping, filter forwarding, no-op edit guard, text correction) are unchanged and were already confirmed sound in the first review pass. d3a587e adds no new logic beyond hardening the two flagged spots.

Overall verdict: ship.

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 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/HotReloadHelper.cs:205

  • Same issue in UpdateServerFileAndRevert<T>: edited is only set after UpdateServerFile<T> completes, so exceptions thrown after the update request is sent (e.g., waiting for the visual-tree update) will skip the undo and may leave the edited file in place for later tests. Making the undo a best-effort, non-throwing cleanup avoids both state leakage and failure-masking.
		var edited = false;
		try
		{
			await UpdateServerFile<T>(originalText, replacementText, ct, caller, line);
			edited = true;

src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/HotReloadHelper.cs:167

  • UpdateProjectFileAndRevert sets edited = true only after UpdateServerFile completes successfully. If UpdateServerFile throws after sending the update request (e.g., during the visual-tree update wait/timeout), the finally block will skip the undo and can leave the workspace modified for subsequent tests. Consider making the undo best-effort and non-throwing so it runs even when the initial update path fails, without masking the original failure.

This issue also appears on line 200 of the same file.

		var edited = false;
		try
		{
			await UpdateServerFile(filePathInProject, originalText, replacementText, ct, caller, line);
			edited = true;

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund
MartinZikmund merged commit 817f8a9 into master Aug 19, 2026
51 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/hotreload-test-fixes-master branch August 19, 2026 20:30
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.

Hot Reload runtime tests: two that cannot fail, one that asserts on content that never existed

5 participants