Commit a8b8a440 authored by Tamer Tas's avatar Tamer Tas Committed by Commit Bot

[testrunner] remove the up-front test counter

Moving to a lazy test loading approach makes counting the total number of tests
non-trivial.

For CI runs, we output the total number of tests after the run.
For users, progress indicator signals the status of the run.

R=machenbach@chromium.org
CC=​yangguo@chromium.org,sergiyb@chromium.org

Bug: v8:8174
Change-Id: I0731964515aac60a3629acee6c7243433a2b4e04
Reviewed-on: https://chromium-review.googlesource.com/c/1420677
Commit-Queue: Tamer Tas <tmrts@chromium.org>
Reviewed-by: 's avatarSergiy Belozorov <sergiyb@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58944}
parent 044daa54
......@@ -20,7 +20,7 @@ from testrunner.testproc.execution import ExecutionProc
from testrunner.testproc.expectation import ForgiveTimeoutProc
from testrunner.testproc.filter import StatusFileFilterProc, NameFilterProc
from testrunner.testproc.loader import LoadProc
from testrunner.testproc.progress import ResultsTracker, TestsCounter
from testrunner.testproc.progress import ResultsTracker
from testrunner.utils import random_utils
......
......@@ -18,7 +18,7 @@ from testrunner.objects import predictable
from testrunner.testproc.execution import ExecutionProc
from testrunner.testproc.filter import StatusFileFilterProc, NameFilterProc
from testrunner.testproc.loader import LoadProc
from testrunner.testproc.progress import ResultsTracker, TestsCounter
from testrunner.testproc.progress import ResultsTracker
from testrunner.testproc.seed import SeedProc
from testrunner.testproc.variant import VariantProc
from testrunner.utils import random_utils
......@@ -282,7 +282,6 @@ class StandardTestRunner(base_runner.BaseTestRunner):
print '>>> Running with test processors'
loader = LoadProc()
tests_counter = TestsCounter()
results = self._create_result_tracker(options)
indicators = self._create_progress_indicators(options)
......@@ -297,7 +296,6 @@ class StandardTestRunner(base_runner.BaseTestRunner):
NameFilterProc(args) if args else None,
StatusFileFilterProc(options.slow_tests, options.pass_fail_tests),
self._create_shard_proc(options),
tests_counter,
VariantProc(self._variants),
StatusFileFilterProc(options.slow_tests, options.pass_fail_tests),
self._create_predictable_filter(),
......@@ -314,9 +312,6 @@ class StandardTestRunner(base_runner.BaseTestRunner):
loader.load_tests(tests)
print '>>> Running %d base tests' % tests_counter.total
tests_counter.remove_from_chain()
# This starts up worker processes and blocks until all tests are
# processed.
execproc.run()
......
......@@ -22,15 +22,6 @@ def print_failure_header(test):
}
class TestsCounter(base.TestProcObserver):
def __init__(self):
super(TestsCounter, self).__init__()
self.total = 0
def _on_next_test(self, test):
self.total += 1
class ResultsTracker(base.TestProcObserver):
"""Tracks number of results and stops to run tests if max_failures reached."""
def __init__(self, max_failures):
......@@ -66,10 +57,6 @@ class SimpleProgressIndicator(ProgressIndicator):
self._requirement = base.DROP_PASS_OUTPUT
self._failed = []
self._total = 0
def _on_next_test(self, test):
self._total += 1
def _on_result_for(self, test, result):
# TODO(majeski): Support for dummy/grouped results
......@@ -170,13 +157,9 @@ class CompactProgressIndicator(ProgressIndicator):
self._last_status_length = 0
self._start_time = time.time()
self._total = 0
self._passed = 0
self._failed = 0
def _on_next_test(self, test):
self._total += 1
def _on_result_for(self, test, result):
# TODO(majeski): Support for dummy/grouped results
if result.has_unexpected_output:
......@@ -210,13 +193,8 @@ class CompactProgressIndicator(ProgressIndicator):
def _print_progress(self, name):
self._clear_line(self._last_status_length)
elapsed = time.time() - self._start_time
if not self._total:
progress = 0
else:
progress = (self._passed + self._failed) * 100 // self._total
status = self._templates['status_line'] % {
'passed': self._passed,
'progress': progress,
'failed': self._failed,
'test': name,
'mins': int(elapsed) / 60,
......@@ -241,7 +219,6 @@ class ColorProgressIndicator(CompactProgressIndicator):
def __init__(self):
templates = {
'status_line': ("[%(mins)02i:%(secs)02i|"
"\033[34m%%%(progress) 4d\033[0m|"
"\033[32m+%(passed) 4d\033[0m|"
"\033[31m-%(failed) 4d\033[0m]: %(test)s"),
'stdout': "\033[1m%s\033[0m",
......@@ -256,7 +233,7 @@ class ColorProgressIndicator(CompactProgressIndicator):
class MonochromeProgressIndicator(CompactProgressIndicator):
def __init__(self):
templates = {
'status_line': ("[%(mins)02i:%(secs)02i|%%%(progress) 4d|"
'status_line': ("[%(mins)02i:%(secs)02i|"
"+%(passed) 4d|-%(failed) 4d]: %(test)s"),
'stdout': '%s',
'stderr': '%s',
......
......@@ -671,11 +671,10 @@ class SystemTest(unittest.TestCase):
infra_staging=infra_staging,
)
if name == 'color':
expected = ('\033[34m% 100\033[0m|'
'\033[32m+ 1\033[0m|'
expected = ('\033[32m+ 1\033[0m|'
'\033[31m- 1\033[0m]: Done')
else:
expected = '% 100|+ 1|- 1]: Done'
expected = '+ 1|- 1]: Done'
self.assertIn(expected, result.stdout)
self.assertIn('sweet/cherries', result.stdout)
self.assertIn('sweet/bananas', result.stdout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment