Sync eng/common directory with azure-sdk-tools for PR 1498 (#1924)
* Fix null check against matrix parameter array * add negative test cases Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com> Co-authored-by: Chidozie Ononiwu <31145988+chidozieononiwu@users.noreply.github.com>
This commit is contained in:
parent
e360553546
commit
e464f8b01e
@ -474,7 +474,7 @@ function GenerateFullMatrix(
|
||||
[Hashtable]$displayNamesLookup = @{}
|
||||
) {
|
||||
# Handle when the config does not have a matrix specified (e.g. only the include field is specified)
|
||||
if ($parameters.Count -eq 0) {
|
||||
if (!$parameters) {
|
||||
return @()
|
||||
}
|
||||
|
||||
|
||||
@ -404,4 +404,26 @@ Describe "Platform Matrix Replace" -Tag "replace" {
|
||||
$matrix[1].name | Should -Be "foo2_barReplacedBar2"
|
||||
$matrix[1].parameters.Bar | Should -Be "barReplacedBar2"
|
||||
}
|
||||
|
||||
It "Should only fully match a string for replace" {
|
||||
$matrixJson = @'
|
||||
{
|
||||
"matrix": {
|
||||
"Foo": [ "foo1", "foo2" ],
|
||||
"Bar": "bar1"
|
||||
}
|
||||
}
|
||||
'@
|
||||
|
||||
$importConfig = GetMatrixConfigFromJson $matrixJson
|
||||
|
||||
$replace = @("Foo=foo/shouldNotReplaceFoo", "B=bar1/shouldNotReplaceBar")
|
||||
$matrix = GenerateMatrix -config $importConfig -selectFromMatrixType "sparse" -replace $replace
|
||||
|
||||
$matrix.Length | Should -Be 2
|
||||
$matrix[0].parameters.Foo | Should -Be "foo1"
|
||||
$matrix[0].parameters.Bar | Should -Be "bar1"
|
||||
$matrix[1].parameters.Foo | Should -Be "foo2"
|
||||
$matrix[1].parameters.Bar | Should -Be "bar1"
|
||||
}
|
||||
}
|
||||
|
||||
@ -466,6 +466,40 @@ Describe "Platform Matrix Post Transformation" -Tag "transform" {
|
||||
$matrix[7].parameters.operatingSystem | Should -Be "windows-2019"
|
||||
$matrix[7].parameters.additionalArguments | Should -Be "--enableWindowsFoo"
|
||||
}
|
||||
|
||||
It "Should parse a config with an empty base matrix" {
|
||||
$matrixConfigForIncludeOnly = @"
|
||||
{
|
||||
"include": [
|
||||
{
|
||||
"operatingSystem": "windows-2019",
|
||||
"framework": "net461"
|
||||
}
|
||||
]
|
||||
}
|
||||
"@
|
||||
|
||||
$config = GetMatrixConfigFromJson $matrixConfigForIncludeOnly
|
||||
[Array]$matrix = GenerateMatrix $config "all"
|
||||
$matrix.Length | Should -Be 1
|
||||
$matrix[0].name | Should -Be "windows2019_net461"
|
||||
}
|
||||
|
||||
It "Should parse a config with an empty include" {
|
||||
$matrixConfigForIncludeOnly = @"
|
||||
{
|
||||
"matrix": {
|
||||
"operatingSystem": "windows-2019",
|
||||
"framework": "net461"
|
||||
}
|
||||
}
|
||||
"@
|
||||
|
||||
$config = GetMatrixConfigFromJson $matrixConfigForIncludeOnly
|
||||
[Array]$matrix = GenerateMatrix $config "all"
|
||||
$matrix.Length | Should -Be 1
|
||||
$matrix[0].name | Should -Be "windows2019_net461"
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Platform Matrix Generation With Object Fields" -Tag "objectfields" {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user