Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions tools/devops/automation/scripts/TestConfiguration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,75 @@ Describe 'Get-TestConfiguration' {
"@
}

Context 'macOS tests excluded when platforms disabled' {
It "excludes mac tests when neither macOS nor MacCatalyst is enabled" {
$macTestConfigs = @"
[
{
"label": "cecil",
"splitByPlatforms": "false",
"testPrefix": "simulator_tests"
},
{
"label": "mac_monterey",
"displayName": "Tests on macOS Monterey (12)",
"splitByPlatforms": "false",
"testPrefix": "mac_12_m1",
"testStage": "mac_12_m1",
"isMacTest": true
}
]
"@
$supportedPlatforms = @"
[
{ "platform": "iOS" },
{ "platform": "tvOS" }
]
"@
# Only tvOS enabled — no macOS or MacCatalyst
$result = Get-TestConfiguration `
-TestConfigurations $macTestConfigs `
-SupportedPlatforms $supportedPlatforms `
-EnabledPlatforms "tvOS" `
-TestsLabels "test-labels" `
-StatusContext "ctx" `
-StageFilter ""

$parsed = $result | ConvertFrom-Json
# cecil should be present, mac_monterey should not
$parsed.cecil | Should -Not -BeNullOrEmpty
$parsed.PSObject.Properties.Name | Should -Not -Contain "mac_monterey"
}

It "includes mac tests when macOS is enabled" {
$macTestConfigs = @"
[
{
"label": "mac_monterey",
"displayName": "Tests on macOS Monterey (12)",
"splitByPlatforms": "false",
"testPrefix": "mac_12_m1",
"testStage": "mac_12_m1",
"isMacTest": true
}
]
"@
$supportedPlatforms = @"
[
{ "platform": "macOS" }
]
"@
$result = Get-TestConfiguration `
-TestConfigurations $macTestConfigs `
-SupportedPlatforms $supportedPlatforms `
-EnabledPlatforms "macOS" `
-TestsLabels "test-labels" `
-StatusContext "ctx" `
-StageFilter ""

$parsed = $result | ConvertFrom-Json
$parsed.mac_monterey | Should -Not -BeNullOrEmpty
}
}

Comment thread
rolfbjarne marked this conversation as resolved.
}
9 changes: 9 additions & 0 deletions tools/devops/automation/scripts/TestConfiguration.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ class TestConfiguration {
Write-Host "Test $label with testStage '$testStage' is included, because there's no stage filter set"
}

# Skip macOS tests if neither macOS nor MacCatalyst platforms are enabled
if ($config.isMacTest -eq "true" -or $config.isMacTest -eq $true) {
$hasMacPlatform = ($this.enabledPlatforms -contains "macOS") -or ($this.enabledPlatforms -contains "MacCatalyst")
if (-not $hasMacPlatform) {
Write-Host "Skipping mac test $label - neither macOS nor MacCatalyst platforms are enabled"
continue
}
}
Comment thread
rolfbjarne marked this conversation as resolved.

$vars = [ordered]@{}
# set common variables
$vars["LABEL"] = $label
Expand Down
2 changes: 1 addition & 1 deletion tools/devops/automation/templates/mac/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ stages:
dependsOn:
- build_macos_tests
- configure_build
condition: and(succeeded(), eq(stageDependencies.configure_build.outputs['configure.decisions.RUN_MAC_TESTS'], 'true'))
condition: and(succeeded(), eq(dependencies.configure_build.outputs['configure.decisions.RUN_MAC_TESTS'], 'true'))
variables:
GITHUB_FAILURE_COMMENT_FILE: $(System.DefaultWorkingDirectory)/github-comment-file.md

Expand Down
Loading