Skip to content

Commit ee81f5f

Browse files
committed
Fix PHP test harness environments
1 parent 13f1f11 commit ee81f5f

10 files changed

Lines changed: 189 additions & 39 deletions

php/BuildPhp/config/ext_test_directories

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ ext\reflection\tests
4444
ext\session\tests
4545
ext\shmop\tests
4646
ext\simplexml\tests
47-
ext\snmp\tests
4847
ext\soap\tests
4948
ext\sockets\tests
5049
ext\sodium\tests

php/BuildPhp/config/run-tests/run-tests-7.4.patch

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,17 @@
476476
break;
477477
default:
478478
send_message($workerSock, [
479+
@@ -3384,7 +3691,9 @@
480+
481+
if (!empty($suite_name)) {
482+
foreach ($suite['files'] as $file) {
483+
- $result .= $JUNIT['files'][$file]['xml'];
484+
+ if (isset($JUNIT['files'][$file]['xml'])) {
485+
+ $result .= $JUNIT['files'][$file]['xml'];
486+
+ }
487+
}
488+
}
489+
479490
@@ -3414,6 +3721,8 @@
480491
if (!junit_enabled()) return;
481492

@@ -493,3 +504,21 @@
493504
$JUNIT['suites'][$suite][$param] += $value;
494505
}
495506

507+
@@ -3586,7 +3895,7 @@
508+
$JUNIT['test_skip'] += $junit['test_skip'];
509+
$JUNIT['test_warn'] += $junit['test_warn'];
510+
$JUNIT['execution_time'] += $junit['execution_time'];
511+
- $JUNIT['files'] += $junit['files'];
512+
+ $JUNIT['files'] = array_replace($JUNIT['files'], $junit['files']);
513+
foreach ($junit['suites'] as $name => $suite) {
514+
if (!isset($JUNIT['suites'][$name])) {
515+
$JUNIT['suites'][$name] = $suite;
516+
@@ -3601,7 +3910,7 @@
517+
$SUITE['test_skip'] += $suite['test_skip'];
518+
$SUITE['test_warn'] += $suite['test_warn'];
519+
$SUITE['execution_time'] += $suite['execution_time'];
520+
- $SUITE['files'] += $suite['files'];
521+
+ $SUITE['files'] = array_replace($SUITE['files'], $suite['files']);
522+
}
523+
}
524+

php/BuildPhp/config/run-tests/run-tests-8.0.patch

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,17 @@
469469
break;
470470
default:
471471
send_message($workerSock, [
472+
@@ -3464,7 +3770,9 @@
473+
474+
if (!empty($suite_name)) {
475+
foreach ($suite['files'] as $file) {
476+
- $result .= $JUNIT['files'][$file]['xml'];
477+
+ if (isset($JUNIT['files'][$file]['xml'])) {
478+
+ $result .= $JUNIT['files'][$file]['xml'];
479+
+ }
480+
}
481+
}
482+
472483
@@ -3496,6 +3802,8 @@
473484
}
474485

@@ -486,3 +497,21 @@
486497
$JUNIT['suites'][$suite][$param] += $value;
487498
}
488499

500+
@@ -3677,7 +3985,7 @@
501+
$JUNIT['test_skip'] += $junit['test_skip'];
502+
$JUNIT['test_warn'] += $junit['test_warn'];
503+
$JUNIT['execution_time'] += $junit['execution_time'];
504+
- $JUNIT['files'] += $junit['files'];
505+
+ $JUNIT['files'] = array_replace($JUNIT['files'], $junit['files']);
506+
foreach ($junit['suites'] as $name => $suite) {
507+
if (!isset($JUNIT['suites'][$name])) {
508+
$JUNIT['suites'][$name] = $suite;
509+
@@ -3692,7 +4000,7 @@
510+
$SUITE['test_skip'] += $suite['test_skip'];
511+
$SUITE['test_warn'] += $suite['test_warn'];
512+
$SUITE['execution_time'] += $suite['execution_time'];
513+
- $SUITE['files'] += $suite['files'];
514+
+ $SUITE['files'] = array_replace($SUITE['files'], $suite['files']);
515+
}
516+
}
517+

php/BuildPhp/config/run-tests/run-tests-8.1.patch

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,17 @@
472472
break;
473473
default:
474474
send_message($workerSock, [
475+
@@ -3549,7 +3858,9 @@
476+
477+
if (!empty($suite_name)) {
478+
foreach ($suite['files'] as $file) {
479+
- $result .= $this->rootSuite['files'][$file]['xml'];
480+
+ if (isset($this->rootSuite['files'][$file]['xml'])) {
481+
+ $result .= $this->rootSuite['files'][$file]['xml'];
482+
+ }
483+
}
484+
}
485+
475486
@@ -3571,6 +3880,8 @@
476487
}
477488

@@ -489,3 +500,12 @@
489500
$this->suites[$suite][$param] += $value;
490501
}
491502

503+
@@ -3753,7 +4064,7 @@
504+
$dest['test_skip'] += $source['test_skip'];
505+
$dest['test_warn'] += $source['test_warn'];
506+
$dest['execution_time'] += $source['execution_time'];
507+
- $dest['files'] += $source['files'];
508+
+ $dest['files'] = array_replace($dest['files'], $source['files']);
509+
}
510+
}
511+

php/BuildPhp/config/run-tests/run-tests-8.2-plus.patch

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- run-tests.php
22
+++ run-tests.php
3-
@@ -140,6 +140,275 @@
3+
@@ -140,6 +140,288 @@
44
* code that was previously found at the top level. It could and should be
55
* refactored to be smaller and more manageable.
66
*/
@@ -108,6 +108,19 @@
108108
+ }
109109
+ }
110110
+
111+
+ function buildphp_worker_recovery_save_junit_on_error($message)
112+
+ {
113+
+ if (($GLOBALS['workerID'] ?? 0) !== 0 || !buildphp_worker_recovery_has_object_junit()) {
114+
+ return;
115+
+ }
116+
+
117+
+ $junit = $GLOBALS['junit'];
118+
+ if ($junit->isEnabled()) {
119+
+ $junit->markTestAs('BORK', 'run-tests.php', 'Infrastructure error', null, $message);
120+
+ $junit->saveXML();
121+
+ }
122+
+ }
123+
+
111124
+ function buildphp_worker_recovery_track_started(&$workerBatches, $workerID, $assignedName, $name, $index)
112125
+ {
113126
+ if (!isset($workerBatches[$workerID])) {
@@ -278,7 +291,7 @@
278291
/* This list was derived in a naïve mechanical fashion. If a member
279292
@@ -1285,22 +1553,20 @@
280293
}
281-
294+
282295
foreach ($test_files as $name) {
283296
- if (is_array($name)) {
284297
- $index = "# $name[1]: $name[0]";
@@ -295,7 +308,7 @@
295308
+ $index = buildphp_worker_recovery_format_test_index($name, $redir_tested);
296309
+ $name = buildphp_worker_recovery_get_result_test_name($name, $redir_tested);
297310
$test_idx++;
298-
311+
299312
if ($workerID) {
300313
$PHP_FAILED_TESTS = ['BORKED' => [], 'FAILED' => [], 'WARNED' => [], 'LEAKED' => [], 'XFAILED' => [], 'XLEAKED' => [], 'SLOW' => []];
301314
ob_start();
@@ -306,7 +319,7 @@
306319
+ "index" => $index,
307320
+ ]);
308321
}
309-
322+
310323
$result = run_test($php, $name, $env);
311324
@@ -1312,12 +1578,15 @@
312325
if ($workerID) {
@@ -324,18 +337,18 @@
324337
+ buildphp_worker_recovery_reset_junit();
325338
continue;
326339
}
327-
340+
328341
@@ -1345,6 +1614,8 @@
329-
342+
330343
$workerProcs = [];
331344
$workerSocks = [];
332345
+ $workerBatches = [];
333346
+ $workerCrashRetryTests = [];
334-
347+
335348
// Each test may specify a list of conflict keys. While a test that conflicts with
336349
// key K is running, no other test that conflicts with K may run. Conflict keys are
337350
@@ -1486,6 +1756,15 @@
338-
351+
339352
escape:
340353
while ($test_files || $sequentialTests || $testsInProgress > 0) {
341354
+ if (!$workerSocks) {
@@ -378,7 +391,7 @@
378391
error("Worker $i died unexpectedly");
379392
}
380393
@@ -1520,19 +1829,12 @@
381-
394+
382395
switch ($message["type"]) {
383396
case "tests_finished":
384397
- $testsInProgress--;
@@ -434,9 +447,9 @@
434447
$PHP_FAILED_TESTS[$category] = array_merge($PHP_FAILED_TESTS[$category], $tests);
435448
}
436449
@@ -1630,4 +1940,12 @@
437-
450+
438451
kill_children($workerProcs);
439-
452+
440453
+ if ($workerCrashRetryTests) {
441454
+ echo "Retrying " . count($workerCrashRetryTests) . " tests interrupted by worker crashes serially...\n";
442455
+ $savedWorkers = $workers;
@@ -458,20 +471,45 @@
458471
break;
459472
default:
460473
send_message($workerSock, [
461-
@@ -3380,6 +3694,8 @@
474+
@@ -2942,6 +3269,7 @@
475+
function error(string $message): void
476+
{
477+
echo "ERROR: {$message}\n";
478+
+ buildphp_worker_recovery_save_junit_on_error($message);
479+
exit(1);
480+
}
481+
482+
@@ -3353,5 +3681,7 @@
483+
if (!empty($suite_name)) {
484+
foreach ($suite['files'] as $file) {
485+
- $result .= $this->rootSuite['files'][$file]['xml'];
486+
+ if (isset($this->rootSuite['files'][$file]['xml'])) {
487+
+ $result .= $this->rootSuite['files'][$file]['xml'];
488+
+ }
489+
}
490+
}
491+
@@ -3380,6 +3708,8 @@
462492
}
463-
493+
464494
$suite = $this->getSuiteName($file_name);
465495
+ $this->initSuite($suite);
466496
+ $this->suites[$suite]['files'][$file_name] = $file_name;
467-
497+
468498
$this->record($suite, 'test_total');
469-
499+
470500
@@ -3428,6 +3744,7 @@
471501
private function record(string $suite, string $param, $value = 1): void
472502
{
473503
$this->rootSuite[$param] += $value;
474504
+ $this->initSuite($suite);
475505
$this->suites[$suite][$param] += $value;
476506
}
477-
507+
508+
@@ -3473,6 +3791,6 @@
509+
$dest['test_skip'] += $source['test_skip'];
510+
$dest['test_warn'] += $source['test_warn'];
511+
$dest['execution_time'] += $source['execution_time'];
512+
- $dest['files'] += $source['files'];
513+
+ $dest['files'] = array_replace($dest['files'], $source['files']);
514+
}
515+
}

php/BuildPhp/private/Set-FirebirdTestEnvironment.ps1

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@ function Set-FirebirdTestEnvironment {
22
<#
33
.SYNOPSIS
44
Configure Firebird for PDO_Firebird tests on Windows.
5+
.PARAMETER Arch
6+
PHP architecture.
57
#>
68
[CmdletBinding()]
7-
param ()
9+
param (
10+
[Parameter(Mandatory = $false, Position=0, HelpMessage='PHP architecture')]
11+
[ValidateSet('x86', 'x64')]
12+
[string] $Arch = 'x64'
13+
)
814
process {
9-
$destDir = 'C:\Firebird'
15+
$destDir = "C:\Firebird-$Arch"
1016
$firebirdVersion = 'v4.0.4'
1117
$firebirdRelease = "https://github.com/FirebirdSQL/firebird/releases/download/$firebirdVersion"
1218
New-Item -ItemType Directory -Force -Path $destDir | Out-Null
1319

14-
$is64 = [Environment]::Is64BitOperatingSystem
15-
$url = if ($is64) {
20+
$url = if ($Arch -eq 'x64') {
1621
"$firebirdRelease/Firebird-4.0.4.3010-0-x64.zip"
1722
} else {
1823
"$firebirdRelease/Firebird-4.0.4.3010-0-Win32.zip"
@@ -28,10 +33,11 @@ function Set-FirebirdTestEnvironment {
2833
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPath, $destDir)
2934
}
3035

31-
$env:PDO_FIREBIRD_TEST_DATABASE = 'C:\test.fdb'
36+
$env:PDO_FIREBIRD_TEST_DATABASE = "C:\test-$Arch.fdb"
3237
$env:PDO_FIREBIRD_TEST_DSN = "firebird:dbname=127.0.0.1:$($env:PDO_FIREBIRD_TEST_DATABASE)"
3338
$env:PDO_FIREBIRD_TEST_USER = 'SYSDBA'
3439
$env:PDO_FIREBIRD_TEST_PASS = 'phpfi'
40+
$serviceName = "PHPTestFirebird$Arch"
3541

3642
$createUserSql = Join-Path $destDir 'create_user.sql'
3743
Set-Content -Path $createUserSql -Value "create user $($env:PDO_FIREBIRD_TEST_USER) password '$($env:PDO_FIREBIRD_TEST_PASS)';" -Encoding ASCII
@@ -40,10 +46,13 @@ function Set-FirebirdTestEnvironment {
4046
$setupSql = Join-Path $destDir 'setup.sql'
4147
Set-Content -Path $setupSql -Value "create database '$($env:PDO_FIREBIRD_TEST_DATABASE)' user '$($env:PDO_FIREBIRD_TEST_USER)' password '$($env:PDO_FIREBIRD_TEST_PASS)';" -Encoding ASCII
4248
if(-not(Test-Path pdo_firebird_db_created)) {
43-
& (Join-Path $destDir 'instsvc.exe') install -n TestInstance | Out-Null
49+
if (Test-Path -LiteralPath $env:PDO_FIREBIRD_TEST_DATABASE) {
50+
Remove-Item -LiteralPath $env:PDO_FIREBIRD_TEST_DATABASE -Force
51+
}
52+
& (Join-Path $destDir 'instsvc.exe') install -n $serviceName | Out-Null
4453
& (Join-Path $destDir 'isql') -q -i $setupSql | Out-Null
4554
& (Join-Path $destDir 'isql') -q -i $createUserSql -user sysdba $env:PDO_FIREBIRD_TEST_DATABASE | Out-Null
46-
& (Join-Path $destDir 'instsvc.exe') start -n TestInstance | Out-Null
55+
& (Join-Path $destDir 'instsvc.exe') start -n $serviceName | Out-Null
4756
Set-Content -Path pdo_firebird_db_created -Value "db_created" -Encoding ASCII
4857
}
4958

php/BuildPhp/private/Set-MsSqlTestEnvironment.ps1

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,26 @@ function Set-MsSqlTestEnvironment {
1111
}
1212

1313
$serviceName = 'MSSQL$SQLEXPRESS'
14-
& choco install sql-server-express -y --no-progress --install-arguments="/SECURITYMODE=SQL /SAPWD=Password12!"
15-
if (@(0, 3010) -notcontains $LASTEXITCODE) {
16-
throw "Failed to install SQL Server Express. choco exited with $LASTEXITCODE."
14+
$installExitCode = $null
15+
for($attempt = 1; $attempt -le 3; $attempt++) {
16+
Write-Host "Installing SQL Server Express (attempt $attempt of 3)..."
17+
& choco install sql-server-express -y --no-progress --install-arguments="/SECURITYMODE=SQL /SAPWD=Password12!"
18+
$installExitCode = $LASTEXITCODE
19+
if (@(0, 3010) -contains $installExitCode) {
20+
break
21+
}
22+
23+
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue
24+
if ($service) {
25+
break
26+
}
27+
28+
if ($attempt -lt 3) {
29+
Start-Sleep -Seconds (15 * $attempt)
30+
}
31+
}
32+
if (@(0, 3010) -notcontains $installExitCode -and -not (Get-Service -Name $serviceName -ErrorAction SilentlyContinue)) {
33+
throw "Failed to install SQL Server Express. choco exited with $installExitCode."
1734
}
1835

1936
$service = Get-Service -Name $serviceName -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)