Fix issue where matrix replace was not using imported display names (#3694)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2022-06-02 13:18:44 -07:00 committed by GitHub
parent cad69e1a8c
commit 48ef687a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 4 deletions

View File

@ -117,7 +117,7 @@ function GenerateMatrix(
}
$matrix = FilterMatrix $matrix $filters
$matrix = ProcessReplace $matrix $replace $config.displayNamesLookup
$matrix = ProcessReplace $matrix $replace $combinedDisplayNameLookup
$matrix = FilterMatrixDisplayName $matrix $displayNameFilter
return $matrix
}
@ -352,7 +352,7 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n
}
}
if ((!$matrix -and !$importPath) -or !$importPath) {
return $matrix, @()
return $matrix, @(), @{}
}
if (!(Test-Path $importPath)) {
@ -370,7 +370,7 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n
$combinedDisplayNameLookup[$lookup.Name] = $lookup.Value
}
return $matrix, $importedMatrix, $importedMatrixConfig.displayNamesLookup
return $matrix, $importedMatrix, $combinedDisplayNameLookup
}
function CombineMatrices([Array]$matrix1, [Array]$matrix2, [Hashtable]$displayNamesLookup = @{})

View File

@ -403,7 +403,7 @@ Describe "Platform Matrix Replace" -Tag "replace" {
{ $parsed = ParseReplacement $query } | Should -Throw
{ $parsed = ParseReplacement $query } | Should -Throw
}
It "Should replace values in a matrix" {
$matrixJson = @'
{
@ -542,4 +542,31 @@ Describe "Platform Matrix Replace" -Tag "replace" {
$matrix[1].parameters.Foo | Should -Be "foo2"
$matrix[1].parameters.Bar | Should -Be "bar1"
}
It "Should parse replacement syntax and source imported display name lookups" {
$matrixJson = @'
{
"displayNames": {
"replaceme": ""
},
"matrix": {
"$IMPORT": "./test-import-matrix.json",
"replaceme": "replaceme"
}
}
'@
$importConfig = GetMatrixConfigFromJson $matrixJson
$replace = 'Foo=(foo)1/$1ReplacedFoo1', 'B.*=(.*)2/$1ReplacedBar2'
$matrix = GenerateMatrix $importConfig "sparse" -replace $replace
$matrix.Length | Should -Be 3
$matrix[0].name | Should -Be "fooReplacedFoo1_bar1"
$matrix[0].parameters.Foo | Should -Be "fooReplacedFoo1"
$matrix[1].name | Should -Be "foo2_barReplacedBar2"
$matrix[1].parameters.Bar | Should -Be "barReplacedBar2"
$matrix[2].name | Should -Be "importedBazName"
$matrix[2].parameters.Baz | Should -Be "importedBaz"
$matrix[2].parameters.replaceme | Should -Be "replaceme"
}
}