Dot-source Get-HostMachineArch in the setup.ps1 Pester suite

#7549 taught Test-VCRedistInstalled to consult the host architecture before
trusting the System32 DLL. The Pester suite dot-sources a fixed list of
functions out of setup.ps1 one at a time, and that list did not gain the
helper, so the two clean-box cases (registry miss, and an old sub-14.20
redist) throw "Get-HostMachineArch is not recognized" instead of returning
false. The registry hit returns early, which is why the other cases pass.

#7597 made exactly this fix to the sibling list in the VC++ round-trip job
but left the Pester suite alone. Verified with pwsh 7.6 + Pester: 3 failed
before, 31 passed 0 failed after.
This commit is contained in:
Daniel Han 2026-07-29 09:07:34 +00:00
commit 0573a0e0f0

View file

@ -27,10 +27,16 @@ BeforeAll {
if (-not $script:SetupPs1) { throw "Could not locate studio/setup.ps1 (set SETUP_PS1_PATH)." }
Write-Host "setup.ps1 under test: $script:SetupPs1"
# Test-VCRedistInstalled consults Get-HostMachineArch before trusting the
# System32 DLL, and dot-sourcing functions one at a time does not carry that
# callee in. The registry hit returns early, so only the clean-box cases reach
# the call and fail there with "Get-HostMachineArch is not recognized"; the
# same list in the VC++ round-trip job gained the helper in #7597.
foreach ($fn in @('Resolve-VsGeneratorFromLabel', 'Find-VsBuildTools', 'Get-VcBuildCustomizationsDir',
'Test-CmakeSupportsGenerator', 'Get-CmakeVersion', 'Test-CmakeListsGenerator',
'Test-CmakeCanDriveGenerator', 'Get-FallbackVsGenerator',
'Ensure-BuildToolsForLlamaSourceBuild', 'Test-VCRedistInstalled')) {
'Ensure-BuildToolsForLlamaSourceBuild', 'Get-HostMachineArch',
'Test-VCRedistInstalled')) {
$src = Get-FunctionSource -Path $script:SetupPs1 -Name $fn
if (-not $src) { throw "Function '$fn' not found in $script:SetupPs1 - cannot test the real code." }
. ([scriptblock]::Create($src))