summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2015-09-22 00:15:50 +0000
committerTodd Fiala <todd.fiala@gmail.com>2015-09-22 00:15:50 +0000
commitde9a44e3e9f29951c7e287b8db4f5639a42f4005 (patch)
tree276ef88edf61131abe66f14646566f9d1f789933
parent5d9a8cbb68e7e6849af61f44352d962c90ecf1cb (diff)
downloadbcm5719-llvm-de9a44e3e9f29951c7e287b8db4f5639a42f4005.tar.gz
bcm5719-llvm-de9a44e3e9f29951c7e287b8db4f5639a42f4005.zip
test framework: parallel test runner sends terminate to formatter before printing to stdout
The parallel test runner now sends the terminate event to the formatter (if there is one) after the parallel test runs but before dumping anything to stdout/stderr at the end of the run. This allows the existing stdout/stderr summary reporting to co-exist nicely with a formatter like the test_results.Curses that otherwise clobbers the screen. llvm-svn: 248228
-rwxr-xr-xlldb/test/dosep.py5
-rwxr-xr-xlldb/test/dotest.py3
-rw-r--r--lldb/test/test_results.py19
3 files changed, 23 insertions, 4 deletions
diff --git a/lldb/test/dosep.py b/lldb/test/dosep.py
index d666fdbe2df..4af748d78f5 100755
--- a/lldb/test/dosep.py
+++ b/lldb/test/dosep.py
@@ -1231,6 +1231,11 @@ def main(print_details_on_success, num_threads, test_subdir,
(timed_out, passed, failed, unexpected_successes, pass_count,
fail_count) = summary_results
+ # The results formatter - if present - is done now. Tell it to
+ # terminate.
+ if results_formatter is not None:
+ results_formatter.send_terminate_as_needed()
+
timed_out = set(timed_out)
num_test_files = len(passed) + len(failed)
num_test_cases = pass_count + fail_count
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py
index cd59f44fbcd..9bcdc829196 100755
--- a/lldb/test/dotest.py
+++ b/lldb/test/dotest.py
@@ -1030,8 +1030,7 @@ def setupTestResults():
# Tell the formatter to write out anything it may have
# been saving until the very end (e.g. xUnit results
# can't complete its output until this point).
- terminate_event = EventBuilder.bare_event("terminate")
- results_formatter_object.handle_event(terminate_event)
+ results_formatter_object.send_terminate_as_needed()
# And now close out the output file-like object.
if cleanup_func is not None:
diff --git a/lldb/test/test_results.py b/lldb/test/test_results.py
index 1aa175ef722..31b5090e81e 100644
--- a/lldb/test/test_results.py
+++ b/lldb/test/test_results.py
@@ -386,6 +386,7 @@ class ResultsFormatter(object):
if not self.out_file:
raise Exception("ResultsFormatter created with no file object")
self.start_time_by_test = {}
+ self.terminate_called = False
# Lock that we use while mutating inner state, like the
# total test count and the elements. We minimize how
@@ -402,7 +403,14 @@ class ResultsFormatter(object):
@param test_event the test event as formatted by one of the
event_for_* calls.
"""
- pass
+ # Keep track of whether terminate was received. We do this so
+ # that a process can call the 'terminate' event on its own, to
+ # close down a formatter at the appropriate time. Then the
+ # atexit() cleanup can call the "terminate if it hasn't been
+ # called yet".
+ if test_event is not None:
+ if test_event.get("event", "") == "terminate":
+ self.terminate_called = True
def track_start_time(self, test_class, test_name, start_time):
"""Tracks the start time of a test so elapsed time can be computed.
@@ -438,9 +446,16 @@ class ResultsFormatter(object):
return end_time - start_time
def is_using_terminal(self):
- """Returns True if this results formatter is using the terminal and output should be avoided"""
+ """Returns True if this results formatter is using the terminal and
+ output should be avoided."""
return self.using_terminal
+ def send_terminate_as_needed(self):
+ """Sends the terminate event if it hasn't been received yet."""
+ if not self.terminate_called:
+ terminate_event = EventBuilder.bare_event("terminate")
+ self.handle_event(terminate_event)
+
class XunitFormatter(ResultsFormatter):
"""Provides xUnit-style formatted output.
"""
OpenPOWER on IntegriCloud