← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bug-752149 into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bug-752149 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #752149 in Launchpad itself: "OutputLineHandler doesn't empty buffer on complete lines"
  https://bugs.launchpad.net/launchpad/+bug/752149

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bug-752149/+merge/56500

Not much to say beyond the bug description and test.
-- 
https://code.launchpad.net/~wgrant/launchpad/bug-752149/+merge/56500
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bug-752149 into lp:launchpad.
=== modified file 'lib/lp/services/command_spawner.py'
--- lib/lp/services/command_spawner.py	2011-02-01 20:01:58 +0000
+++ lib/lp/services/command_spawner.py	2011-04-06 03:38:30 +0000
@@ -224,7 +224,9 @@
         Any trailing text not (yet) terminated with a newline is buffered.
         """
         lines = (self.incomplete_buffer + output).split("\n")
-        if not output.endswith("\n") and len(lines) > 0:
+        if output.endswith("\n"):
+            self.incomplete_buffer = ''
+        elif len(lines) > 0:
             self.incomplete_buffer = lines[-1]
             lines = lines[:-1]
         for line in lines:

=== modified file 'lib/lp/services/tests/test_command_spawner.py'
--- lib/lp/services/tests/test_command_spawner.py	2011-02-01 19:51:46 +0000
+++ lib/lp/services/tests/test_command_spawner.py	2011-04-06 03:38:30 +0000
@@ -367,6 +367,13 @@
         self.handler("i\n")
         self.assertEqual(["hi"], self._getLines())
 
+    def test_clears_buffer_after_joining_lines(self):
+        self.handler("hi")
+        self.handler("!\n")
+        self.assertEqual(["hi!"], self._getLines())
+        self.handler("!\n")
+        self.assertEqual(["hi!", "!"], self._getLines())
+
     def test_finalize_processes_remaining_partial_line(self):
         self.handler("foo")
         self.handler.finalize()