[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: Sergiy Belozorov <sergiyb@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58944}
This commit is contained in:
Tamer Tas 2019-01-21 08:00:32 +01:00 committed by Commit Bot
parent 044daa5488
commit a8b8a4408b
4 changed files with 5 additions and 34 deletions

View File

@ -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

View File

@ -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()

View File

@ -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',

View File

@ -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)