@@ -105,76 +105,79 @@ jobs:
105105
106106 LogGroup 'Source Code Test Suites:' {
107107 if ($skipTests -notcontains 'SourceCode') {
108- $osConfigs | Format-Table -AutoSize | Out-String
109- Set-GitHubOutput -Name SourceCodeTestSuites -Value $osConfigs
108+ $sourceCodeTestSuites = $osConfigs
110109 }
110+ $sourceCodeTestSuites | Format-Table -AutoSize | Out-String
111+ Set-GitHubOutput -Name SourceCodeTestSuites -Value ($sourceCodeTestSuites ?? '[]')
111112 }
112113
113114 LogGroup 'Module Test Suites:' {
114115 if ($skipTests -notcontains 'Module') {
115- $osConfigs | Format-Table -AutoSize | Out-String
116- Set-GitHubOutput -Name ModuleTestSuites -Value $osConfigs
116+ $moduleTestSuites = $osConfigs
117117 }
118+ $moduleTestSuites | Format-Table -AutoSize | Out-String
119+ Set-GitHubOutput -Name ModuleTestSuites -Value ($moduleTestSuites ?? '[]')
118120 }
119121
120122 LogGroup 'Module Local Test Suites:' {
121- # Locate the tests directory.
122- $testsPath = Resolve-Path 'tests' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path
123- if (-not $testsPath -or -not (Test-Path -Path $testsPath)) {
124- Write-Warning 'No tests found'
125- exit 0
126- }
127- Write-Host "Tests found at [$testsPath]"
123+ if ($skipTests -notcontains 'Module') {
124+ # Locate the tests directory.
125+ $testsPath = Resolve-Path 'tests' -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Path
126+ if (-not $testsPath -or -not (Test-Path -Path $testsPath)) {
127+ Write-Warning 'No tests found'
128+ exit 0
129+ }
130+ Write-Host "Tests found at [$testsPath]"
128131
129- function Get-TestItemsFromFolder {
130- param ([string]$FolderPath)
132+ function Get-TestItemsFromFolder {
133+ param ([string]$FolderPath)
131134
132- $configFiles = Get-ChildItem -Path $FolderPath -File -Filter '*.Configuration.ps1'
133- if ($configFiles.Count -eq 1) {
134- return @($configFiles)
135- } elseif ($configFiles.Count -gt 1) {
136- throw "Multiple configuration files found in [$FolderPath]. Please separate configurations into different folders."
137- }
135+ $configFiles = Get-ChildItem -Path $FolderPath -File -Filter '*.Configuration.ps1'
136+ if ($configFiles.Count -eq 1) {
137+ return @($configFiles)
138+ } elseif ($configFiles.Count -gt 1) {
139+ throw "Multiple configuration files found in [$FolderPath]. Please separate configurations into different folders."
140+ }
141+
142+ $containerFiles = Get-ChildItem -Path $FolderPath -File -Filter '*.Container.ps1'
143+ if ($containerFiles.Count -ge 1) {
144+ return $containerFiles
145+ }
138146
139- $containerFiles = Get-ChildItem -Path $FolderPath -File -Filter '*.Container.ps1'
140- if ($containerFiles.Count -ge 1) {
141- return $containerFiles
147+ $testFiles = Get-ChildItem -Path $FolderPath -File -Filter '*.Tests.ps1'
148+ return $testFiles
142149 }
143150
144- $testFiles = Get-ChildItem -Path $FolderPath -File -Filter '*.Tests.ps1'
145- return $testFiles
146- }
151+ function Find-TestDirectories {
152+ param ([string]$Path)
147153
148- function Find-TestDirectories {
149- param ([string]$ Path)
154+ $directories = @()
155+ $childDirs = Get-ChildItem - Path $Path -Directory
150156
151- $directories = @()
152- $childDirs = Get-ChildItem -Path $Path -Directory
157+ foreach ($dir in $childDirs) {
158+ $directories += $dir.FullName
159+ $directories += Find-TestDirectories -Path $dir.FullName
160+ }
153161
154- foreach ($dir in $childDirs) {
155- $directories += $dir.FullName
156- $directories += Find-TestDirectories -Path $dir.FullName
162+ return $directories
157163 }
158164
159- return $directories
160- }
161-
162- $allTestFolders = @($testsPath) + (Find-TestDirectories -Path $testsPath)
163-
164- $moduleLocalTestSuites = foreach ($folder in $allTestFolders) {
165- $testItems = Get-TestItemsFromFolder -FolderPath $folder
166- foreach ($item in $testItems) {
167- foreach ($osConfig in $osConfigs) {
168- [pscustomobject]@{
169- RunsOn = $osConfig.RunsOn
170- OSName = $osConfig.OSName
171- TestPath = Resolve-Path -Path $item.FullName -Relative
172- TestName = ($item.BaseName).Split('.')[0]
165+ $allTestFolders = @($testsPath) + (Find-TestDirectories -Path $testsPath)
166+
167+ $moduleLocalTestSuites = foreach ($folder in $allTestFolders) {
168+ $testItems = Get-TestItemsFromFolder -FolderPath $folder
169+ foreach ($item in $testItems) {
170+ foreach ($osConfig in $osConfigs) {
171+ [pscustomobject]@{
172+ RunsOn = $osConfig.RunsOn
173+ OSName = $osConfig.OSName
174+ TestPath = Resolve-Path -Path $item.FullName -Relative
175+ TestName = ($item.BaseName).Split('.')[0]
176+ }
173177 }
174178 }
175179 }
176180 }
177-
178181 $moduleLocalTestSuites | Format-Table -AutoSize | Out-String
179182 Set-GitHubOutput -Name ModuleLocalTestSuites -Value ($moduleLocalTestSuites ?? '[]')
180183 }
0 commit comments