Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: tools/telemetry/telemetry/page/gtest_test_results.py

Issue 327583002: Move results related stuff to telemetry/results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change the directory name from test_results to results Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/page/gtest_test_results.py
diff --git a/tools/telemetry/telemetry/page/gtest_test_results.py b/tools/telemetry/telemetry/page/gtest_test_results.py
deleted file mode 100644
index 2bed68449eefcd402a61c96bb13d9f156a3cf97f..0000000000000000000000000000000000000000
--- a/tools/telemetry/telemetry/page/gtest_test_results.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright 2013 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import logging
-import sys
-import time
-import unittest
-
-from telemetry.page import page_test_results
-
-class GTestTestResults(page_test_results.PageTestResults):
- def __init__(self, output_stream):
- super(GTestTestResults, self).__init__(output_stream)
- self._timestamp = None
-
- def _GetMs(self):
- return (time.time() - self._timestamp) * 1000
-
- @property
- def num_errors(self):
- return len(self.errors) + len(self.failures)
-
- @staticmethod
- def _formatTestname(test):
- if isinstance(test, unittest.TestCase):
- chunks = test.id().split('.')[2:]
- return '.'.join(chunks)
- else:
- return str(test)
-
- def _emitFailure(self, test, err):
- print >> self._output_stream, self._exc_info_to_string(err, test)
- test_name = GTestTestResults._formatTestname(test)
- print >> self._output_stream, '[ FAILED ]', test_name, (
- '(%0.f ms)' % self._GetMs())
- sys.stdout.flush()
-
- def addError(self, test, err):
- super(GTestTestResults, self).addError(test, err)
- self._emitFailure(test, err)
-
- def addFailure(self, test, err):
- super(GTestTestResults, self).addFailure(test, err)
- self._emitFailure(test, err)
-
- def startTest(self, test):
- super(GTestTestResults, self).startTest(test)
- print >> self._output_stream, '[ RUN ]', (
- GTestTestResults._formatTestname(test))
- sys.stdout.flush()
- self._timestamp = time.time()
-
- def addSuccess(self, test):
- super(GTestTestResults, self).addSuccess(test)
- test_name = GTestTestResults._formatTestname(test)
- print >> self._output_stream, '[ OK ]', test_name, (
- '(%0.f ms)' % self._GetMs())
- sys.stdout.flush()
-
- def addSkip(self, test, reason):
- super(GTestTestResults, self).addSkip(test, reason)
- test_name = GTestTestResults._formatTestname(test)
- logging.warning('===== SKIPPING TEST %s: %s =====', test_name, reason)
- if self._timestamp == None:
- self._timestamp = time.time()
- print >> self._output_stream, '[ OK ]', test_name, (
- '(%0.f ms)' % self._GetMs())
- sys.stdout.flush()
-
- def PrintSummary(self):
- unit = 'test' if len(self.successes) == 1 else 'tests'
- print >> self._output_stream, '[ PASSED ]', (
- '%d %s.' % (len(self.successes), unit))
- if self.errors or self.failures:
- all_errors = self.errors[:]
- all_errors.extend(self.failures)
- unit = 'test' if len(all_errors) == 1 else 'tests'
- print >> self._output_stream, '[ FAILED ]', (
- '%d %s, listed below:' % (len(all_errors), unit))
- for test, _ in all_errors:
- print >> self._output_stream, '[ FAILED ] ', (
- GTestTestResults._formatTestname(test))
- if not self.wasSuccessful():
- print >> self._output_stream
- count = len(self.errors) + len(self.failures)
- unit = 'TEST' if count == 1 else 'TESTS'
- print >> self._output_stream, '%d FAILED %s' % (count, unit)
- print >> self._output_stream
- sys.stdout.flush()

Powered by Google App Engine
This is Rietveld 408576698