diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index a4f9665f..ab9f8703 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -124,7 +124,14 @@ steps: - label: ":windows: install_windows_10_sdk Tests - Standard version file" command: | echo '20348' > .windows-10-sdk-version - bin/install_windows_10_sdk.ps1 -DryRun + $output = & bin/install_windows_10_sdk.ps1 -DryRun + $exitCode = $LASTEXITCODE + if ($exitCode -ne 0) { + echo "Unexpected failure. Exit code: $exitCode" + echo "Output:" + echo $output + exit 1 + } agents: queue: windows notify: @@ -133,8 +140,19 @@ steps: - label: ":windows: install_windows_10_sdk Tests - Version file with new lines" command: | - echo "20348\n\n" > .windows-10-sdk-version - bin/install_windows_10_sdk.ps1 -DryRun + echo "20348`n`n" > .windows-10-sdk-version + $output = & bin/install_windows_10_sdk.ps1 -DryRun + $exitCode = $LASTEXITCODE + if ($exitCode -ne 0) { + echo "Unexpected failure. Exit code: $exitCode" + echo "Output:" + echo $output + exit 1 + } + if (($output -notmatch "[!] Invalid version file format") -and ($output -notmatch "Expected exactly one non-empty line")) { + echo "Failure message did not match expectation." + exit 1 + } agents: queue: windows notify: @@ -144,7 +162,18 @@ steps: - label: ":windows: install_windows_10_sdk Tests - Version file with a word" command: | echo "not an integer" > .windows-10-sdk-version - bin/install_windows_10_sdk.ps1 -DryRun + $output = & bin/install_windows_10_sdk.ps1 -DryRun + $exitCode = $LASTEXITCODE + if ($exitCode -ne 1) { + echo "Expected exit code 1, got: $exitCode" + echo "Output:" + echo $output + exit 1 + } + if (($output -notmatch "[!] Invalid version file format") -and ($output -notmatch "Expected an integer, got:'")) { + echo "Failure message did not match expectation." + exit 1 + } agents: queue: windows notify: diff --git a/bin/install_windows_10_sdk.ps1 b/bin/install_windows_10_sdk.ps1 index d6f00afe..2a4abe42 100755 --- a/bin/install_windows_10_sdk.ps1 +++ b/bin/install_windows_10_sdk.ps1 @@ -24,7 +24,7 @@ if ($windows10SDKVersion.Count -ne 1) { } if ($windows10SDKVersion -notmatch '^\d+$') { - Write-Output "[!] Invalid version format." + Write-Output "[!] Invalid version file format." Write-Output "Expected an integer, got: '$windows10SDKVersion'" exit 1 } @@ -49,7 +49,7 @@ If (-not (Test-Path $buildToolsPath)) { Write-Output "[!] Failed to download Visual Studio Build Tools" Exit 1 } else { - Write-Output "Successfully downloaded Visual Studio Build Toosl at $buildToolsPath." + Write-Output "Successfully downloaded Visual Studio Build Tools at $buildToolsPath." } # Install the Windows SDK and other required components