Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fallback for the test-proxy command in migration script #6300

Merged
merged 5 commits into from
Jun 16, 2023
Merged
Changes from 4 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,18 @@ class Version {
}

Function Test-Exe-In-Path {
Param([string] $ExeToLookFor)
Param([string] $ExeToLookFor, [bool]$ExitOnError = $true)
if ($null -eq (Get-Command $ExeToLookFor -ErrorAction SilentlyContinue)) {
Write-Error "Unable to find $ExeToLookFor in your PATH"
exit 1
if ($ExitOnError) {
Write-Error "Unable to find $ExeToLookFor in your PATH"
exit 1
}
else {
return $false
}
}

return $true
}

Function Test-TestProxyVersion {
Expand Down Expand Up @@ -348,9 +355,29 @@ $language = Get-Repo-Language
# in the path and that we're able to map the language's recording
# directories
if ($InitialPush) {
Test-Exe-In-Path -ExeToLookFor $TestProxyExe
$proxyPresent = Test-Exe-In-Path -ExeToLookFor $TestProxyExe -ExitOnError $false

# try to fall back
if (-not $proxyPresent) {
$StandaloneTestProxyExe = "Azure.Sdk.Tools.TestProxy"
scbedd marked this conversation as resolved.
Show resolved Hide resolved

if ($IsWindows) {
$StandaloneTestProxyExe += ".exe"
}

$standalonePresent = Test-Exe-In-Path -ExeToLookFor $StandaloneTestProxyExe -ExitOnError $false

if ($standalonePresent) {
Write-Host "Default proxy exe $TestProxyExe is not present, but standalone tool $StandaloneTestProxyExe is. Updating proxy exe to use the standalone version."
$TestProxyExe = $StandaloneTestProxyExe
}
else {
Write-Error "The user has selected option InitialPush to push their assets, neither $TestProxyExe nor standalone executable $StandaloneTestProxyExe are installed on this machine."
exit 1
}
}

if ($TestProxyExe -eq "test-proxy") {
if ($TestProxyExe -eq "test-proxy" -or $TestProxyExe.StartsWith("Azure.Sdk.Tools.TestProxy")) {
Test-TestProxyVersion -TestProxyExe $TestProxyExe
}

Expand Down