@@ -73,10 +73,61 @@ jobs:
7373 }
7474 Write-Host "Tests found at [$testsPath]"
7575
76- # Get all subdirectories inside the tests folder; if none, use the tests folder itself.
77- $testsPaths = Get-ChildItem -Path $testsPath -Directory | ForEach-Object { $_.FullName }
78- if (-not $testsPaths) {
76+ # First, check if the root tests folder contains configuration.ps1, .container.ps1 or .tests.ps1 files
77+ $hasTestFiles = Get-ChildItem -Path $testsPath -File -Recurse:$false | Where-Object {
78+ $_.Name -like '*.Configuration.ps1' -or
79+ $_.Name -like '*.Container.ps1' -or
80+ $_.Name -like '*.Tests.ps1'
81+ }
82+
83+ # Define the test paths based on our findings
84+ $testsPaths = @()
85+ if ($hasTestFiles) {
86+ # If the tests folder directly contains test files, only use the root folder
87+ Write-Host "Test files found directly in tests folder. Using only the root tests folder."
7988 $testsPaths = @($testsPath)
89+ } else {
90+ # Otherwise, recursively search for subdirectories that might contain tests
91+ Write-Host "No test files found in root tests folder. Searching subdirectories..."
92+
93+ # Helper function to find test directories recursively
94+ function Find-TestDirectories {
95+ param (
96+ [string]$Path
97+ )
98+
99+ $directories = @()
100+ $childDirs = Get-ChildItem -Path $Path -Directory
101+
102+ foreach ($dir in $childDirs) {
103+ # Check if this directory contains test files
104+ $hasTests = Get-ChildItem -Path $dir.FullName -File -Recurse:$false | Where-Object {
105+ $_.Name -like '*.Configuration.ps1' -or
106+ $_.Name -like '*.Container.ps1' -or
107+ $_.Name -like '*.Tests.ps1'
108+ }
109+
110+ if ($hasTests) {
111+ $directories += $dir.FullName
112+ } else {
113+ # Recursively check subdirectories
114+ $directories += Find-TestDirectories -Path $dir.FullName
115+ }
116+ }
117+
118+ return $directories
119+ }
120+
121+ $testsPaths = Find-TestDirectories -Path $testsPath
122+
123+ # If no test directories were found, default to the root tests folder
124+ if (-not $testsPaths) {
125+ Write-Host "No specific test directories found. Using the root tests folder."
126+ $testsPaths = @($testsPath)
127+ } else {
128+ Write-Host "Found test directories:"
129+ $testsPaths | ForEach-Object { Write-Host " - $_" }
130+ }
80131 }
81132
82133 # Build the test suites matrix.
0 commit comments