From d4b4cb8bc7a8769dc6ccb9ec9abfb2c17f888832 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Fri, 15 Oct 2010 16:36:45 -0700 Subject: [PATCH] Print out debug of test when it fails. Change-Id: I9dc535a7d1ee5feeb364456ca8ff367285cdad2b BUG= TEST=Ran with with a test suite with both passing / failing tests Review URL: http://codereview.chromium.org/3814009 --- generate_test_report.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/generate_test_report.py b/generate_test_report.py index f5d32dbbea..3ad5e1755d 100755 --- a/generate_test_report.py +++ b/generate_test_report.py @@ -167,6 +167,8 @@ class ReportGenerator(object): tests = self._results.keys() tests.sort() + tests_with_errors = [] + width = self.GetTestColumnWidth() line = ''.ljust(width + 5, '-') @@ -182,6 +184,8 @@ class ReportGenerator(object): tests_pass += 1 else: color = Color.RED + tests_with_errors.append(test) + status_entry = self._color.Color(color, status_entry) print test_entry + status_entry @@ -204,6 +208,23 @@ class ReportGenerator(object): pass_str = '%d/%d (%d%%)' % (tests_pass, total_tests, percent_pass) print 'Total PASS: ' + self._color.Color(Color.BOLD, pass_str) + # Print out the client debug information for failed tests. + if self._options.print_debug: + for test in tests_with_errors: + debug_file_regex = os.path.join(self._options.strip, test, 'debug', + 'client.*.DEBUG') + for path in glob.glob(debug_file_regex): + try: + fh = open(path) + print ('\n========== DEBUG FILE %s FOR TEST %s ==============\n' % ( + path, test)) + print fh.read() + print('\n=========== END DEBUG %s FOR TEST %s ===============\n' % ( + path, test)) + fh.close() + except: + print 'Could not open %s' % path + def Run(self): """Runs report generation.""" self._CollectResults() @@ -232,6 +253,9 @@ def main(): ' [default: \'%default\']') parser.add_option('--no-strip', dest='strip', const='', action='store_const', help='Don\'t strip a prefix from test directory names') + parser.add_option('--no-debug', dest='print_debug', action='store_false', + default=True, + help='Do not print out the debug log when a test fails.') (options, args) = parser.parse_args() if not args: