[Lldb-commits] [lldb] r248228 - test framework: parallel test runner sends terminate to formatter before printing to stdout
Todd Fiala via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 21 17:15:51 PDT 2015
Author: tfiala
Date: Mon Sep 21 19:15:50 2015
New Revision: 248228
URL: http://llvm.org/viewvc/llvm-project?rev=248228&view=rev
Log:
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.
Modified:
lldb/trunk/test/dosep.py
lldb/trunk/test/dotest.py
lldb/trunk/test/test_results.py
Modified: lldb/trunk/test/dosep.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.py?rev=248228&r1=248227&r2=248228&view=diff
==============================================================================
--- lldb/trunk/test/dosep.py (original)
+++ lldb/trunk/test/dosep.py Mon Sep 21 19:15:50 2015
@@ -1231,6 +1231,11 @@ def main(print_details_on_success, num_t
(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
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=248228&r1=248227&r2=248228&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Mon Sep 21 19:15:50 2015
@@ -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:
Modified: lldb/trunk/test/test_results.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/test_results.py?rev=248228&r1=248227&r2=248228&view=diff
==============================================================================
--- lldb/trunk/test/test_results.py (original)
+++ lldb/trunk/test/test_results.py Mon Sep 21 19:15:50 2015
@@ -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.
"""
More information about the lldb-commits
mailing list