Changeset 139831 in webkit


Ignore:
Timestamp:
Jan 15, 2013 8:44:48 PM (11 years ago)
Author:
dpranke@chromium.org
Message:

test-webkitpy: truncate output to the terminal width when necessary
https://bugs.webkit.org/show_bug.cgi?id=106973

Reviewed by Ojan Vafai.

this implements the same logic for test-webkitpy that we have
for run-webkit-tests (and ninja).

No tests written as this is exercised by running test-webkitpy itself.

  • Scripts/webkitpy/test/printer.py:

(Printer.configure):
(Printer._test_line):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r139830 r139831  
     12013-01-15  Dirk Pranke  <dpranke@chromium.org>
     2
     3        test-webkitpy: truncate output to the terminal width when necessary
     4        https://bugs.webkit.org/show_bug.cgi?id=106973
     5
     6        Reviewed by Ojan Vafai.
     7
     8        this implements the same logic for test-webkitpy that we have
     9        for run-webkit-tests (and ninja).
     10
     11        No tests written as this is exercised by running test-webkitpy itself.
     12
     13        * Scripts/webkitpy/test/printer.py:
     14        (Printer.configure):
     15        (Printer._test_line):
     16
    1172013-01-15  Dirk Pranke  <dpranke@chromium.org>
    218
  • trunk/Tools/Scripts/webkitpy/test/printer.py

    r124501 r139831  
    2626
    2727from webkitpy.common.system import outputcapture
     28from webkitpy.common.system.systemhost import SystemHost
    2829from webkitpy.layout_tests.views.metered_stream import MeteredStream
    2930
     
    5859            log_level = logging.DEBUG
    5960
    60         self.meter = MeteredStream(self.stream, (options.verbose == 2))
     61        self.meter = MeteredStream(self.stream, (options.verbose == 2),
     62            number_of_columns=SystemHost().platform.terminal_width())
    6163
    6264        handler = logging.StreamHandler(self.stream)
     
    160162
    161163    def _test_line(self, test_name, suffix):
    162         return '[%d/%d] %s%s' % (self.num_completed, self.num_tests, test_name, suffix)
     164        format_string = '[%d/%d] %s%s'
     165        status_line = format_string % (self.num_completed, self.num_tests, test_name, suffix)
     166        if len(status_line) > self.meter.number_of_columns():
     167            overflow_columns = len(status_line) - self.meter.number_of_columns()
     168            ellipsis = '...'
     169            if len(test_name) < overflow_columns + len(ellipsis) + 3:
     170                # We don't have enough space even if we elide, just show the test method name.
     171                test_name = test_name.split('.')[-1]
     172            else:
     173                new_length = len(test_name) - overflow_columns - len(ellipsis)
     174                prefix = int(new_length / 2)
     175                test_name = test_name[:prefix] + ellipsis + test_name[-(new_length - prefix):]
     176        return format_string % (self.num_completed, self.num_tests, test_name, suffix)
    163177
    164178    def print_result(self, run_time):
Note: See TracChangeset for help on using the changeset viewer.