Auto merge of #8456 - mrobinson:wpt-fixes, r=jgraham

Fix some issues with the WPT UI output

When running in non-interactive mode, print test names as they are run.
This prevent timeouts on the bots, which are detected by watching for
output from the test runner.

When running in iTerm.app don't use the multi-line status line, as the
carriage return is not processed properly. Instead use a single-line
output with the last test run and then backspace characters to keep it
up to date.

Fixes #8368.
Fixes #8395.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8456)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-10 22:32:03 +05:30
commit 8e80e38c78

View file

@ -17,11 +17,16 @@ class GroupingFormatter(base.BaseFormatter):
self.need_to_erase_last_line = False
self.current_display = ""
self.running_tests = {}
self.last_test_finished = "Running tests..."
self.test_output = collections.defaultdict(str)
self.subtest_failures = collections.defaultdict(list)
self.tests_with_failing_subtests = []
self.interactive = os.isatty(sys.stdout.fileno())
# iTerm2 doesn't support the terminal codes used to erase previous lines,
# so only print one line and rely only on backspace characters.
self.one_line = os.environ.get("TERM_PROGRAM", "") == "iTerm.app"
self.expected = {
'OK': 0,
'PASS': 0,
@ -44,7 +49,12 @@ class GroupingFormatter(base.BaseFormatter):
def text_to_erase_display(self):
if not self.interactive or not self.current_display:
return ""
# TODO(mrobinson, 8313): We need to add support for Windows terminals here.
erase_length = len(self.current_display)
if self.one_line:
return "\b \b" * erase_length
else:
return ("\033[F" + "\033[K") * len(self.current_display.splitlines())
def generate_output(self, text=None, new_display=None):
@ -64,6 +74,9 @@ class GroupingFormatter(base.BaseFormatter):
else:
new_display = " [%i/%i] " % (self.completed_tests, self.number_of_tests)
if self.one_line:
return new_display + self.last_test_finished
if self.running_tests:
indent = " " * len(new_display)
return new_display + ("\n%s" % indent).join(
@ -161,11 +174,16 @@ class GroupingFormatter(base.BaseFormatter):
subtest_failures = self.subtest_failures.pop(test_name, [])
del self.running_tests[data['thread']]
self.last_test_finished = test_name
new_display = self.build_status_line()
if not had_unexpected_test_result and not subtest_failures:
self.expected[test_status] += 1
if self.interactive:
return self.generate_output(text=None, new_display=new_display)
else:
return self.generate_output(text=" %s\n\n" % test_name,
new_display=new_display)
# If the test crashed or timed out, we also include any process output,
# because there is a good chance that the test produced a stack trace