@@ -32,7 +32,7 @@ function GenerateMatrix(
3232 [Array ]$filters = @ (),
3333 [Array ]$nonSparseParameters = @ ()
3434) {
35- $orderedMatrix , $importedMatrix = ProcessImport $config.orderedMatrix $selectFromMatrixType
35+ $orderedMatrix , $importedMatrix , $importedDisplayNamesLookup = ProcessImport $config.orderedMatrix $selectFromMatrixType
3636 if ($selectFromMatrixType -eq " sparse" ) {
3737 [Array ]$matrix = GenerateSparseMatrix $orderedMatrix $config.displayNamesLookup $nonSparseParameters
3838 } elseif ($selectFromMatrixType -eq " all" ) {
@@ -44,7 +44,7 @@ function GenerateMatrix(
4444 # Combine with imported after matrix generation, since a sparse selection should result in a full combination of the
4545 # top level and imported sparse matrices (as opposed to a sparse selection of both matrices).
4646 if ($importedMatrix ) {
47- [Array ]$matrix = CombineMatrices $matrix $importedMatrix
47+ [Array ]$matrix = CombineMatrices $matrix $importedMatrix $importedDisplayNamesLookup
4848 }
4949
5050 if ($config.exclude ) {
@@ -199,19 +199,19 @@ function ProcessIncludes([MatrixConfig]$config, [Array]$matrix)
199199function ProcessImport ([System.Collections.Specialized.OrderedDictionary ]$matrix , [String ]$selection )
200200{
201201 if (! $matrix -or ! $matrix.Contains ($IMPORT_KEYWORD )) {
202- return $matrix
202+ return $matrix , @ () , @ {}
203203 }
204204
205205 $importPath = $matrix [$IMPORT_KEYWORD ]
206206 $matrix.Remove ($IMPORT_KEYWORD )
207207
208- $matrixConfig = GetMatrixConfigFromJson (Get-Content $importPath )
209- $importedMatrix = GenerateMatrix $matrixConfig $selection
208+ $importedMatrixConfig = GetMatrixConfigFromJson (Get-Content $importPath )
209+ $importedMatrix = GenerateMatrix $importedMatrixConfig $selection
210210
211- return $matrix , $importedMatrix
211+ return $matrix , $importedMatrix , $importedMatrixConfig .displayNamesLookup
212212}
213213
214- function CombineMatrices ([Array ]$matrix1 , [Array ]$matrix2 )
214+ function CombineMatrices ([Array ]$matrix1 , [Array ]$matrix2 , [ Hashtable ] $displayNamesLookup = @ {} )
215215{
216216 $combined = @ ()
217217 if (! $matrix1 ) {
@@ -223,21 +223,22 @@ function CombineMatrices([Array]$matrix1, [Array]$matrix2)
223223
224224 foreach ($entry1 in $matrix1 ) {
225225 foreach ($entry2 in $matrix2 ) {
226+ $entry2name = @ ()
226227 $newEntry = @ {
227228 name = $entry1.name
228229 parameters = CloneOrderedDictionary $entry1.parameters
229230 }
230231 foreach ($param in $entry2.parameters.GetEnumerator ()) {
231- if (! $newEntry.Contains ($param.Name )) {
232+ if (! $newEntry.parameters. Contains ($param.Name )) {
232233 $newEntry.parameters [$param.Name ] = $param.Value
234+ $entry2name += CreateDisplayName $param.Value $displayNamesLookup
233235 } else {
234236 Write-Warning " Skipping duplicate parameter `" $ ( $param.Name ) `" when combining matrix."
235237 }
236238 }
237239
238240 # The maximum allowed matrix name length is 100 characters
239- $entry2.name = $entry2.name.TrimStart (" job_" )
240- $newEntry.name = $newEntry.name , $entry2.name -join " _"
241+ $newEntry.name = @ ($newEntry.name , ($entry2name -join " _" )) -join " _"
241242 if ($newEntry.name.Length -gt 100 ) {
242243 $newEntry.name = $newEntry.name [0 .. 99 ] -join " "
243244 }
@@ -305,7 +306,7 @@ function GenerateSparseMatrix(
305306
306307 if ($nonSparse ) {
307308 [Array ]$allOfMatrix = GenerateFullMatrix $nonSparse $displayNamesLookup
308- return CombineMatrices $allOfMatrix $sparseMatrix
309+ return CombineMatrices $allOfMatrix $sparseMatrix $displayNamesLookup
309310 }
310311
311312 return $sparseMatrix
0 commit comments