Skip to content

Commit fb99a64

Browse files
azure-sdkscbeddsamvaitykonrad-jamrozik
authored
Sync eng/common directory with azure-sdk-tools for PR 6300 (Azure#21026)
* add fallback onto azure.sdk.tools.testproxy within generate-assets-json.ps1 Co-authored-by: scbedd <[email protected]> Co-authored-by: Sameeksha Vaity <[email protected]> Co-authored-by: Konrad Jamrozik <[email protected]>
1 parent a5b57fa commit fb99a64

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

eng/common/testproxy/transition-scripts/generate-assets-json.ps1

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,18 @@ class Version {
138138
}
139139

140140
Function Test-Exe-In-Path {
141-
Param([string] $ExeToLookFor)
141+
Param([string] $ExeToLookFor, [bool]$ExitOnError = $true)
142142
if ($null -eq (Get-Command $ExeToLookFor -ErrorAction SilentlyContinue)) {
143-
Write-Error "Unable to find $ExeToLookFor in your PATH"
144-
exit 1
143+
if ($ExitOnError) {
144+
Write-Error "Unable to find $ExeToLookFor in your PATH"
145+
exit 1
146+
}
147+
else {
148+
return $false
149+
}
145150
}
151+
152+
return $true
146153
}
147154

148155
Function Test-TestProxyVersion {
@@ -348,9 +355,29 @@ $language = Get-Repo-Language
348355
# in the path and that we're able to map the language's recording
349356
# directories
350357
if ($InitialPush) {
351-
Test-Exe-In-Path -ExeToLookFor $TestProxyExe
358+
$proxyPresent = Test-Exe-In-Path -ExeToLookFor $TestProxyExe -ExitOnError $false
359+
360+
# try to fall back
361+
if (-not $proxyPresent) {
362+
$StandaloneTestProxyExe = "Azure.Sdk.Tools.TestProxy"
363+
364+
if ($IsWindows) {
365+
$StandaloneTestProxyExe += ".exe"
366+
}
367+
368+
$standalonePresent = Test-Exe-In-Path -ExeToLookFor $StandaloneTestProxyExe -ExitOnError $false
369+
370+
if ($standalonePresent) {
371+
Write-Host "Default proxy exe $TestProxyExe is not present, but standalone tool $StandaloneTestProxyExe is. Updating proxy exe to use the standalone version."
372+
$TestProxyExe = $StandaloneTestProxyExe
373+
}
374+
else {
375+
Write-Error "The user has selected option InitialPush to push their assets, neither $TestProxyExe nor standalone executable $StandaloneTestProxyExe are installed on this machine."
376+
exit 1
377+
}
378+
}
352379

353-
if ($TestProxyExe -eq "test-proxy") {
380+
if ($TestProxyExe -eq "test-proxy" -or $TestProxyExe.StartsWith("Azure.Sdk.Tools.TestProxy")) {
354381
Test-TestProxyVersion -TestProxyExe $TestProxyExe
355382
}
356383

0 commit comments

Comments
 (0)