com php-src: Fix junit XML format: run-tests.php
| From: | Anatol Belski | Date: | Sat, 02 Dec 2017 09:40:43 +0000 |
| Subject: | com php-src: Fix junit XML format: run-tests.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100469@lists.php.net to get a copy of this message | ||
Commit: 65c209d0c2d56346740aecbf24647a17ae23596d
Author: Anatol Belski <ab@php.net> Sat, 2 Dec 2017 10:40:43 +0100
Parents: 7a96ab7bb8818ca41d634cdfd47c9b0483f84c91
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=65c209d0c2d56346740aecbf24647a17ae23596d
Log:
Fix junit XML format
The junit XML format is purely documented, some existings spec like
http://llg.cubic.org/docs/junit/ also provide an XSD.
The testsuite
tag included into itself doesn't seems to be correct, instead only a
flat list is included into "testsuites" tag.
Changed paths:
M run-tests.php
Diff:
diff --git a/run-tests.php b/run-tests.php
index 75c4d6e..aa75244 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -2768,8 +2768,12 @@ function junit_save_xml() {
global $JUNIT;
if (!junit_enabled()) return;
- $xml = '<' . '?' . 'xml version="1.0"
encoding="UTF-8"' . '?' . '>'. PHP_EOL .
- '<testsuites>' . PHP_EOL;
+ $xml = '<' .. '?' . 'xml version="1.0"
encoding="UTF-8"' . '?' . '>'. PHP_EOL;
+ $xml .= sprintf(
+ '<testsuites name="%s" tests="%s" failures="%d"
errors="%d" skip="%d" time="%s">' . PHP_EOL,
+ $JUNIT['name'], $JUNIT['test_total'], $JUNIT['test_fail'],
$JUNIT['test_error'], $JUNIT['test_skip'],
+ $JUNIT['execution_time']
+ );
$xml .= junit_get_suite_xml();
$xml .= '</testsuites>';
fwrite($JUNIT['fp'], $xml);
@@ -2778,26 +2782,23 @@ function junit_save_xml() {
function junit_get_suite_xml($suite_name = '') {
global $JUNIT;
- $suite = $suite_name ? $JUNIT['suites'][$suite_name] : $JUNIT;
-
- $result = sprintf(
- '<testsuite name="%s" tests="%s" failures="%d"
errors="%d" skip="%d" time="%s">' . PHP_EOL,
- $suite['name'], $suite['test_total'], $suite['test_fail'],
$suite['test_error'], $suite['test_skip'],
- $suite['execution_time']
- );
+ $result = "";
- foreach($suite['suites'] as $sub_suite) {
- $result .= junit_get_suite_xml($sub_suite['name']);
- }
+ foreach ($JUNIT['suites'] as $suite_name => $suite) {
+ $result .= sprintf(
+ '<testsuite name="%s" tests="%s" failures="%d"
errors="%d" skip="%d" time="%s">' . PHP_EOL,
+ $suite['name'], $suite['test_total'], $suite['test_fail'],
$suite['test_error'], $suite['test_skip'],
+ $suite['execution_time']
+ );
- // Output files only in subsuites
- if (!empty($suite_name)) {
- foreach($suite['files'] as $file) {
- $result .= $JUNIT['files'][$file]['xml'];
+ if (!empty($suite_name)) {
+ foreach($suite['files'] as $file) {
+ $result .= $JUNIT['files'][$file]['xml'];
+ }
}
- }
- $result .= '</testsuite>' . PHP_EOL;
+ $result .= '</testsuite>' . PHP_EOL;
+ }
return $result;
}