Skip to content

Commit

Permalink
Try to fix CI null test bug
Browse files Browse the repository at this point in the history
  • Loading branch information
benbp committed Feb 14, 2024
1 parent b94e9e9 commit 70aabf9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -591,26 +591,34 @@ Describe "Platform Matrix Environment Variables" -Tag "UnitTest", "envvar" {
"matrix": {
"foo": "bar",
"envReference": ["env:TestMatrixEnvReference", "env:TestMatrixEnvReference2", "noref"]
}
},
"include": [
{
"foo": "bar",
"envReference": "env:TestMatrixEnvReference"
}
]
}
'@

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

[System.Environment]::SetEnvironmentVariable("TestMatrixEnvReference", "replaced")
[System.Environment]::SetEnvironmentVariable("TestMatrixEnvReference2", "replaced2")
[array]$replacedMatrix = GenerateMatrix (GetMatrixConfigFromJson $matrixJson) "sparse"
$replacedMatrix.Length | Should -Be 3
$replacedMatrix.Length | Should -Be 4
$replacedMatrix[0].name | Should -Be "bar_replaced"
$replacedMatrix[0].parameters.envReference | Should -Be "replaced"
$replacedMatrix[1].name | Should -Be "bar_replaced2"
$replacedMatrix[1].parameters.envReference | Should -Be "replaced2"
$replacedMatrix[2].name | Should -Be "bar_noref"
$replacedMatrix[2].parameters.envReference | Should -Be "noref"
$replacedMatrix[3].name | Should -Be "bar_replaced"
$replacedMatrix[3].parameters.envReference | Should -Be "replaced"
}

It "Should support filter/replace with variable reference syntax" {
Expand Down
6 changes: 6 additions & 0 deletions eng/common/scripts/job-matrix/job-matrix-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ function ProcessReplace {
$replaceMatrix = @()

foreach ($element in $matrix) {
if (!$element || $element.PSobject.Properties.name -match "_permutation") {
continue
}
$replacement = [MatrixParameter[]]@()

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

foreach ($element in $matrix) {
if (!$element || $element.PSobject.Properties.name -match "_permutation") {
continue
}
$updated = [MatrixParameter[]]@()

foreach ($perm in $element._permutation) {
Expand Down

0 comments on commit 70aabf9

Please sign in to comment.