Repository navigation
test(services): crash-dump / XAML-triage / debug-output coverage to 95% - #644
Conversation
Raise Debug line coverage for the crash-dump / XAML-triage / debug-output services with real-workflow tests first (genuine minidumps analyzed by the in-process ClrMD/DbgEng engines, a live Win32 debug-event loop driven by a controlled child process, and offline NuGet/bundle acquisition), then targeted unit tests for parsing, orchestration, and error paths. Product changes are test seams only and behavior-preserving: - CrashDumpService: ClrMD/DbgEng analyzer + symbol-download Func seams; extract AppendStackOverflowSummary / ParseStackModuleNames / WinUI-module helpers as pure functions; move ValidatePdbMatchesDll to the outer class; widen a few helpers to internal. - XamlTriageService: extract BuildTriageStartInfo; add timeout / process-path / extension-download / hash / binaries-resolver Func seams. - XamlTriageBinaries: HttpGetAsync Func seam; TryMaterializePackageAsync internal. - WinDbgJsProviderAcquirer: split out network-free TryAcquireCoreAsync; add host-arch / signature / engine-compat Func seams. - DebugOutputService: widen 3 pure noise-filter helpers to internal. Final per-file Debug line coverage: XamlTriageResult 100%, WinDbgJsProviderAcquirer 97.4%, XamlTriageService 96.3%. XamlTriageBinaries 93.7%, DebugOutputService 92.8%, CrashDumpService 89.8% and XamlTriageRunner 79.7% are documented honest ceilings (cross-architecture DAC, live symbol servers, Win32 fault injection, and host-architecture switch arms are unreachable without flaky or cross-arch tests; the specific uncovered line ranges and rationale are recorded in ceiling remarks on each test class). No coverage exclusions added; coverage.runsettings unchanged. Co-authored-by: Copilot App <[email protected]>
…lings H1: AppendStackOverflowSummary now resolves each frame's name/source lazily inside the 15-frame cap via nameSelector/sourceResolver delegates (was eagerly resolving PDB source for every deepest frame before the cap - a perf and exception-surface regression vs origin/main). Added a regression test asserting resolution happens for at most 15 frames. M1: Extract XamlTriageRunner.RunTriageSequence (execute/getOutput delegates) so the full DbgEng command sequence, symbol-path config, and provider-load failure are covered offline. XamlTriageRunner 79.7% -> 97.2%. M2: DebugOutputService - HandleException/ReadExceptionParameters made internal and pure GetContextFlags(Architecture) extracted; covered via fabricated DEBUG_EVENTs + unit tests. 92.8% -> 96.4%. M3: Extract pure XamlTriageBinaries.KitsArchFor/NuGetArchFor; covered X64/Arm64/X86/fallback. 93.7% -> 95.8%. M4: Extract CrashDumpService.DownloadSymbolsForModules (image-path provider delegate) so the download/cache/PE-parse core is covered offline; the live lmvm boundary is isolated in GetModuleImagePath. Reconcile every ceiling <remarks> to the actual uncovered lines. CrashDumpService remains a documented 91.5% honest ceiling (native P/Invoke fault injection, cross-arch DAC, live symbol network, ClrMD-null-object guards, corrupt-PDB edges - all policy-forbidden to force). All seams are behavior-preserving and confined to OS/engine boundaries. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Pull request overview
Expands crash-analysis, XAML-triage, and debug-output coverage for issue #630 through internal test seams and workflow tests.
Changes:
- Extracts injectable OS, engine, network, and process boundaries.
- Adds real-dump/debug-loop workflows and offline acquisition tests.
- Adds focused coverage for parsing, orchestration, and failure paths.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
Services/XamlTriageService.cs |
Adds triage test seams and process helpers. |
Services/XamlTriageRunner.cs |
Extracts the DbgEng command sequence. |
Services/XamlTriageBinaries.cs |
Adds HTTP and architecture seams. |
Services/WinDbgJsProviderAcquirer.cs |
Extracts network-free acquisition logic. |
Services/DebugOutputService.cs |
Exposes pure exception/debug helpers. |
Services/CrashDumpService.cs |
Adds analyzer seams and extracted helpers. |
XamlTriageServiceWorkflowTests.cs |
Tests triage orchestration and processes. |
XamlTriageRunnerTests.cs |
Tests parsing and DbgEng sequencing. |
XamlTriageResultTests.cs |
Covers result factories and properties. |
XamlTriageBinariesTests.cs |
Expands layout and architecture coverage. |
XamlTriageBinariesDownloadTests.cs |
Tests offline package downloads. |
XamlTriageBinariesAcquisitionTests.cs |
Tests local acquisition workflows. |
WinDbgJsProviderAcquirerTests.cs |
Tests provider extraction and verification. |
TestProcessDump.cs |
Generates native and managed test dumps. |
FakeWinappDirectoryService.cs |
Provides isolated cache directories. |
DebugOutputServiceWorkflowTests.cs |
Exercises the live debug-event loop. |
DebugOutputServiceTests.cs |
Covers classification and context helpers. |
CrashDumpServiceWorkflowTests.cs |
Exercises real dump-analysis workflows. |
CrashDumpServiceTests.cs |
Expands orchestration and helper coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var name = nameSelector(frame); | ||
| var sourceInfo = sourceResolver(frame); | ||
| var displayName = sourceInfo != null ? $"{name} in {sourceInfo}" : name; | ||
|
|
||
| if (name == lastFrame) | ||
| { | ||
| repeatCount++; | ||
| continue; | ||
| } | ||
|
|
||
| if (repeatCount > 0) | ||
| { | ||
| summary.AppendLine($" ... (repeated {repeatCount} more times)"); | ||
| displayed++; | ||
| } | ||
|
|
||
| if (displayed >= 15) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| summary.AppendLine($" {displayName}"); |
| var stderr = p.StandardError.ReadToEnd(); | ||
| _ = p.StandardOutput.ReadToEnd(); | ||
| p.WaitForExit(60000); |
There was a problem hiding this comment.
Fixed in e60b035. Added TestProcessDump.WaitForExitDrainingPipes, which starts both StandardOutput/StandardError ReadToEndAsync before WaitForExit (so neither pipe can back-pressure the child) and kills the process tree on timeout. This call site is rewired to use it.
| var stdout = proc.StandardOutput.ReadToEnd(); | ||
| var stderr = proc.StandardError.ReadToEnd(); | ||
| if (!proc.WaitForExit(120000)) | ||
| { | ||
| try { proc.Kill(entireProcessTree: true); } catch { /* best effort */ } | ||
| error = "'dotnet build' timed out"; | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Fixed in e60b035. Same as the compile path: this dotnet-build call site now uses WaitForExitDrainingPipes (concurrent drain before WaitForExit, kill on timeout) instead of sequential ReadToEnd, and the now-duplicate kill was removed.
| var symbolCache = Path.Combine(Path.GetTempPath(), "symbols"); | ||
| try { if (Directory.Exists(symbolCache)) { Directory.Delete(symbolCache, recursive: true); } } catch { /* best effort */ } |
There was a problem hiding this comment.
Fixed in e60b035. Added an internal CrashDumpService.SymbolCacheDirectory seam (defaults to the real %TEMP%\symbols); the test now points it at an isolated _tempDir\symbols and saves/restores it in a finally, so it no longer recursively deletes the shared developer/CI symbol cache. Only per-test temp dirs are cleaned up now.
| // Download from Microsoft Symbol Server (seamed for tests) | ||
| var pdbBytes = SymbolFileDownloader($"https://msdl.microsoft.com/download/symbols/{pdbName}/{sig}/{pdbName}"); | ||
| if (pdbBytes == null) |
There was a problem hiding this comment.
Fixed in e60b035. Restored origin/main streaming: the SymbolFileDownloader seam is now Func<url, destPath, bool>, and DefaultDownloadSymbolFile streams the response straight to the destination file (pdbStream.CopyTo into File.Create(destPath)) with constant memory. DownloadSymbolsForModules no longer materializes the whole PDB via MemoryStream.ToArray + File.WriteAllBytes.
| // Proves the extension commands ran against an opened dump (the extension exports are absent | ||
| // because the real JsProvider.dll is not present, which is expected in a hermetic test). | ||
| StringAssert.Contains(result, "xamlstowed"); |
There was a problem hiding this comment.
Fixed in e60b035. The test now early-returns Assert.Inconclusive when output contains "could not load the JavaScript provider" (the host-dependent .load HRESULT), so it no longer asserts on the full command sequence when DbgEng rejects the absent provider. The load-failure path stays covered deterministically offline by RunTriageSequence_LoadProviderFails.
| var (exit, stdout, _) = RunCaptured( | ||
| [XamlTriageRunner.InternalVerb, "--dump", dump, "--bin", system32, "--ext", ext, "--jsprovider", bogusJsProvider]); | ||
|
|
||
| if (exit != 0) | ||
| { | ||
| Assert.Inconclusive("In-process DbgEng engine unavailable (Run mapped it to a non-zero exit)."); | ||
| return; | ||
| } | ||
|
|
||
| StringAssert.Contains(stdout, "xamlstowed"); |
There was a problem hiding this comment.
Fixed in e60b035. Same host-invariant guard: when the .load of the absent provider fails, Run() can return 0 (triage fails open) with the load-failure message in stdout, so the test now goes Assert.Inconclusive in that case instead of treating it as the success path. Offline coverage via RunTriageSequence_LoadProviderFails.
Build Metrics ReportBinary Sizes
Test Results✅ 1855 passed, 2 skipped out of 1857 tests in 507.5s (+194 tests, +96.3s vs. baseline) Test Coverage❌ 52.8% line coverage, 61.4% branch coverage · ✅ +4.7% vs. baseline CLI Startup Time41ms median (x64, Updated 2026-07-15 20:37:08 UTC · commit |
Fixes the 6 confirmed findings from the auto-review bot, touching only the files needed: - #1 (BLOCKING, machine-mutating test): add an internal SymbolCacheDirectory seam to CrashDumpService (defaults to the real %TEMP%\symbols). The workflow test now points it at an isolated _tempDir\symbols instead of recursively deleting the developer's/CI's shared symbol cache. - #2 (product memory regression): restore origin/main streaming for symbol downloads. The SymbolFileDownloader seam becomes Func<url, destPath, bool>; DefaultDownloadSymbolFile streams the response straight to the destination file (constant memory), and DownloadSymbolsForModules no longer materializes the whole PDB via MemoryStream/File.WriteAllBytes. - #3/#4 (test-helper deadlock): TestProcessDump.WaitForExitDrainingPipes drains stdout and stderr concurrently before WaitForExit (was sequential ReadToEnd), killing the process tree on timeout. Both call sites rewired. - #5/#6 (env-dependent tests): the two bogus-provider XamlTriageRunner tests now treat a host-dependent `.load` failure as inconclusive instead of asserting on output that only appears when the full command sequence runs. Also reconciles the CrashDumpService coverage-ceiling <remarks> line numbers to the current source (91.3% Debug, 68 honestly-uncovered native/DAC/network/PDB boundary lines; the streaming restoration adds one line to the network boundary). Co-authored-by: Copilot App <[email protected]>
14c3207
into
main
PR 5 — Test coverage: crash-dump / XAML-triage / debug-output services
Raises test coverage on the crash-analysis, XAML-triage, and debug-output services toward the ≥95% per-file bar, part of the coverage-to-95% effort (issue #630). Real-workflow tests first (genuine minidumps analyzed by the in-process ClrMD/DbgEng engines; a live Win32 debug-event loop; offline NuGet/bundle acquisition), then targeted unit tests for parsing/orchestration/error paths.
Per-file Debug line coverage (authoritative
coverage-report.ps1 -Configuration Debug, full run)6 of 7 files ≥95%. CrashDumpService lands at 91.5% as a rigorously per-line-documented ceiling (see below).
Product changes — test seams only, all behavior-preserving
No runtime-behavior change, no coverage exclusions, no visibility widened beyond
internal. All changes are at OS/engine boundaries and were reviewed as character-identical extractions / additive-visibility only:AppendStackOverflowSummary<TFrame>now takes raw frames +nameSelector/sourceResolverdelegates and resolves lazily inside the 15-cap loop (restores origin/main behavior: ≤15 PDB lookups, no eager resolution of thousands of overflow frames).DownloadSymbolsForModules(imagePathProvider)extracted so the download/cache/PE-parse core is covered offline. Analyzer/symbol-downloaderFuncseams (ClrMdAnalyzerOverride/DbgEngAnalyzerOverride/SymbolFileDownloader); pure helpers extracted (AppendStackOverflowSummary/ParseStackModuleNames/WinUI-module helpers, char-identical); a few helpers widened tointernal.GetContextFlags(Architecture)extracted;HandleException/ReadExceptionParameters→internal; three pure noise-filter helpers →internal.KitsArchFor/NuGetArchForextracted;HttpGetAsyncFuncseam;TryMaterializePackageAsync→internal.RunTriageSequence(execute, getOutput)extracted so the whole command sequence + symbol-path + provider-load-fail is covered offline.ProcessPathProviderFuncseam (reaches the dotnet-host branch — an MTP host is an apphost, never dotnet.exe);BuildTriageStartInfo/DownloadExtensionBytesAsyncextracted; timeout/extension-download/hash/binaries-resolverFuncseams.TryAcquireCoreAsyncsplit out; host-arch/signature/engine-compatFuncseams.Precedent for these seams:
UpdateNotificationService.cs. No dead code found to delete.CrashDumpService 91.5% — documented honest ceiling
The 67 residual lines are all genuine native/engine/network boundaries, reconciled per-line in a
<remarks>block onCrashDumpServiceWorkflowTests. Reaching them would require a foreign CPU architecture, a live symbol server, a corrupt/stripped/mismatched PE or PDB, or Win32/engine fault injection — all policy-forbidden (no flaky tests, no OS-mutating tests, no[ExcludeFromCodeCoverage]on hand-written logic):MiniDumpWriteDumpP/Invoke returning FALSE + outer catch (native dump-write failure; can't provoke without corrupting the OS call).DumpHasWinUiModulecatch (DAC not loadable on this host).FormatManagedExceptionper-frame source append — a dedicated test (AnalyzeDumpAsync_DeepStackWithPortablePdb_ResolvesManagedSourceLocations) exists but goesAssert.Inconclusivebecause the child-runtime DAC is not loadable here.DefaultDownloadSymbolFileHTTPS (live msdl network).Method/Moduleguards (ClrStackFrame/ClrMethod/ClrModulehave no public ctor — can't be faked null), and corrupt-/locked-PDB catches.This mirrors the documented-ceiling approach used elsewhere in this coverage effort. Definition of done: ≥95% OR a documented honest ceiling.
Verification
WinApp.Cli.csproj+WinApp.Cli.Tests.csproj,-p:UseSharedCompilation=false -nodeReuse:false): 0 warnings / 0 errors (warnings-as-errors).src/winapp-npm/dist/cli.js/ NativeAOTwinapp.exe) and DAC-gatedAssert.Inconclusiveskips on this host — none introduced by this PR.Review
This branch was reviewed with the repo's
pr-reviewskill before opening. One high finding (H1 — a stack-overflow-summary extraction that had regressed origin/main's lazy source-resolution into an eager.Select(...).ToList()) was caught and fixed: source resolution is now lazy inside the 15-frame cap, guarded by a regression test (50 distinct frames, a poison resolver that throws past the cap, asserting exactly 15 resolutions). Four medium coverage findings were addressed (XamlTriageRunner 79.7→97.2%, DebugOutputService, XamlTriageBinaries, CrashDumpService lmvm).Co-authored-by: Copilot App [email protected]