|
1 | 1 | --- run-tests.php |
2 | 2 | +++ run-tests.php |
3 | | -@@ -140,6 +140,275 @@ |
| 3 | +@@ -140,6 +140,288 @@ |
4 | 4 | * code that was previously found at the top level. It could and should be |
5 | 5 | * refactored to be smaller and more manageable. |
6 | 6 | */ |
|
108 | 108 | + } |
109 | 109 | + } |
110 | 110 | + |
| 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 | ++ |
111 | 124 | + function buildphp_worker_recovery_track_started(&$workerBatches, $workerID, $assignedName, $name, $index) |
112 | 125 | + { |
113 | 126 | + if (!isset($workerBatches[$workerID])) { |
|
278 | 291 | /* This list was derived in a naïve mechanical fashion. If a member |
279 | 292 | @@ -1285,22 +1553,20 @@ |
280 | 293 | } |
281 | | - |
| 294 | + |
282 | 295 | foreach ($test_files as $name) { |
283 | 296 | - if (is_array($name)) { |
284 | 297 | - $index = "# $name[1]: $name[0]"; |
|
295 | 308 | + $index = buildphp_worker_recovery_format_test_index($name, $redir_tested); |
296 | 309 | + $name = buildphp_worker_recovery_get_result_test_name($name, $redir_tested); |
297 | 310 | $test_idx++; |
298 | | - |
| 311 | + |
299 | 312 | if ($workerID) { |
300 | 313 | $PHP_FAILED_TESTS = ['BORKED' => [], 'FAILED' => [], 'WARNED' => [], 'LEAKED' => [], 'XFAILED' => [], 'XLEAKED' => [], 'SLOW' => []]; |
301 | 314 | ob_start(); |
|
306 | 319 | + "index" => $index, |
307 | 320 | + ]); |
308 | 321 | } |
309 | | - |
| 322 | + |
310 | 323 | $result = run_test($php, $name, $env); |
311 | 324 | @@ -1312,12 +1578,15 @@ |
312 | 325 | if ($workerID) { |
|
324 | 337 | + buildphp_worker_recovery_reset_junit(); |
325 | 338 | continue; |
326 | 339 | } |
327 | | - |
| 340 | + |
328 | 341 | @@ -1345,6 +1614,8 @@ |
329 | | - |
| 342 | + |
330 | 343 | $workerProcs = []; |
331 | 344 | $workerSocks = []; |
332 | 345 | + $workerBatches = []; |
333 | 346 | + $workerCrashRetryTests = []; |
334 | | - |
| 347 | + |
335 | 348 | // Each test may specify a list of conflict keys. While a test that conflicts with |
336 | 349 | // key K is running, no other test that conflicts with K may run. Conflict keys are |
337 | 350 | @@ -1486,6 +1756,15 @@ |
338 | | - |
| 351 | + |
339 | 352 | escape: |
340 | 353 | while ($test_files || $sequentialTests || $testsInProgress > 0) { |
341 | 354 | + if (!$workerSocks) { |
|
378 | 391 | error("Worker $i died unexpectedly"); |
379 | 392 | } |
380 | 393 | @@ -1520,19 +1829,12 @@ |
381 | | - |
| 394 | + |
382 | 395 | switch ($message["type"]) { |
383 | 396 | case "tests_finished": |
384 | 397 | - $testsInProgress--; |
|
434 | 447 | $PHP_FAILED_TESTS[$category] = array_merge($PHP_FAILED_TESTS[$category], $tests); |
435 | 448 | } |
436 | 449 | @@ -1630,4 +1940,12 @@ |
437 | | - |
| 450 | + |
438 | 451 | kill_children($workerProcs); |
439 | | - |
| 452 | + |
440 | 453 | + if ($workerCrashRetryTests) { |
441 | 454 | + echo "Retrying " . count($workerCrashRetryTests) . " tests interrupted by worker crashes serially...\n"; |
442 | 455 | + $savedWorkers = $workers; |
|
458 | 471 | break; |
459 | 472 | default: |
460 | 473 | 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 @@ |
462 | 492 | } |
463 | | - |
| 493 | + |
464 | 494 | $suite = $this->getSuiteName($file_name); |
465 | 495 | + $this->initSuite($suite); |
466 | 496 | + $this->suites[$suite]['files'][$file_name] = $file_name; |
467 | | - |
| 497 | + |
468 | 498 | $this->record($suite, 'test_total'); |
469 | | - |
| 499 | + |
470 | 500 | @@ -3428,6 +3744,7 @@ |
471 | 501 | private function record(string $suite, string $param, $value = 1): void |
472 | 502 | { |
473 | 503 | $this->rootSuite[$param] += $value; |
474 | 504 | + $this->initSuite($suite); |
475 | 505 | $this->suites[$suite][$param] += $value; |
476 | 506 | } |
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 | + } |
0 commit comments