commit d5ad53925a487348b171a80e4e3f71a0dadc3ef5
Author: Damien Tournoud <damien@tournoud.net>
Date:   Fri Oct 10 02:17:24 2008 +0200

    #243532: Catch notices, warnings, errors and fatal errors from the tested side.
    
    Requires #304924.

diff --git includes/common.inc includes/common.inc
index 326d6a0..cc921f2 100644
--- includes/common.inc
+++ includes/common.inc
@@ -677,6 +677,19 @@ function _drupal_log_error($type, $message, $backtrace, $fatal) {
     drupal_maintenance_theme();
   }
 
+  // When running inside the testing framework, we relay the errors
+  // to the tested site by the way of HTTP headers.
+  if (preg_match("/^simpletest\d+/", $GLOBALS['db_prefix']) && !headers_sent()) {
+    static $number = 0;
+    $assertion = array(
+      $message,
+      $type,
+      $caller
+    );
+    header('X-Drupal-Assertion-' . $number . ': ' . rawurlencode(serialize($assertion)));
+    $number++;
+  }
+
   // Force display of error messages in update.php.
   if (variable_get('error_level', 1) == 1 || (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update')) {
     drupal_set_message(t('@type: %message in %function (line %line of %file).', array('@type' => $type, '%message' => $message, '%function' => $caller['function'], '%line' => $caller['line'], '%file' => $caller['file'])), 'error');
diff --git modules/simpletest/drupal_web_test_case.php modules/simpletest/drupal_web_test_case.php
index 988f159..ee9110a 100644
--- modules/simpletest/drupal_web_test_case.php
+++ modules/simpletest/drupal_web_test_case.php
@@ -799,6 +799,7 @@ class DrupalWebTestCase {
         CURLOPT_RETURNTRANSFER => TRUE,
         CURLOPT_SSL_VERIFYPEER => FALSE,  // Required to make the tests run on https://
         CURLOPT_SSL_VERIFYHOST => FALSE,  // Required to make the tests run on https://
+        CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
       );
       if (preg_match('/simpletest\d+/', $db_prefix)) {
         $curl_options[CURLOPT_USERAGENT] = $db_prefix;
@@ -831,6 +832,21 @@ class DrupalWebTestCase {
   }
 
   /**
+   * Reads headers and registers errors received from the tested site.
+   *
+   * @see _drupal_log_error().
+   *
+   * @param $ch the cURL handler.
+   * @param $header a header.
+   */
+  protected function curlHeaderCallback($ch, $header) {
+    if (preg_match('/^X-Drupal-Assertion-[0-9]+: (.*)$/', $header, $matches)) {
+      call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1])));
+    }
+    return strlen($header);
+  }
+
+  /**
    * Close the cURL handler and unset the handler.
    */
   protected function curlClose() {
