Lift the Diagnostic out of the orchestrator into src/WcdDiagnostic.ps1 - #31
Merged
Merged
Conversation
The 13 functions that decide what the technician actually reads lived in Invoke-WcdConfiguration.ps1, where nothing could reach them: dot-sourcing the script runs the whole run. So the three-way "skip" CONTEXT.md works hardest to pin down - declined prompt is a Manual Step, filtered by Form Factor or Environment is Not Applicable, could-not-run is a failure - was the only rule with no test behind it. A pure move, byte for byte. The new file is dot-sourced beside WcdHelpers.ps1 and still reads $T from script scope; the test file sets $script:T in BeforeAll by lifting the real assignment out of the orchestrator's AST, so the tests assert against the strings a technician actually sees rather than a copy that drifts. Read-WcdChoice, Read-WcdComputerName, Wait-WcdForEnter and Resolve-WcdExecutionOptions stay put: they are the console, not the Diagnostic. FatalHelpersMissing now names the file it could not find, since there are two. The rendered sentence is unchanged. Closes #16 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16.
What moved
The 13 functions that decide what the technician reads, lifted byte for byte out
of
src/Invoke-WcdConfiguration.ps1intosrc/WcdDiagnostic.ps1:Get-WcdSeverityRank,Get-WcdResultsForSteps,Get-WcdStrongestResult,Format-WcdRemedy,Get-WcdAggregateDetail,New-WcdDiagnosticEntry,Resolve-WcdAutomaticEntry,Get-WcdModuleStatusKind,Format-WcdModuleLine,Format-WcdChecklistLine,Write-WcdSectionHeader,Get-WcdFinalChecklistEntries,Get-WcdFinalDiagnosticLines.Read-WcdChoice,Read-WcdComputerName,Wait-WcdForEnterandResolve-WcdExecutionOptionsstayed: they are the console, not the Diagnostic.The orchestrator dot-sources the new file beside
WcdHelpers.ps1. No behaviourchanges; the moved block is identical to what was removed.
The
$TproblemTook the second option from the issue: the functions still read
$script:T.Rather than hand-copy a
$Tinto the test file and let it drift, the test liftsthe real assignment out of the orchestrator's AST and evaluates it with
$ScriptUI = 'EN'. The assertions therefore run against the strings atechnician actually sees, and a renamed key breaks the test instead of passing
silently.
Tests
tests/WcdDiagnostic.Tests.ps1, 16 tests, covering every box on the issue:ApplicationsSkip) yields a Manual StepMANUAL) yields a Manual Step, not a failureFormat-WcdRemedywith a key absent from$T.Remedyrenders nothingFormat-WcdRemedywith mismatchedRemedyArgsreturns the template, not a throwtests/Help.Tests.ps1still green: comment-based help came across intact.Verified
Run locally on PowerShell 7.4.6:
Invoke-Pester ./tests/*.Tests.ps1— 128 passed, 2 failed. Both failures arethe pre-existing Windows-only ones (
New-WinUserLanguageList,Get-CimInstance) that also fail onmainfrom Linux; CI runswindows-latest, where they pass.Invoke-ScriptAnalyzer -Path . -Recurse -Settings ./PSScriptAnalyzerSettings.psd1— clean.One small change that is not a pure move
FatalHelpersMissingnow takes the filename as{0}, since there are two filesto dot-source. The rendered sentence for
WcdHelpers.ps1is unchanged, soconsole output stays byte-identical.
Left out
docs/manual.typhas two Typst diagrams of thesrc/tree that still show twofiles. Adding a row means shifting every coordinate in both and rebuilding the
committed PDF — out of scope here, worth its own issue. The README tree is
updated.
🤖 Generated with Claude Code