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

Unified Diff: tools/testrunner/local/progress.py

Issue 1163373005: Revert of [test] Refactoring - Use subject/observer pattern for progress indicators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « tools/testrunner/local/execution.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testrunner/local/progress.py
diff --git a/tools/testrunner/local/progress.py b/tools/testrunner/local/progress.py
index 469d64bc00a2344efc2589a7c15ab89824a1be93..a9519e926d7552418e56aeaf2a7fb764e86bdfbb 100644
--- a/tools/testrunner/local/progress.py
+++ b/tools/testrunner/local/progress.py
@@ -26,7 +26,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from functools import wraps
import json
import os
import sys
@@ -55,9 +54,6 @@
def __init__(self):
self.runner = None
- def SetRunner(self, runner):
- self.runner = runner
-
def Starting(self):
pass
@@ -82,30 +78,6 @@
'label': test.GetLabel(),
'negative': negative_marker
}
-
-
-class IndicatorNotifier(object):
- """Holds a list of progress indicators and notifies them all on events."""
- def __init__(self):
- self.indicators = []
-
- def Register(self, indicator):
- self.indicators.append(indicator)
-
-
-# Forge all generic event-dispatching methods in IndicatorNotifier, which are
-# part of the ProgressIndicator interface.
-for func_name in ProgressIndicator.__dict__:
- func = getattr(ProgressIndicator, func_name)
- if callable(func) and not func.__name__.startswith('_'):
- def wrap_functor(f):
- @wraps(f)
- def functor(self, *args, **kwargs):
- """Generic event dispatcher."""
- for indicator in self.indicators:
- getattr(indicator, f.__name__)(*args, **kwargs)
- return functor
- setattr(IndicatorNotifier, func_name, wrap_functor(func))
class SimpleProgressIndicator(ProgressIndicator):
@@ -279,19 +251,29 @@
class JUnitTestProgressIndicator(ProgressIndicator):
- def __init__(self, junitout, junittestsuite):
+ def __init__(self, progress_indicator, junitout, junittestsuite):
+ self.progress_indicator = progress_indicator
self.outputter = junit_output.JUnitTestOutput(junittestsuite)
if junitout:
self.outfile = open(junitout, "w")
else:
self.outfile = sys.stdout
- def Done(self):
+ def Starting(self):
+ self.progress_indicator.runner = self.runner
+ self.progress_indicator.Starting()
+
+ def Done(self):
+ self.progress_indicator.Done()
self.outputter.FinishAndWrite(self.outfile)
if self.outfile != sys.stdout:
self.outfile.close()
- def HasRun(self, test, has_unexpected_output):
+ def AboutToRun(self, test):
+ self.progress_indicator.AboutToRun(test)
+
+ def HasRun(self, test, has_unexpected_output):
+ self.progress_indicator.HasRun(test, has_unexpected_output)
fail_text = ""
if has_unexpected_output:
stdout = test.output.stdout.strip()
@@ -310,17 +292,25 @@
test.duration,
fail_text)
+ def Heartbeat(self):
+ self.progress_indicator.Heartbeat()
class JsonTestProgressIndicator(ProgressIndicator):
- def __init__(self, json_test_results, arch, mode):
+ def __init__(self, progress_indicator, json_test_results, arch, mode):
+ self.progress_indicator = progress_indicator
self.json_test_results = json_test_results
self.arch = arch
self.mode = mode
self.results = []
self.tests = []
- def Done(self):
+ def Starting(self):
+ self.progress_indicator.runner = self.runner
+ self.progress_indicator.Starting()
+
+ def Done(self):
+ self.progress_indicator.Done()
complete_results = []
if os.path.exists(self.json_test_results):
with open(self.json_test_results, "r") as f:
@@ -350,7 +340,11 @@
with open(self.json_test_results, "w") as f:
f.write(json.dumps(complete_results))
- def HasRun(self, test, has_unexpected_output):
+ def AboutToRun(self, test):
+ self.progress_indicator.AboutToRun(test)
+
+ def HasRun(self, test, has_unexpected_output):
+ self.progress_indicator.HasRun(test, has_unexpected_output)
# Buffer all tests for sorting the durations in the end.
self.tests.append(test)
if not has_unexpected_output:
@@ -372,6 +366,9 @@
"duration": test.duration,
})
+ def Heartbeat(self):
+ self.progress_indicator.Heartbeat()
+
PROGRESS_INDICATORS = {
'verbose': VerboseProgressIndicator,
« no previous file with comments | « tools/testrunner/local/execution.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698