From 0573a0e0f02a91c64b1a8043739489f9927f242e Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 29 Jul 2026 09:07:34 +0000 Subject: [PATCH] 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. --- tests/studio_setup_ps1/Studio.Setup.Vs2026.Tests.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/studio_setup_ps1/Studio.Setup.Vs2026.Tests.ps1 b/tests/studio_setup_ps1/Studio.Setup.Vs2026.Tests.ps1 index 35c18770a5..1db715c2f1 100644 --- a/tests/studio_setup_ps1/Studio.Setup.Vs2026.Tests.ps1 +++ b/tests/studio_setup_ps1/Studio.Setup.Vs2026.Tests.ps1 @@ -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))