summaryrefslogtreecommitdiff
path: root/buildscripts/tests/resmokelib/core/test_pipe.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/tests/resmokelib/core/test_pipe.py')
-rw-r--r--buildscripts/tests/resmokelib/core/test_pipe.py39
1 files changed, 38 insertions, 1 deletions
diff --git a/buildscripts/tests/resmokelib/core/test_pipe.py b/buildscripts/tests/resmokelib/core/test_pipe.py
index 69b0e3fb576..6ecece299a7 100644
--- a/buildscripts/tests/resmokelib/core/test_pipe.py
+++ b/buildscripts/tests/resmokelib/core/test_pipe.py
@@ -10,7 +10,7 @@ import mock
from buildscripts.resmokelib.core import pipe as _pipe
-# pylint: disable=missing-docstring
+# pylint: disable=missing-docstring,protected-access
class TestLoggerPipe(unittest.TestCase):
@@ -43,3 +43,40 @@ class TestLoggerPipe(unittest.TestCase):
def test_escapes_null_bytes(self):
calls = self._get_log_calls(b"a\0b")
self.assertEqual(calls, [mock.call(self.LOG_LEVEL, u"a\\0b")])
+
+
+class TestFormatLineForLogging(unittest.TestCase):
+ def test_strips_trailing_whitespace(self):
+ line = b" a "
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u" a"], line_output)
+
+ def test_strips_trailing_newlines(self):
+ line = b"a\r\n"
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u"a"], line_output)
+
+ def test_handles_invalid_utf8(self):
+ line = b"a\x80b"
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u"a\ufffdb"], line_output)
+
+ def test_escapes_null_bytes(self):
+ line = b"a\0b"
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual([u"a\\0b"], line_output)
+
+ def test_long_lines_are_split(self):
+ line = b"a" * 4_000_000
+
+ line_output = _pipe.LoggerPipe._format_line_for_logging(line)
+
+ self.assertEqual(2, len(line_output))