Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build_scripts/windows/scripts/azps.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
$env:AZ_INSTALLER="MSI"
& "$PSScriptRoot\..\python.exe" -IBm azure.cli $args
$input | & "$PSScriptRoot\..\python.exe" -IBm azure.cli $args
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
exit $LASTEXITCODE

# SIG # Begin signature block
# MIInuQYJKoZIhvcNAQcCoIInqjCCJ6YCAQExDzANBglghkgBZQMEAgEFADB5Bgor
Expand Down
34 changes: 34 additions & 0 deletions build_scripts/windows/scripts/test_msi_installation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,37 @@ if ($installed_version -ne $artifact_version){
# Test bundled pip with extension installation
& $az_full_path extension add -n account
& $az_full_path self-test

# ---------------------------------------------------------------------
# azps.ps1 wrapper regression tests
# ---------------------------------------------------------------------
$azps_full_path = Join-Path (Split-Path $az_full_path -Parent) "azps.ps1"
if (-not (Test-Path $azps_full_path)) {
Write-Output "azps.ps1 was not installed at $azps_full_path"
Exit 1
}

# Baseline: the wrapper runs and --version returns success.
& $azps_full_path --version
if ($LASTEXITCODE -ne 0) {
Write-Output "azps.ps1 --version returned $LASTEXITCODE (expected 0)"
Exit 1
}

# A .ps1 wrapper must propagate non-zero exit codes from the
# child process. Unknown commands exit with code 2; an unfixed wrapper
# would exit 0 here.
& $azps_full_path this-command-does-not-exist-xyz *> $null
if ($LASTEXITCODE -eq 0) {
Write-Output "azps.ps1 did not propagate a failure exit code"
Exit 1
}

# When pwsh.exe invokes a .ps1 via
# -Command, the script's exit code is only surfaced if the script
# itself calls 'exit N'.
& pwsh.exe -NoProfile -Command "& '$azps_full_path' this-command-does-not-exist-xyz *> `$null; exit `$LASTEXITCODE"
if ($LASTEXITCODE -eq 0) {
Write-Output "azps.ps1 exit code swallowed when invoked via 'pwsh.exe -Command'"
Exit 1
}
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
6 changes: 4 additions & 2 deletions src/azure-cli/azps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ $env:AZ_INSTALLER="PIP"

if (Test-Path "$PSScriptRoot\python.exe") {
# Perfer python.exe in venv
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
Outdated
& "$PSScriptRoot\python.exe" -m azure.cli $args
$input | & "$PSScriptRoot\python.exe" -m azure.cli $args
}
Comment thread
AaronRobinsonMSFT marked this conversation as resolved.
else {
# Run system python.exe
python.exe -m azure.cli $args
$input | python.exe -m azure.cli $args
}

exit $LASTEXITCODE

# SIG # Begin signature block
# MIInqgYJKoZIhvcNAQcCoIInmzCCJ5cCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
Expand Down
Loading