svn: /pear/pear-core/tags/PEAR-1.9.2/PEAR/ RunTest.php

[email protected] (Helgi Þormar Þorbjörnsson) Fri, 25 Feb 2011 23:20:24 +0000
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
dufuz                                    Fri, 25 Feb 2011 23:20:24 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=308689

Log:
Fixed Bug #18001: PEAR/RunTest coverage fails [dufuz]

# Backported from trunk

Bug: http://pear.php.net/bugs/18001 (unknown) 
      
Changed paths:
    U   pear/pear-core/tags/PEAR-1.9.2/PEAR/RunTest.php

Modified: pear/pear-core/tags/PEAR-1.9.2/PEAR/RunTest.php
===================================================================
--- pear/pear-core/tags/PEAR-1.9.2/PEAR/RunTest.php	2011-02-25 23:18:06 UTC (rev 308688)
+++ pear/pear-core/tags/PEAR-1.9.2/PEAR/RunTest.php	2011-02-25 23:20:24 UTC (rev 308689)
@@ -282,7 +282,7 @@
         if (empty($this->_options['cgi'])) {
             // try to see if php-cgi is in the path
             $res = $this->system_with_timeout('php-cgi -v');
-            if (false !== $res && !(is_array($res) && $res === array(127, ''))) {
+            if (false !== $res && !(is_array($res) && in_array($res[0], array(-1, 127)))) {
                 $this->_options['cgi'] = 'php-cgi';
             }
         }
@@ -385,7 +385,7 @@
             $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?>";
+            $text .= "\n" . 'xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);' . "\n";

             // Workaround for http://pear.php.net/bugs/bug.php?id=17292
             $lines     = explode("\n", $section_text['FILE']);
@@ -399,14 +399,14 @@
                     unset($lines[$i]);
                 }

-                if (substr($lines[$i], 0, 9) == 'namespace') {
+                if (isset($lines[$i]) && 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));
+            $this->save_text($temp_file, "<?php\n" . $namespace . "\n" . $text  . "\n" . implode("\n", $lines));
         } else {
             $this->save_text($temp_file, $section_text['FILE']);
         }