com php-src: Rework junit output: run-tests.php
| From: | Anatol Belski | Date: | Sat, 02 Dec 2017 01:18:43 +0000 |
| Subject: | com php-src: Rework junit output: run-tests.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100468@lists.php.net to get a copy of this message | ||
Commit: 7a96ab7bb8818ca41d634cdfd47c9b0483f84c91
Author: Anatol Belski <ab@php.net> Sat, 2 Dec 2017 02:18:43 +0100
Parents: 0b44af5b1da049a66d44b1aa5a1a6a198026cd94
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7a96ab7bb8818ca41d634cdfd47c9b0483f84c91
Log:
Rework junit output
- testcase classname attribute is closest to put the filename
- if tests run from php checkout, don't include the full path
- remove filename from the testcase description, as it's included into
classname
Changed paths:
M run-tests.php
Diff:
diff --git a/run-tests.php b/run-tests.php
index bb85938..75c4d6e 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -2748,7 +2748,7 @@ function junit_init() {
} else {
$JUNIT = array(
'fp' => $fp,
- 'name' => 'php-src',
+ 'name' => 'PHP',
'test_total' => 0,
'test_pass' => 0,
'test_fail' => 0,
@@ -2768,7 +2768,7 @@ function junit_save_xml() {
global $JUNIT;
if (!junit_enabled()) return;
- $xml = '<?xml version="1.0" encoding="UTF-8"?>'. PHP_EOL .
+ $xml = '<' . '?' . 'xml version="1.0"
encoding="UTF-8"' . '?' . '>'. PHP_EOL .
'<testsuites>' . PHP_EOL;
$xml .= junit_get_suite_xml();
$xml .= '</testsuites>';
@@ -2833,8 +2833,8 @@ function junit_mark_test_as($type, $file_name, $test_name, $time = null,
$messag
}, $escaped_details);
$escaped_message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
- $escaped_test_name = basename($file_name) . ' - ' . htmlspecialchars($test_name,
ENT_QUOTES);
- $JUNIT['files'][$file_name]['xml'] = "<testcase
classname='$suite' name='$escaped_test_name' time='$time'>\n";
+ $escaped_test_name = htmlspecialchars($test_name, ENT_QUOTES);
+ $JUNIT['files'][$file_name]['xml'] = "<testcase
classname='" . $suite . "." . basename($file_name) . "'
name='$escaped_test_name' time='$time'>\n";
if (is_array($type)) {
$output_type = $type[0] . 'ED';
@@ -2904,7 +2904,33 @@ function junit_get_suitename_for($file_name) {
function junit_path_to_classname($file_name) {
global $JUNIT;
- return $JUNIT['name'] . '.' . str_replace(DIRECTORY_SEPARATOR,
'.', $file_name);
+
+ $ret = $JUNIT['name'];
+ $_tmp = array();
+
+ // lookup whether we're in the PHP source checkout
+ $max = 5;
+ if (is_file($file_name)) {
+ $dir = dirname(realpath($file_name));
+ } else {
+ $dir = realpath($file_name);
+ }
+ do {
+ array_unshift($_tmp, basename($dir));
+ $chk = $dir . DIRECTORY_SEPARATOR . "main" . DIRECTORY_SEPARATOR .
"php_version.h";
+ $dir = dirname($dir);
+ } while (!file_exists($chk) && --$max > 0);
+ if (file_exists($chk)) {
+ if ($max) {
+ array_shift($_tmp);
+ }
+ foreach ($_tmp as $p) {
+ $ret = $ret . "." . preg_replace(",[^a-z0-9]+,i", ".", $p);
+ }
+ return $ret;
+ }
+
+ return $JUNIT['name'] . '.' . str_replace(array(DIRECTORY_SEPARATOR,
'-'), '.', $file_name);
}
function junit_init_suite($suite_name) {