Changeset 239303 in webkit


Ignore:
Timestamp:
Dec 17, 2018 4:12:06 PM (5 years ago)
Author:
Jonathan Bedard
Message:

webkitpy: Handle case where stdout and stderr don't accept unicode
https://bugs.webkit.org/show_bug.cgi?id=192775
<rdar://problem/46497303>

Reviewed by Stephanie Lewis.

  • Scripts/webkitpy/layout_tests/views/metered_stream.py:

(MeteredStream.write): If unicode cannot be written to the stream, replace unicode
characters with '?'.

  • Scripts/webkitpy/layout_tests/views/metered_stream_unittest.py:

(RegularTest.test_stream_with_encoding):

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r239282 r239303  
     12018-12-17  Jonathan Bedard  <jbedard@apple.com>
     2
     3        webkitpy: Handle case where stdout and stderr don't accept unicode
     4        https://bugs.webkit.org/show_bug.cgi?id=192775
     5        <rdar://problem/46497303>
     6
     7        Reviewed by Stephanie Lewis.
     8
     9        * Scripts/webkitpy/layout_tests/views/metered_stream.py:
     10        (MeteredStream.write): If unicode cannot be written to the stream, replace unicode
     11        characters with '?'.
     12        * Scripts/webkitpy/layout_tests/views/metered_stream_unittest.py:
     13        (RegularTest.test_stream_with_encoding):
     14
    1152018-12-17  Daniel Bates  <dabates@apple.com>
    216
  • trunk/Tools/Scripts/webkitpy/layout_tests/views/metered_stream.py

    r238862 r239303  
    108108            txt = self._ensure_newline(txt)
    109109
    110         self._stream.write(timestamp_string + txt)
     110        try:
     111            self._stream.write(timestamp_string + txt)
     112        except UnicodeEncodeError:
     113            output = ''
     114            for c in timestamp_string + txt:
     115                try:
     116                    output += '{}'.format(c)
     117                except UnicodeEncodeError:
     118                    output += '?'
     119            self._stream.write(output)
    111120
    112121    def writeln(self, txt, now=None, pid=None):
  • trunk/Tools/Scripts/webkitpy/layout_tests/views/metered_stream_unittest.py

    r238862 r239303  
    118118        self.assertEqual(self.buflist[-1][-14:], '‘example’\n')
    119119
     120    def test_stream_with_encoding(self):
     121        class AsciiStream(StringIO.StringIO):
     122            def write(self, s):
     123                return StringIO.StringIO.write(self, '{}'.format(s))
     124
     125        stream = AsciiStream()
     126
     127        logger = logging.getLogger(__name__)
     128        logger.setLevel(logging.DEBUG)
     129        logger.propagate = False
     130
     131        try:
     132            meter = MeteredStream(stream, self.verbose, logger, self.time_fn, 8675, print_timestamps=self.print_timestamps)
     133            self.logger.info(u'\u2713')
     134            self.assertEqual(stream.buflist[-1][-2:], '?\n')
     135        finally:
     136            meter.cleanup()
     137
    120138
    121139class TtyTest(RegularTest):
Note: See TracChangeset for help on using the changeset viewer.