From 4dace9b1143661331163678769a724d478148d8e Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 10 Nov 2022 16:37:39 -0500 Subject: [PATCH] Add optional TestResourcesDirectory override parameter (#4105) Co-authored-by: Ben Broderick Phillips --- .../TestResources/New-TestResources.ps1 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index 8fdcaad7f..80f59a904 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -21,6 +21,9 @@ param ( [Parameter(Mandatory = $true, Position = 0)] [string] $ServiceDirectory, + [Parameter()] + [string] $TestResourcesDirectory, + [Parameter()] [ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')] [string] $TestApplicationId, @@ -351,6 +354,14 @@ try { # Enumerate test resources to deploy. Fail if none found. $repositoryRoot = "$PSScriptRoot/../../.." | Resolve-Path $root = [System.IO.Path]::Combine($repositoryRoot, "sdk", $ServiceDirectory) | Resolve-Path + if ($TestResourcesDirectory) { + $root = $TestResourcesDirectory | Resolve-Path + # Add an explicit check below in case ErrorActionPreference is overridden and Resolve-Path doesn't stop execution + if (!$root) { + throw "TestResourcesDirectory '$TestResourcesDirectory' does not exist." + } + Write-Verbose "Overriding test resources search directory to '$root'" + } $templateFiles = @() "$ResourceType-resources.json", "$ResourceType-resources.bicep" | ForEach-Object { @@ -809,7 +820,13 @@ group that will be created. .PARAMETER ServiceDirectory A directory under 'sdk' in the repository root - optionally with subdirectories specified - in which to discover ARM templates named 'test-resources.json' and -Bicep templates named 'test-resources.bicep'. This can also be an absolute path +Bicep templates named 'test-resources.bicep'. This can be an absolute path +or specify parent directories. ServiceDirectory is also used for resource and +environment variable naming. + +.PARAMETER TestResourcesDirectory +An override directory in which to discover ARM templates named 'test-resources.json' and +Bicep templates named 'test-resources.bicep'. This can be an absolute path or specify parent directories. .PARAMETER TestApplicationId