Skip to content

Commit 02c7ccf

Browse files
committed
Add test for skip windows 10 installation behavior
1 parent 8216d5e commit 02c7ccf

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.buildkite/pipeline.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,11 @@ steps:
205205
notify:
206206
- github_commit_status:
207207
context: "install_windows_10_sdk Tests - Version file with version number that is not in the allowed list"
208+
209+
- label: ":windows: prepare_windows_host_for_app_distribution Tests - Skip Windows 10 SDK Installation"
210+
command: .\tests\test-prepare-windows-host-for-app-distribution.ps1
211+
agents:
212+
queue: windows
213+
notify:
214+
- github_commit_status:
215+
context: "prepare_windows_host_for_app_distribution Tests - Skip Windows 10 SDK Installation"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

Comments
 (0)