cvs: pear-core /PEAR RunTest.php
| From: | Helgi �ormar �orbj�rnsson | Date: | Tue, 24 Jun 2008 18:39:04 +0000 |
| Subject: | cvs: pear-core /PEAR RunTest.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-7607@lists.php.net to get a copy of this message | ||
dufuz Tue Jun 24 18:39:04 2008 UTC
Modified files:
/pear-core/PEAR RunTest.php
Log:
Fix Bug #13958: When a phpt tests exit() or die() xdebug coverage is not generated, patch by izi
(David Jean Louis)
http://cvs.php.net/viewvc.cgi/pear-core/PEAR/RunTest.php?r1=1.69&r2=1.70&diff_format=u
Index: pear-core/PEAR/RunTest.php
diff -u pear-core/PEAR/RunTest.php:1.69 pear-core/PEAR/RunTest.php:1.70
--- pear-core/PEAR/RunTest.php:1.69 Sat Jun 14 12:04:26 2008
+++ pear-core/PEAR/RunTest.php Tue Jun 24 18:39:04 2008
@@ -16,7 +16,7 @@
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2008 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: RunTest.php,v 1.69 2008/06/14 12:04:26 dufuz Exp $
+ * @version CVS: $Id: RunTest.php,v 1.70 2008/06/24 18:39:04 dufuz Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.3.3
*/
@@ -376,28 +376,31 @@
// 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);';
+ if (!function_exists('file_put_contents')) {
+ $text .= "\n" . ' $fh = fopen(\'' . $xdebug_file .
'\', "wb");' .
+ "\n" . ' if ($fh !== false) {' .
+ "\n" . ' fwrite($fh, $xdebug);' .
+ "\n" . ' fclose($fh);' .
+ "\n" . ' }';
+ } else {
+ $text .= "\n" . ' file_put_contents(\'' . $xdebug_file
. '\', $xdebug);';
+ }
+
+ $text .= "\n" . 'xdebug_stop_code_coverage();' .
+ "\n" . '} // end coverage_shutdown()' .
+ "\n" .
'register_shutdown_function("coverage_shutdown");';
+ $text .= "\n" . 'xdebug_start_code_coverage(XDEBUG_CC_UNUSED |
XDEBUG_CC_DEAD_CODE);' . "\n";
+
$len_f = 5;
if (substr($section_text['FILE'], 0, 5) != '<?php'
&& substr($section_text['FILE'], 0, 2) == '<?') {
$len_f = 2;
}
-
- $text = '<?php' . "\n" .
'xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);' . "\n";
- $new = substr($section_text['FILE'], $len_f,
strlen($section_text['FILE']));
- $text .= substr($new, 0, strrpos($new, '?>'));
- $xdebug_file = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'xdebug';
- $text .= "\n" .
- "\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) {' .
- "\n" . ' fwrite($fh, $xdebug);' .
- "\n" . ' fclose($fh);' .
- "\n" . '}';
- } else {
- $text .= "\n" . 'file_put_contents(\'' . $xdebug_file .
'\', $xdebug);';
- }
- $text .= "\n" . 'xdebug_stop_code_coverage();' . "\n" .
'?>';
+ $text .= substr($section_text['FILE'], $len_f,
strlen($section_text['FILE']));
$this->save_text($temp_file, $text);
} else {