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

Proposed by William Grant
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 12766
Proposed branch: lp:~wgrant/launchpad/bug-752149
Merge into: lp:launchpad
Diff against target: 36 lines (+10/-4)
2 files modified
lib/lp/services/command_spawner.py (+3/-4)
lib/lp/services/tests/test_command_spawner.py (+7/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-752149
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+56500@code.launchpad.net

Commit message

[r=lifeless][bug=752149] CommandSpawner's OutputLineHandler now correctly clears the buffer when a complete line is received.

Description of the change

Not much to say beyond the bug description and test.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/command_spawner.py'
2--- lib/lp/services/command_spawner.py 2011-02-01 20:01:58 +0000
3+++ lib/lp/services/command_spawner.py 2011-04-06 03:45:49 +0000
4@@ -224,11 +224,10 @@
5 Any trailing text not (yet) terminated with a newline is buffered.
6 """
7 lines = (self.incomplete_buffer + output).split("\n")
8- if not output.endswith("\n") and len(lines) > 0:
9+ if len(lines) > 0:
10 self.incomplete_buffer = lines[-1]
11- lines = lines[:-1]
12- for line in lines:
13- self.process_line(line)
14+ for line in lines[:-1]:
15+ self.process_line(line)
16
17 def finalize(self):
18 """Process the remaining incomplete line, if any."""
19
20=== modified file 'lib/lp/services/tests/test_command_spawner.py'
21--- lib/lp/services/tests/test_command_spawner.py 2011-02-01 19:51:46 +0000
22+++ lib/lp/services/tests/test_command_spawner.py 2011-04-06 03:45:49 +0000
23@@ -367,6 +367,13 @@
24 self.handler("i\n")
25 self.assertEqual(["hi"], self._getLines())
26
27+ def test_clears_buffer_after_joining_lines(self):
28+ self.handler("hi")
29+ self.handler("!\n")
30+ self.assertEqual(["hi!"], self._getLines())
31+ self.handler("!\n")
32+ self.assertEqual(["hi!", "!"], self._getLines())
33+
34 def test_finalize_processes_remaining_partial_line(self):
35 self.handler("foo")
36 self.handler.finalize()