Verified Commit b857b099 authored by Dave Long's avatar Dave Long
Browse files

ci: #3547746 run-tests.sh reports x2 duration for failed tests

By: mondrake
(cherry picked from commit fc5e3375)
parent af48404e
Loading
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -228,9 +228,7 @@ public function execute(
    // Store output from our test run.
    $output = [];
    $error = [];
    $start = microtime(TRUE);
    $this->runCommand($test_class_name, $log_junit_file_path, $status, $output, $error, $colors);
    $time = microtime(TRUE) - $start;

    if (file_exists($log_junit_file_path)) {
      $results = JUnitConverter::xmlToRows($test_run->id(), $log_junit_file_path);
@@ -257,7 +255,7 @@ public function execute(
        'function' => '*** Process execution output ***',
        'line' => '0',
        'file' => $log_junit_file_path,
        'time' => $time,
        'time' => 0,
      ];
    }

+17 −7
Original line number Diff line number Diff line
@@ -1312,12 +1312,12 @@ function simpletest_script_reporter_display_summary($class, $results, $duration
    $summary[] = 'exit code ' . $results['#exit_code'];
  }

  if ($results['#time']) {
    $time = sprintf('%8.3fs', $results['#time']);
  }
  else {
  // The key $results['#time'] holds the sum of the tests execution times,
  // without taking into account the process spawning time and the setup
  // times of the tests themselves. So for reporting to be consistent with
  // PHPUnit CLI reported execution time, we report here the overall time of
  // execution of the spawned process.
  $time = sprintf('%8.3fs', $duration);
  }

  $output = vsprintf('%s %s %s', [$time, trim_with_ellipsis($class, 70, STR_PAD_LEFT), implode(', ', $summary)]);
  $status = ($results['#fail'] || $results['#cli_fail'] || $results['#exception'] || $results['#error'] ? 'fail' : 'pass');
@@ -1463,7 +1463,17 @@ function simpletest_script_reporter_display_results(TestRunResultsStorageInterfa
function simpletest_script_format_result($result): void {
  global $args, $results_map, $color;

  $summary = sprintf("%-9.9s %9.3fs %s\n", $results_map[$result->status], $result->time, trim_with_ellipsis($result->function, 80, STR_PAD_LEFT));
  if ($result->time == 0) {
    $duration = "          ";
  }
  elseif ($result->time < 0.001) {
    $duration = "     <1 ms";
  }
  else {
    $duration = sprintf("%9.3fs", $result->time);
  }

  $summary = sprintf("%-9.9s %s %s\n", $results_map[$result->status], $duration, trim_with_ellipsis($result->function, 80, STR_PAD_LEFT));

  simpletest_script_print($summary, simpletest_script_color_code($result->status));