summaryrefslogtreecommitdiff
path: root/run-tests.php
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-05-31 12:38:06 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-05-31 12:38:06 +0200
commitdd2bf448693df98d060d784fed798ec9ba461fad (patch)
treed9f6c3897e6288f213bf8b2d9228a79a0f807c45 /run-tests.php
parent137747bdaf8a5fa0d01e2d3833147aba66eb314d (diff)
downloadphp-git-dd2bf448693df98d060d784fed798ec9ba461fad.tar.gz
Add junit support for parallel test runner
Diffstat (limited to 'run-tests.php')
-rwxr-xr-xrun-tests.php75
1 files changed, 56 insertions, 19 deletions
diff --git a/run-tests.php b/run-tests.php
index eed88ef132..b8dbb9cc47 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -1544,6 +1544,9 @@ escape:
}
}
}
+ if (junit_enabled()) {
+ junit_merge_results($message["junit"]);
+ }
// intentional fall-through
case "ready":
// Schedule sequential tests only once we are down to one worker.
@@ -1712,8 +1715,10 @@ function run_worker() {
case "run_tests":
run_all_tests($command["test_files"], $command["env"], $command["redir_tested"]);
send_message($workerSock, [
- "type" => "tests_finished"
+ "type" => "tests_finished",
+ "junit" => junit_enabled() ? $GLOBALS['JUNIT'] : null,
]);
+ junit_init();
break;
default:
send_message($workerSock, [
@@ -3317,28 +3322,30 @@ function show_result($result, $tested, $tested_file, $extra = '', $temp_filename
function junit_init()
{
// Check whether a junit log is wanted.
+ global $workerID;
$JUNIT = getenv('TEST_PHP_JUNIT');
if (empty($JUNIT)) {
- $JUNIT = false;
- } elseif (!$fp = fopen($JUNIT, 'w')) {
+ $GLOBALS['JUNIT'] = false;
+ return;
+ }
+ if ($workerID) {
+ $fp = null;
+ } else if (!$fp = fopen($JUNIT, 'w')) {
error("Failed to open $JUNIT for writing.");
- } else {
- $JUNIT = array(
- 'fp' => $fp,
- 'name' => 'PHP',
- 'test_total' => 0,
- 'test_pass' => 0,
- 'test_fail' => 0,
- 'test_error' => 0,
- 'test_skip' => 0,
- 'test_warn' => 0,
- 'execution_time' => 0,
- 'suites' => array(),
- 'files' => array()
- );
}
-
- $GLOBALS['JUNIT'] = $JUNIT;
+ $GLOBALS['JUNIT'] = array(
+ 'fp' => $fp,
+ 'name' => 'PHP',
+ 'test_total' => 0,
+ 'test_pass' => 0,
+ 'test_fail' => 0,
+ 'test_error' => 0,
+ 'test_skip' => 0,
+ 'test_warn' => 0,
+ 'execution_time' => 0,
+ 'suites' => array(),
+ 'files' => array()
+ );
}
function junit_save_xml()
@@ -3544,6 +3551,7 @@ function junit_init_suite($suite_name)
'test_fail' => 0,
'test_error' => 0,
'test_skip' => 0,
+ 'test_warn' => 0,
'files' => array(),
'execution_time' => 0,
);
@@ -3567,6 +3575,35 @@ function junit_finish_timer($file_name)
unset($JUNIT['files'][$file_name]['start']);
}
+function junit_merge_results($junit)
+{
+ global $JUNIT;
+ $JUNIT['test_total'] += $junit['test_total'];
+ $JUNIT['test_pass'] += $junit['test_pass'];
+ $JUNIT['test_fail'] += $junit['test_fail'];
+ $JUNIT['test_error'] += $junit['test_error'];
+ $JUNIT['test_skip'] += $junit['test_skip'];
+ $JUNIT['test_warn'] += $junit['test_warn'];
+ $JUNIT['execution_time'] += $junit['execution_time'];
+ $JUNIT['files'] += $junit['files'];
+ foreach ($junit['suites'] as $name => $suite) {
+ if (!isset($JUNIT['suites'][$name])) {
+ $JUNIT['suites'][$name] = $suite;
+ continue;
+ }
+
+ $SUITE =& $JUNIT['suites'][$name];
+ $SUITE['test_total'] += $suite['test_total'];
+ $SUITE['test_pass'] += $suite['test_pass'];
+ $SUITE['test_fail'] += $suite['test_fail'];
+ $SUITE['test_error'] += $suite['test_error'];
+ $SUITE['test_skip'] += $suite['test_skip'];
+ $SUITE['test_warn'] += $suite['test_warn'];
+ $SUITE['execution_time'] += $suite['execution_time'];
+ $SUITE['files'] += $suite['files'];
+ }
+}
+
class RuntestsValgrind
{
protected $version = '';