scripts: twister: Fix trailing CR/LF at BinaryHandler logs
Fix trailing `\\r\\n` (escaped CR/LF) didn't cut off because of rstrip() removed by #58338, so the CR/LF suffix was never found as the actual line end was `\\r\\n\n`. Add ANSI code sequence to `test_handlers` Twister unit test. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
This commit is contained in:
parent
58d9e3d27a
commit
2ddab56bfd
@ -216,10 +216,9 @@ class BinaryHandler(Handler):
|
||||
reader_t.join(this_timeout)
|
||||
if not reader_t.is_alive() and self.line != b"":
|
||||
line_decoded = self.line.decode('utf-8', "replace")
|
||||
if line_decoded.endswith(suffix):
|
||||
stripped_line = line_decoded[:-len(suffix)].rstrip()
|
||||
else:
|
||||
stripped_line = line_decoded.rstrip()
|
||||
stripped_line = line_decoded.rstrip()
|
||||
if stripped_line.endswith(suffix):
|
||||
stripped_line = stripped_line[:-len(suffix)].rstrip()
|
||||
logger.debug("OUTPUT: %s", stripped_line)
|
||||
log_out_fp.write(strip_ansi_sequences(line_decoded))
|
||||
log_out_fp.flush()
|
||||
|
||||
@ -297,17 +297,19 @@ def test_binaryhandler_try_kill_process_by_pid(mocked_instance):
|
||||
|
||||
TESTDATA_3 = [
|
||||
(
|
||||
[b'This\\r\\n', b'is\r', b'a short', b'file.'],
|
||||
[b'This\\r\\n\n', b'is\r', b'some \x1B[31mANSI\x1B[39m in\n', b'a short\n', b'file.'],
|
||||
mock.Mock(status=TwisterStatus.NONE, capture_coverage=False),
|
||||
[
|
||||
mock.call('This\\r\\n'),
|
||||
mock.call('This\\r\\n\n'),
|
||||
mock.call('is\r'),
|
||||
mock.call('a short'),
|
||||
mock.call('some ANSI in\n'),
|
||||
mock.call('a short\n'),
|
||||
mock.call('file.')
|
||||
],
|
||||
[
|
||||
mock.call('This'),
|
||||
mock.call('is'),
|
||||
mock.call('some \x1B[31mANSI\x1B[39m in'),
|
||||
mock.call('a short'),
|
||||
mock.call('file.')
|
||||
],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user