svn: /pear/pear-core/trunk/PEAR/ RunTest.php
| From: | Sebastian Bergmann | Date: | Wed, 07 Apr 2010 15:09:33 +0000 |
| Subject: | svn: /pear/pear-core/trunk/PEAR/ RunTest.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-9365@lists.php.net to get a copy of this message | ||
sebastian Wed, 07 Apr 2010 15:09:33 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=297621
Log:
Fix 17292.
Changed paths:
U pear/pear-core/trunk/PEAR/RunTest.php
Modified: pear/pear-core/trunk/PEAR/RunTest.php
===================================================================
--- pear/pear-core/trunk/PEAR/RunTest.php 2010-04-07 15:06:12 UTC (rev 297620)
+++ pear/pear-core/trunk/PEAR/RunTest.php 2010-04-07 15:09:33 UTC (rev 297621)
@@ -370,9 +370,8 @@
// We've satisfied the preconditions - run the test!
if (isset($this->_options['coverage']) && $this->xdebug_loaded) {
$xdebug_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'xdebug';
- $text = '<?php';
- $text .= "\n" . 'function coverage_shutdown() {' .
- "\n" . ' $xdebug = var_export(xdebug_get_code_coverage(),
true);';
+ $text = "\n" . 'function coverage_shutdown() {' .
+ "\n" . ' $xdebug = var_export(xdebug_get_code_coverage(),
true);';
if (!function_exists('file_put_contents')) {
$text .= "\n" . ' $fh = fopen(\'' . $xdebug_file .
'\', "wb");' .
"\n" . ' if ($fh !== false) {' .
@@ -388,9 +387,26 @@
"\n" .
'register_shutdown_function("coverage_shutdown");';
$text .= "\n" . 'xdebug_start_code_coverage(XDEBUG_CC_UNUSED |
XDEBUG_CC_DEAD_CODE);' . "\n?>";
- $text .= $section_text['FILE'];
+ // Workaround for http://pear.php.net/bugs/bug.php?id=17292
+ $lines = explode("\n", $section_text['FILE']);
+ $numLines = count($lines);
+ $namespace = '';
- $this->save_text($temp_file, $text);
+ for ($i = 0; $i < $numLines; $i++) {
+ $lines[$i] = trim($lines[$i]);
+
+ if ($lines[$i] == '<?' || $lines[$i] == '<?php') {
+ unset($lines[$i]);
+ }
+
+ if (substr($lines[$i], 0, 9) == 'namespace') {
+ $namespace = $lines[$i] . "\n";
+ unset($lines[$i]);
+ break;
+ }
+ }
+
+ $this->save_text($temp_file, "<?php\n" . $namespace .
join("\n", $lines));
} else {
$this->save_text($temp_file, $section_text['FILE']);
}
@@ -943,4 +959,4 @@
}
}
}
-}
\ No newline at end of file
+}