Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 6300 (#37078)
Browse files Browse the repository at this point in the history
* add fallback onto azure.sdk.tools.testproxy within generate-assets-json.ps1

Co-authored-by: scbedd <45376673+scbedd@users.noreply.github.com>
Co-authored-by: Sameeksha Vaity <sameeksha.v91@gmail.com>
Co-authored-by: Konrad Jamrozik <spawarotti@jamro.pl>
  • Loading branch information
4 people committed Jun 16, 2023
1 parent f70b5f6 commit 8aeb2d1
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions eng/common/testproxy/transition-scripts/generate-assets-json.ps1
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"

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

0 comments on commit 8aeb2d1

Please sign in to comment.