Skip to content

Commit 4ed14b1

Browse files
committed
Use strict test discovery in Windows workflow
1 parent c323e89 commit 4ed14b1

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

.github/workflows/ql-unit-tests-windows.yml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,43 @@ jobs:
206206
exit 0
207207
}
208208
209-
# Find all test directories containing .qlref files in this test path
210-
$testDirs = Get-ChildItem -Path $testPath -Recurse -Filter "*.qlref" -ErrorAction SilentlyContinue |
211-
Select-Object -ExpandProperty DirectoryName |
212-
Sort-Object -Unique
209+
# Use CodeQL's strict test discovery to find valid tests
210+
Write-Host "Resolving tests with strict test discovery in: $testPath"
211+
212+
$resolveOutputFile = Join-Path $resultsDir "resolve-output.txt"
213+
$resolveErrorFile = Join-Path $resultsDir "resolve-errors.txt"
214+
215+
# Run codeql resolve tests with strict discovery
216+
$resolveProcess = Start-Process -FilePath "codeql" `
217+
-ArgumentList @("resolve", "tests", "--strict-test-discovery", "--format=text", "--", $testPath) `
218+
-Wait `
219+
-PassThru `
220+
-NoNewWindow `
221+
-RedirectStandardOutput $resolveOutputFile `
222+
-RedirectStandardError $resolveErrorFile
223+
224+
# Check if resolve succeeded
225+
if ($resolveProcess.ExitCode -ne 0) {
226+
Write-Host "❌ Failed to resolve tests"
227+
if (Test-Path $resolveErrorFile) {
228+
Get-Content $resolveErrorFile | Write-Host
229+
}
230+
exit $resolveProcess.ExitCode
231+
}
232+
233+
# Read discovered test directories
234+
$testDirs = @()
235+
if (Test-Path $resolveOutputFile) {
236+
$testDirs = Get-Content $resolveOutputFile | Where-Object { $_.Trim() -ne "" }
237+
}
213238
214239
if ($testDirs.Count -eq 0) {
215-
Write-Host "⚠️ No test directories found in: $testPath"
240+
Write-Host "⚠️ No valid test directories found in: $testPath"
216241
Write-Host "Skipping tests for this suite"
217242
exit 0
218243
}
219244
220-
Write-Host "Found $($testDirs.Count) test directory(ies) in $testPath :"
245+
Write-Host "Found $($testDirs.Count) valid test directory(ies):"
221246
$testDirs | ForEach-Object { Write-Host " - $_" }
222247
Write-Host ""
223248

0 commit comments

Comments
 (0)