Merge lp:~yellow/testrepository/on_filter into lp:~testrepository/testrepository/trunk

Proposed by Gary Poster
Status: Rejected
Rejected by: Robert Collins
Proposed branch: lp:~yellow/testrepository/on_filter
Merge into: lp:~testrepository/testrepository/trunk
Diff against target: 50 lines (+8/-32)
1 file modified
testrepository/results.py (+8/-32)
To merge this branch: bzr merge lp:~yellow/testrepository/on_filter
Reviewer Review Type Date Requested Status
Robert Collins Needs Fixing
Review via email: mp+103969@code.launchpad.net

Description of the change

This branch depends on the subunit change in https://code.launchpad.net/~yellow/subunit/on_filter/+merge/103968 . It replaces https://code.launchpad.net/~yellow/testrepository/bug988481/+merge/103704 .

Because of the proposed subunit change, we can significantly simplify testrepository's TestResultFilter subclass.

Moreover, it will support https://code.launchpad.net/~jml/subunit/filter-tags/+merge/102840 in the future: that branch breaks testrepository because _filtered is no longer called on subunit's TestResultFilter in those changes.

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Is this still needed?

Revision history for this message
Gary Poster (gary) wrote :

I…don't know. It is one way to get your subunit tag filter branch to not cause test failures with testrepository. The only reason this branch, of one like it would not be necessary is if Robert's branch fixed it *and* it landed before yours.

I personally suggest that you all land the two on_filter branches of something like them that replaces dependency on _filtered, and then land your subunit-filter with tags branch, which has been proven to work as we'd like, at least. Robert's branch isn't ready to land, and these are, afaik.

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

This comment in the removed lines - 'so we
12 - # should actually use two result objects - one to count and one to
13 - # show. ' - is key: rather than preserving the hack it should be straight forward enough to fix directly and drop the hack entirely. I'll look into doing that. As this stands it would need fixing to preserv compat with the current released testtools/subunit. I'll put it into WIP for now.

review: Needs Fixing
Revision history for this message
Gary Poster (gary) wrote :

Cool Robert, thanks. I'd put this into a withdrawn state if I could; maybe I'll delete later, but I'll keep it around for history for now. If anyone else would like to delete it, feel free.

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

So I think the consensus was to not land this. Marking rejected so its not shown as pending.

Unmerged revisions

149. By Gary Poster

simplify TestResultFilter to take advantage of changes in lp:~yellow/subunit/on_filter; this also prepares the way for lp:~jml/subunit/filter-tags

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testrepository/results.py'
2--- testrepository/results.py 2011-11-02 20:55:16 +0000
3+++ testrepository/results.py 2012-04-28 02:36:19 +0000
4@@ -8,38 +8,14 @@
5 class TestResultFilter(test_results.TestResultFilter):
6 """Test result filter."""
7
8- def _get_concrete_result(self):
9- # XXX: This is really crappy. It assumes that the test result we
10- # actually care about is decorated and that we can find our way to the
11- # one we care about. We want to report counts before filtering, so we
12- # should actually use two result objects - one to count and one to
13- # show. Arguably also the testsRun incrementing facility should be in
14- # testtools / subunit
15- concrete = self
16- while True:
17- next = getattr(concrete, 'decorated', None)
18- if next is None:
19- return concrete
20- concrete = next
21-
22- def _filtered(self):
23- super(TestResultFilter, self)._filtered()
24- concrete = self._get_concrete_result()
25- concrete.testsRun += 1
26-
27- def stopTest(self, test):
28- # Filter out 'time' calls, because we want to forward those events
29- # regardless of whether the test is filtered.
30- #
31- # XXX: Should this be pushed into subunit?
32- buffered_calls = []
33- for method, args, kwargs in self._buffered_calls:
34- if method == 'time':
35- self.decorated.time(*args, **kwargs)
36- else:
37- buffered_calls.append((method, args, kwargs))
38- self._buffered_calls = buffered_calls
39- super(TestResultFilter, self).stopTest(test)
40+ def __init__(self, result, *args, **kwargs):
41+ # This test count should be equal to all of the tests run, not
42+ # just the tests that pass through the filter.
43+ def on_filter(test):
44+ result.testsRun += 1
45+ kwargs['on_filter'] = on_filter
46+ super(TestResultFilter, self).__init__(
47+ result, *args, **kwargs)
48
49
50 class SummarizingResult(TestResult):

Subscribers

People subscribed via source and target branches