Merge lp:~vila/subunit/gtk-filter-fixes into lp:~subunit/subunit/trunk

Proposed by Vincent Ladeuil
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vila/subunit/gtk-filter-fixes
Merge into: lp:~subunit/subunit/trunk
Diff against target: 89 lines (+17/-18)
1 file modified
filters/subunit2gtk (+17/-18)
To merge this branch: bzr merge lp:~vila/subunit/gtk-filter-fixes
Reviewer Review Type Date Requested Status
Subunit Developers Pending
Review via email: mp+17366@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Drive-by fixes while testing subunit2gtk.

Revision history for this message
Robert Collins (lifeless) wrote :

As a drive by it was fine up to here:

On Thu, 2010-01-14 at 11:25 +0000, Vincent Ladeuil wrote:
> + self.protocol.lineReceived(line)
> if not line:
> - self.protocol.lostConnection()
> self.on_finish()
> return False
> - self.protocol.lineReceived(line)
> - # schedule more IO shortly - if we say we're willing to do it
> - # immediately we starve things.
> - source_id = gobject.timeout_add(1, self.schedule_read)
> - return False
> + return True
>
> def schedule_read(self):
> - self.read_id = gobject.io_add_watch(self.stream,
> gobject.IO_IN, self.read)
> + self.read_id = gobject.io_add_watch(self.stream,
> gobject.IO_IN,
> + self.read)
>
> def hup(self, source, condition):
> - self.protocol.lostConnection()
> gobject.source_remove(self.read_id)
> self.on_finish()
> + return False

Please explain.

-Rob

Revision history for this message
Vincent Ladeuil (vila) wrote :

>>>>> "robert" == Robert Collins <email address hidden> writes:

    robert> As a drive by it was fine up to here:
    robert> On Thu, 2010-01-14 at 11:25 +0000, Vincent Ladeuil wrote:
    >> + self.protocol.lineReceived(line)
    >> if not line:
    >> - self.protocol.lostConnection()
    >> self.on_finish()
    >> return False
    >> - self.protocol.lineReceived(line)
    >> - # schedule more IO shortly - if we say we're willing to do it
    >> - # immediately we starve things.
    >> - source_id = gobject.timeout_add(1, self.schedule_read)
    >> - return False
    >> + return True
    >>
    >> def schedule_read(self):
    >> - self.read_id = gobject.io_add_watch(self.stream,
    >> gobject.IO_IN, self.read)
    >> + self.read_id = gobject.io_add_watch(self.stream,
    >> gobject.IO_IN,
    >> + self.read)
    >>
    >> def hup(self, source, condition):
    >> - self.protocol.lostConnection()
    >> gobject.source_remove(self.read_id)
    >> self.on_finish()
    >> + return False

    robert> Please explain.

Commit message (bad launchpad didn't give it to you in mail I
suspect, sorry about that):

    Make subunit2gtk works and stop reporting the last test as an error.

    * subunit2gtk:
    (GTKTestResult.__init__, GTKTestResult.stopTest,
    GTKTestResult.progress): An attribute named like a method sounds
    like a recipe for disaster. 'progress' attribute renamed to
    'progress_model'.
    (GIOProtocolTestCase.read): Don't install additional watches, just
    return True to indicate we want to be called again. Return False
    only when we get to the end of the file. Leave hup handle the lost
    connection issues.
    (GIOProtocolTestCase.hup): We can be called only once but we need
    to return False to avoid spurious warnings.

Revision history for this message
Robert Collins (lifeless) wrote :

On Thu, 2010-01-14 at 14:24 +0000, Vincent Ladeuil wrote:

So, please write better cover letters ;).

> >> - # schedule more IO shortly - if we say we're willing
> to do it
> >> - # immediately we starve things.

So, the reason I did it the way I did was that if you cat a 2MB file
through subunit2gtk with it always ready to do I/O the UI got totally
starved. Have you tested this?

I've pushed the rest of your changes, but not this one.

-Rob

Revision history for this message
Vincent Ladeuil (vila) wrote :

>>>>> "robert" == Robert Collins <email address hidden> writes:

    robert> On Thu, 2010-01-14 at 14:24 +0000, Vincent Ladeuil wrote:
    robert> So, please write better cover letters ;).

    >> >> - # schedule more IO shortly - if we say we're willing
    >> to do it
    >> >> - # immediately we starve things.

    robert> So, the reason I did it the way I did was that if you cat a 2MB file
    robert> through subunit2gtk with it always ready to do I/O the UI got totally
    robert> starved. Have you tested this?

Oh, hmm, then the following is more appropriate IMHO:

   modified filters/subunit2gtk

=== modified file 'filters/subunit2gtk'
--- filters/subunit2gtk 2010-01-14 11:23:18 +0000
+++ filters/subunit2gtk 2010-01-15 07:24:21 +0000
@@ -225,6 +225,10 @@
         self.on_finish = on_finish

     def read(self, source, condition):
+ # We want the display to be refreshed. So we just process all pending
+ # events before handling the IO.
+ while gtk.events_pending():
+ gtk.main_iteration()
         #NB: \o/ actually blocks
         line = source.readline()
         self.protocol.lineReceived(line)

I've pushed that.

The version in trunk still makes the last test seen as an error
and I think it's due to the self.protocol.lostConnection() call.

Have you tested this ?

:)

     Vincent

Revision history for this message
Robert Collins (lifeless) wrote :

On Fri, 2010-01-15 at 07:45 +0000, Vincent Ladeuil wrote:

> I've pushed that.
>
> The version in trunk still makes the last test seen as an error
> and I think it's due to the self.protocol.lostConnection() call.
>
> Have you tested this ?

Yes, it works perfectly for me.

-Rob

Revision history for this message
Robert Collins (lifeless) wrote :

From irc - vila got me to try bzr selftest of log...

Its piping from a program that goes odd:

19:08 < lifeless> vila: so ./bzr selftest -s bt.test_log --subunit > foo
19:08 < lifeless> then cat foo | subunit2gtk
19:08 < lifeless> and subunit2gtk < foo
19:08 < lifeless> give different results

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'filters/subunit2gtk'
2--- filters/subunit2gtk 2009-12-31 17:26:46 +0000
3+++ filters/subunit2gtk 2010-01-14 11:25:21 +0000
4@@ -83,7 +83,7 @@
5 vbox.set_border_width(10)
6 self.window.add(vbox)
7 vbox.show()
8-
9+
10 # Create a centering alignment object
11 align = gtk.Alignment(0.5, 0.5, 0, 0)
12 vbox.pack_start(align, False, False, 5)
13@@ -94,7 +94,7 @@
14 align.add(self.pbar)
15 self.pbar.set_text("Running")
16 self.pbar.show()
17- self.progress = ProgressModel()
18+ self.progress_model = ProgressModel()
19
20 separator = gtk.HSeparator()
21 vbox.pack_start(separator, False, False, 0)
22@@ -139,12 +139,14 @@
23
24 def stopTest(self, test):
25 super(GTKTestResult, self).stopTest(test)
26- self.progress.advance()
27- if self.progress.width() == 0:
28+ self.progress_model.advance()
29+ if self.progress_model.width() == 0:
30 self.pbar.pulse()
31 else:
32- self.pbar.set_fraction(
33- self.progress.pos() / float(self.progress.width()))
34+ pos = self.progress_model.pos()
35+ width = self.progress_model.width()
36+ percentage = (pos / float(width))
37+ self.pbar.set_fraction(percentage)
38
39 def stopTestRun(self):
40 try:
41@@ -190,15 +192,15 @@
42
43 def progress(self, offset, whence):
44 if whence == PROGRESS_PUSH:
45- self.progress.push()
46+ self.progress_model.push()
47 elif whence == PROGRESS_POP:
48- self.progress.pop()
49+ self.progress_model.pop()
50 elif whence == PROGRESS_SET:
51 self.total_tests = offset
52- self.progress.set_width(offset)
53+ self.progress_model.set_width(offset)
54 else:
55 self.total_tests += offset
56- self.progress.adjust_width(offset)
57+ self.progress_model.adjust_width(offset)
58
59 def time(self, a_datetime):
60 # We don't try to estimate completion yet.
61@@ -223,23 +225,20 @@
62 def read(self, source, condition):
63 #NB: \o/ actually blocks
64 line = source.readline()
65+ self.protocol.lineReceived(line)
66 if not line:
67- self.protocol.lostConnection()
68 self.on_finish()
69 return False
70- self.protocol.lineReceived(line)
71- # schedule more IO shortly - if we say we're willing to do it
72- # immediately we starve things.
73- source_id = gobject.timeout_add(1, self.schedule_read)
74- return False
75+ return True
76
77 def schedule_read(self):
78- self.read_id = gobject.io_add_watch(self.stream, gobject.IO_IN, self.read)
79+ self.read_id = gobject.io_add_watch(self.stream, gobject.IO_IN,
80+ self.read)
81
82 def hup(self, source, condition):
83- self.protocol.lostConnection()
84 gobject.source_remove(self.read_id)
85 self.on_finish()
86+ return False
87
88
89 result = GTKTestResult()

Subscribers

People subscribed via source and target branches