diff options
author | Anatol Belski <ab@php.net> | 2017-12-02 10:40:43 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-12-02 10:40:43 +0100 |
commit | 65c209d0c2d56346740aecbf24647a17ae23596d (patch) | |
tree | b8733b9a47993131223a80875ff4b3782280cd60 /run-tests.php | |
parent | 7a96ab7bb8818ca41d634cdfd47c9b0483f84c91 (diff) | |
download | php-git-65c209d0c2d56346740aecbf24647a17ae23596d.tar.gz |
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.
Diffstat (limited to 'run-tests.php')
-rwxr-xr-x | run-tests.php | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/run-tests.php b/run-tests.php index 75c4d6e50d..aa75244b74 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; } |