|
| 1 | +# Tests the prepare_windows_host_for_app_distribution.ps1 script with the -SkipWindows10SDKInstallation parameter. |
| 2 | +# |
| 3 | +# We only test the skip behavior because the installation takes a "long" time to run. |
| 4 | + |
| 5 | +param ( |
| 6 | + [int]$ExpectedExitCode = 0, |
| 7 | +) |
| 8 | + |
| 9 | +# Ensure the output is UTF-8 encoded so we can use emojis... |
| 10 | +[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8 |
| 11 | +$emojiGreenCheck = "$([char]0x2705)" |
| 12 | +$emojiRedCross = "$([char]0x274C)" |
| 13 | + |
| 14 | +Write-Output "Testing prepare_windows_host_for_app_distribution.ps1 with -SkipWindows10SDKInstallation" |
| 15 | + |
| 16 | +# Create a valid SDK version file to ensure it's not being used |
| 17 | +$sdkVersion = "20348" |
| 18 | +"$sdkVersion" | Out-File .windows-10-sdk-version |
| 19 | + |
| 20 | +# Run the script with skip parameter |
| 21 | +$output = & "$PSScriptRoot\..\bin\prepare_windows_host_for_app_distribution.ps1" -SkipWindows10SDKInstallation |
| 22 | +$exitCode = $LASTEXITCODE |
| 23 | + |
| 24 | +# Check exit code |
| 25 | +if ($exitCode -ne $ExpectedExitCode) { |
| 26 | + Write-Output "$emojiRedCross Expected exit code $ExpectedExitCode, got $exitCode" |
| 27 | + Write-Output "Output was:" |
| 28 | + Write-Output "$output" |
| 29 | + exit 1 |
| 30 | +} else { |
| 31 | + Write-Output "$emojiGreenCheck Exit code matches expected value ($ExpectedExitCode)" |
| 32 | +} |
| 33 | + |
| 34 | +$expectedSkipMessage = "Run with SkipWindows10SDKInstallation = true. Skipping Windows 10 SDK installation check." |
| 35 | +if ($output -match [regex]::Escape($expectedSkipMessage)) { |
| 36 | + Write-Output "$emojiGreenCheck Found expected skip message in output" |
| 37 | +} else { |
| 38 | + Write-Output "$emojiRedCross Expected to find message about skipping due to parameter, but got:" |
| 39 | + Write-Output "$output" |
| 40 | + exit 1 |
| 41 | +} |
| 42 | + |
| 43 | +# Verify SDK was not installed by checking the file system |
| 44 | +$windowsSDKsRoot = "C:\Program Files (x86)\Windows Kits\10\bin" |
| 45 | +$sdkPath = "$windowsSDKsRoot\10.0.$sdkVersion\x64" |
| 46 | +If (Test-Path $sdkPath) { |
| 47 | + Write-Output "$emojiRedCross Found SDK installation at $sdkPath when it should have been skipped" |
| 48 | + exit 1 |
| 49 | +} else { |
| 50 | + Write-Output "$emojiGreenCheck Confirmed SDK was not installed at $sdkPath" |
| 51 | +} |
| 52 | + |
| 53 | +Write-Output "Test completed successfully." |
0 commit comments