diff --git a/eng/scripts/job-matrix/job-matrix-functions.ps1 b/eng/scripts/job-matrix/job-matrix-functions.ps1 index 3b581dbe9bca..2fbd8958acf7 100644 --- a/eng/scripts/job-matrix/job-matrix-functions.ps1 +++ b/eng/scripts/job-matrix/job-matrix-functions.ps1 @@ -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) { @@ -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 } } diff --git a/eng/scripts/job-matrix/job-matrix-functions.tests.ps1 b/eng/scripts/job-matrix/job-matrix-functions.tests.ps1 index fa32b0d2498b..5e50596e6cf6 100644 --- a/eng/scripts/job-matrix/job-matrix-functions.tests.ps1 +++ b/eng/scripts/job-matrix/job-matrix-functions.tests.ps1 @@ -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" {