From f620c88d2431b3081225ba1f175f7ca174f1f21e Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Fri, 13 Dec 2013 08:37:14 -0800 Subject: [PATCH] Avoid post test fatals from getting in the way of stats This diff should hopefully help the cronjob run better. The cronjob and my local runs were getting errors like this: The stats file for joomla is corrupt! It should only have test names and statuses in it. We were getting this because of hhvm cleanup core dumps, etc. after a test was run. Instead of printing stats in the stats file, we were printing this fatal information, which corrupted the stats file. So, I captured this fatal information and directed it to the fatals file instead. Reviewed By: @ptarjan Differential Revision: D1097602 --- hphp/test/frameworks/run.php | 53 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/hphp/test/frameworks/run.php b/hphp/test/frameworks/run.php index fec258dfc3f..f4e80c2d433 100755 --- a/hphp/test/frameworks/run.php +++ b/hphp/test/frameworks/run.php @@ -210,7 +210,8 @@ class PHPUnitPatterns { static string $hhvm_warning_pattern = "/^(HipHop|HHVM|hhvm) (Warning|Notice)/"; - static string $hhvm_fatal_pattern = "/(^(HipHop|HHVM|hhvm) Fatal)|(^hhvm)/"; + static string $hhvm_fatal_pattern = + "/(^(HipHop|HHVM|hhvm) Fatal)|(^hhvm:)|(^Core dumped: Segmentation fault)/"; static string $test_method_name_pattern = "/public function test|\@test/"; } @@ -1979,6 +1980,20 @@ class Runner { // 1) Assetic\Test\Asset\HttpAssetTest::testGetLastModified <---- print // No tests executed! <----- print $print_blanks = false; // Only print blanks after the first test is found + + // Sometimes when PHPUnit is done printing its post test information, hhvm + // fatals. This is not good, but it currently happens nonetheless. Here + // is an example: + // + // FAILURES! + // Tests: 3, Assertions: 15, Failures: 2. <--- EXPECTED LAST LINE (STATS) + // Core dumped: Segmentation fault <--- But, we can get this and below + // /home/joelm/bin/hhvm: line 1: 28417 Segmentation fault + // + // Let's separate this from the actual post test info where we are trying + // to get statistics. + $post_test_fatal = false; + do { $line = $this->getLine(); @@ -1995,17 +2010,39 @@ class Runner { continue; } $line = remove_string_from_text($line, __DIR__, ""); - $this->error_information .= $line.PHP_EOL; - if (preg_match($this->framework->getTestNamePattern(), $line) === 1) { - $print_blanks = true; - $this->error_information .= PHP_EOL. - $this->getTestRunStr($line, - "RUN TEST FILE: "). - PHP_EOL.PHP_EOL; + if ($this->checkForFatals($line)) { + // Only print header the first time we arrive here + if (!$post_test_fatal) { + $this->fatal_information .= "POST-TEST FATAL FOR ". + $this->name.PHP_EOL; + $this->fatal_information .= PHP_EOL. + $this->getTestRunStr("", + "RUN TEST FILE: "). + PHP_EOL; + $post_test_fatal = true; + } + $this->fatal_information .= $line.PHP_EOL; + continue; + } + if (!$post_test_fatal) { + $this->error_information .= $line.PHP_EOL; + if (preg_match($this->framework->getTestNamePattern(), $line) === 1) { + $print_blanks = true; + $this->error_information .= PHP_EOL. + $this->getTestRunStr($line, + "RUN TEST FILE: "). + PHP_EOL.PHP_EOL; + } } } } while ($line !== null); + // Add a newline to the fatal file if we had a post-test fatal for better + // visual + if ($post_test_fatal) { + $this->fatal_information .= PHP_EOL; + } + // The last non-null line in the error file would have been the real stat // information for pass percentage purposes. Take that out of the error // string and put in the stat information string instead. Other stat like -- 2.11.4.GIT