Skip to content

Commit 233c3d8

Browse files
azure-sdkbenbpscbedd
authored
Sync eng/common directory with azure-sdk-tools for PR 10081 (#44703)
* update generate-matrix function ProcessImport to return a structured result, versus a tuple that is destructured immediately Co-authored-by: Ben Broderick Phillips <[email protected]> Co-authored-by: Scott Beddall <[email protected]>
1 parent 8aba82c commit 233c3d8

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

eng/common/scripts/job-matrix/job-matrix-functions.ps1

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ function GenerateMatrix(
9999
[Array]$nonSparseParameters = @(),
100100
[Switch]$skipEnvironmentVariables
101101
) {
102-
$matrixParameters, $importedMatrix, $combinedDisplayNameLookup = `
103-
ProcessImport $config.matrixParameters $selectFromMatrixType $nonSparseParameters $config.displayNamesLookup
102+
$result = ProcessImport $config.matrixParameters $selectFromMatrixType $nonSparseParameters $config.displayNamesLookup
103+
104+
$matrixParameters = $result.Matrix
105+
$importedMatrix = $result.ImportedMatrix
106+
$combinedDisplayNameLookup = $result.DisplayNamesLookup
107+
104108
if ($selectFromMatrixType -eq "sparse") {
105109
$matrix = GenerateSparseMatrix $matrixParameters $config.displayNamesLookup $nonSparseParameters
106110
}
@@ -144,6 +148,9 @@ function ProcessNonSparseParameters(
144148
$nonSparse = [MatrixParameter[]]@()
145149

146150
foreach ($param in $parameters) {
151+
if ($null -eq $param){
152+
continue
153+
}
147154
if ($param.Name -in $nonSparseParameters) {
148155
$nonSparse += $param
149156
}
@@ -422,7 +429,11 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n
422429
}
423430
}
424431
if ((!$matrix -and !$importPath) -or !$importPath) {
425-
return $matrix, @(), $displayNamesLookup
432+
return [PSCustomObject]@{
433+
Matrix = $matrix
434+
ImportedMatrix = @()
435+
DisplayNamesLookup = $displayNamesLookup
436+
}
426437
}
427438

428439
if (!(Test-Path $importPath)) {
@@ -444,7 +455,11 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n
444455
$combinedDisplayNameLookup[$lookup.Name] = $lookup.Value
445456
}
446457

447-
return $matrix, $importedMatrix, $combinedDisplayNameLookup
458+
return [PSCustomObject]@{
459+
Matrix = $matrix ?? @()
460+
ImportedMatrix = $importedMatrix
461+
DisplayNamesLookup = $combinedDisplayNameLookup
462+
}
448463
}
449464

450465
function CombineMatrices([Array]$matrix1, [Array]$matrix2, [Hashtable]$displayNamesLookup = @{}) {
@@ -628,6 +643,9 @@ function InitializeMatrix {
628643
function GetMatrixDimensions([MatrixParameter[]]$parameters) {
629644
$dimensions = @()
630645
foreach ($param in $parameters) {
646+
if ($null -eq $param){
647+
continue
648+
}
631649
$dimensions += $param.Length()
632650
}
633651

0 commit comments

Comments
 (0)