Skip to content

Commit f302d95

Browse files
committed
Skip missing PHP test directories
1 parent bd19d90 commit f302d95

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

php/BuildPhp/config/ext_test_directories

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ext\soap\tests
2020
ext\spl\tests
2121
ext\sqlite3\tests
2222
ext\standard\tests
23+
ext\uri\tests
2324
ext\xmlreader\tests
2425
ext\xmlwriter\tests
2526
ext\xml\tests

php/BuildPhp/private/Get-TestsList.ps1

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,32 @@ function Get-TestsList {
3131
$directories = Get-Content "$PSScriptRoot\..\config\${Type}_test_directories"
3232
}
3333

34-
foreach ($line in $directories) {
35-
$path = "$line".Trim()
36-
if ([string]::IsNullOrWhiteSpace($path)) {
37-
continue
38-
}
34+
$testsFound = 0
35+
$outputFilePath = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($OutputFile)
36+
$writer = [System.IO.StreamWriter]::new($outputFilePath, $false)
37+
try {
38+
foreach ($line in $directories) {
39+
$path = "$line".Trim()
40+
if ([string]::IsNullOrWhiteSpace($path)) {
41+
continue
42+
}
43+
44+
if (-not (Test-Path -Path $path -PathType Container)) {
45+
Write-Host "Skipping missing test directory: $path"
46+
continue
47+
}
3948

40-
$ttr = Get-ChildItem -Path $path -Filter "*.phpt" -Recurse
41-
foreach ($t in $ttr) {
42-
Add-Content $OutputFile $t.FullName
49+
Get-ChildItem -Path $path -Filter "*.phpt" -Recurse | ForEach-Object {
50+
$testsFound++
51+
$writer.WriteLine($_.FullName)
52+
}
4353
}
54+
} finally {
55+
$writer.Dispose()
56+
}
57+
58+
if ($testsFound -eq 0) {
59+
throw "No tests were found in the configured $Type test directories."
4460
}
4561
}
4662
end {

0 commit comments

Comments
 (0)