Skip to content

Commit 52e3eda

Browse files
committed
Try to fix CI null test bug
1 parent b94e9e9 commit 52e3eda

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

eng/common-tests/matrix-generator/tests/job-matrix-functions.modification.tests.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,26 +591,34 @@ Describe "Platform Matrix Environment Variables" -Tag "UnitTest", "envvar" {
591591
"matrix": {
592592
"foo": "bar",
593593
"envReference": ["env:TestMatrixEnvReference", "env:TestMatrixEnvReference2", "noref"]
594-
}
594+
},
595+
"include": [
596+
{
597+
"foo": "bar",
598+
"envReference": "env:TestMatrixEnvReference"
599+
}
600+
]
595601
}
596602
'@
597603

598604
[System.Environment]::SetEnvironmentVariable("TestMatrixEnvReference", "")
599605
[array]$matrix = GenerateMatrix (GetMatrixConfigFromJson $matrixJson) "sparse"
600-
$matrix.Length | Should -Be 3
606+
$matrix.Length | Should -Be 4
601607
$matrix[0].name | Should -Be "bar"
602608
$matrix[0].parameters.envReference | Should -Be ""
603609

604610
[System.Environment]::SetEnvironmentVariable("TestMatrixEnvReference", "replaced")
605611
[System.Environment]::SetEnvironmentVariable("TestMatrixEnvReference2", "replaced2")
606612
[array]$replacedMatrix = GenerateMatrix (GetMatrixConfigFromJson $matrixJson) "sparse"
607-
$replacedMatrix.Length | Should -Be 3
613+
$replacedMatrix.Length | Should -Be 4
608614
$replacedMatrix[0].name | Should -Be "bar_replaced"
609615
$replacedMatrix[0].parameters.envReference | Should -Be "replaced"
610616
$replacedMatrix[1].name | Should -Be "bar_replaced2"
611617
$replacedMatrix[1].parameters.envReference | Should -Be "replaced2"
612618
$replacedMatrix[2].name | Should -Be "bar_noref"
613619
$replacedMatrix[2].parameters.envReference | Should -Be "noref"
620+
$replacedMatrix[3].name | Should -Be "bar_replaced"
621+
$replacedMatrix[3].parameters.envReference | Should -Be "replaced"
614622
}
615623

616624
It "Should support filter/replace with variable reference syntax" {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ function ProcessReplace {
338338
$replaceMatrix = @()
339339

340340
foreach ($element in $matrix) {
341+
if (!$element || [bool]$element.PSobject.Properties.name -notmatch "_permutation") {
342+
continue
343+
}
341344
$replacement = [MatrixParameter[]]@()
342345

343346
foreach ($perm in $element._permutation) {
@@ -371,6 +374,9 @@ function ProcessEnvironmentVariableReferences([array]$matrix, $displayNamesLooku
371374
$updatedMatrix = @()
372375

373376
foreach ($element in $matrix) {
377+
if (!$element || [bool]$element.PSobject.Properties.name -notmatch "_permutation") {
378+
continue
379+
}
374380
$updated = [MatrixParameter[]]@()
375381

376382
foreach ($perm in $element._permutation) {

0 commit comments

Comments
 (0)