Skip to content

Commit

Permalink
Fix matrix dimension length bug for string values (#18231)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbp authored Jan 27, 2021
1 parent 211cab8 commit f7d760c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions eng/scripts/job-matrix/job-matrix-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function MatchesFilters([hashtable]$entry, [array]$filters) {
# Default all regex checks to go against empty string when keys are missing.
# This simplifies the filter syntax/interface to be regex only.
$value = ""
if ($entry.parameters.Contains($key)) {
if ($null -ne $entry -and $entry.parameters.Contains($key)) {
$value = $entry.parameters[$key]
}
if ($value -notmatch $regex) {
Expand Down Expand Up @@ -337,8 +337,10 @@ function GetMatrixDimensions([System.Collections.Specialized.OrderedDictionary]$
foreach ($val in $parameters.Values) {
if ($val -is [PSCustomObject]) {
$dimensions += ($val.PSObject.Properties | Measure-Object).Count
} else {
} elseif ($val -is [Array]) {
$dimensions += $val.Length
} else {
$dimensions += 1
}
}

Expand Down
3 changes: 3 additions & 0 deletions eng/scripts/job-matrix/job-matrix-functions.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ Describe "Platform Matrix Generation" -Tag "generate" {

It "Should get matrix dimensions from Nd parameters" {
GetMatrixDimensions $generateConfig.orderedMatrix | Should -Be 3, 2, 2

$generateConfig.orderedMatrix.Add("testStringParameter", "test")
GetMatrixDimensions $generateConfig.orderedMatrix | Should -Be 3, 2, 2, 1
}

It "Should use name overrides from displayNames" {
Expand Down

0 comments on commit f7d760c

Please sign in to comment.