Merge lp:~lifeless/bzr/test-speed into lp:~bzr/bzr/trunk-old
- test-speed
- Merge into trunk-old
Proposed by
Robert Collins
Status: | Superseded |
---|---|
Proposed branch: | lp:~lifeless/bzr/test-speed |
Merge into: | lp:~bzr/bzr/trunk-old |
Diff against target: | 204 lines |
To merge this branch: | bzr merge lp:~lifeless/bzr/test-speed |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Martin Pool | Approve | ||
Review via email:
|
This proposal has been superseded by a proposal from 2009-08-23.
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Robert Collins (lifeless) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Martin Pool (mbp) wrote : | # |
I think those upper-layer tests are almost pointless, but fixing the lower layers to work on smaller data is certainly welcome.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bzrlib/tests/__init__.py' | |||
2 | --- bzrlib/tests/__init__.py 2009-08-20 05:05:59 +0000 | |||
3 | +++ bzrlib/tests/__init__.py 2009-08-23 22:35:09 +0000 | |||
4 | @@ -3207,6 +3207,7 @@ | |||
5 | 3207 | starting_with=None, | 3207 | starting_with=None, |
6 | 3208 | runner_class=None, | 3208 | runner_class=None, |
7 | 3209 | suite_decorators=None, | 3209 | suite_decorators=None, |
8 | 3210 | stream=None, | ||
9 | 3210 | ): | 3211 | ): |
10 | 3211 | """Run the whole test suite under the enhanced runner""" | 3212 | """Run the whole test suite under the enhanced runner""" |
11 | 3212 | # XXX: Very ugly way to do this... | 3213 | # XXX: Very ugly way to do this... |
12 | @@ -3245,6 +3246,7 @@ | |||
13 | 3245 | strict=strict, | 3246 | strict=strict, |
14 | 3246 | runner_class=runner_class, | 3247 | runner_class=runner_class, |
15 | 3247 | suite_decorators=suite_decorators, | 3248 | suite_decorators=suite_decorators, |
16 | 3249 | stream=stream, | ||
17 | 3248 | ) | 3250 | ) |
18 | 3249 | finally: | 3251 | finally: |
19 | 3250 | default_transport = old_transport | 3252 | default_transport = old_transport |
20 | 3251 | 3253 | ||
21 | === modified file 'bzrlib/tests/blackbox/test_selftest.py' | |||
22 | --- bzrlib/tests/blackbox/test_selftest.py 2009-07-10 07:14:02 +0000 | |||
23 | +++ bzrlib/tests/blackbox/test_selftest.py 2009-08-23 22:35:09 +0000 | |||
24 | @@ -26,6 +26,7 @@ | |||
25 | 26 | import bzrlib | 26 | import bzrlib |
26 | 27 | from bzrlib import ( | 27 | from bzrlib import ( |
27 | 28 | osutils, | 28 | osutils, |
28 | 29 | tests, | ||
29 | 29 | ) | 30 | ) |
30 | 30 | from bzrlib.errors import ParamikoNotPresent | 31 | from bzrlib.errors import ParamikoNotPresent |
31 | 31 | from bzrlib.tests import ( | 32 | from bzrlib.tests import ( |
32 | @@ -512,59 +513,55 @@ | |||
33 | 512 | return (header,body,footer) | 513 | return (header,body,footer) |
34 | 513 | 514 | ||
35 | 514 | def test_list_only(self): | 515 | def test_list_only(self): |
89 | 515 | # check that bzr selftest --list-only works correctly | 516 | # check that bzr selftest --list-only outputs no ui noise |
90 | 516 | out,err = self.run_bzr('selftest selftest --list-only') | 517 | def selftest(*args, **kwargs): |
91 | 517 | (header,body,footer) = self._parse_test_list(out.splitlines()) | 518 | """Capture the arguments selftest was run with.""" |
92 | 518 | num_tests = len(body) | 519 | return True |
93 | 519 | self.assertLength(0, header) | 520 | def outputs_nothing(cmdline): |
94 | 520 | self.assertLength(0, footer) | 521 | out,err = self.run_bzr(cmdline) |
95 | 521 | self.assertEqual('', err) | 522 | (header,body,footer) = self._parse_test_list(out.splitlines()) |
96 | 522 | 523 | num_tests = len(body) | |
97 | 523 | def test_list_only_filtered(self): | 524 | self.assertLength(0, header) |
98 | 524 | # check that a filtered --list-only works, both include and exclude | 525 | self.assertLength(0, footer) |
99 | 525 | out_all,err_all = self.run_bzr('selftest --list-only') | 526 | self.assertEqual('', err) |
100 | 526 | tests_all = self._parse_test_list(out_all.splitlines())[1] | 527 | # Yes this prevents using threads to run the test suite in parallel, |
101 | 527 | out_incl,err_incl = self.run_bzr('selftest --list-only selftest') | 528 | # however we don't have a clean dependency injector for commands, |
102 | 528 | tests_incl = self._parse_test_list(out_incl.splitlines())[1] | 529 | # and even if we did - we'd still be testing that the glue is wired |
103 | 529 | self.assertSubset(tests_incl, tests_all) | 530 | # up correctly. XXX: TODO: Solve this testing problem. |
104 | 530 | out_excl,err_excl = self.run_bzr(['selftest', '--list-only', | 531 | original_selftest = tests.selftest |
105 | 531 | '--exclude', 'selftest']) | 532 | tests.selftest = selftest |
106 | 532 | tests_excl = self._parse_test_list(out_excl.splitlines())[1] | 533 | try: |
107 | 533 | self.assertSubset(tests_excl, tests_all) | 534 | outputs_nothing('selftest --list-only') |
108 | 534 | set_incl = set(tests_incl) | 535 | outputs_nothing('selftest --list-only selftest') |
109 | 535 | set_excl = set(tests_excl) | 536 | outputs_nothing(['selftest', '--list-only', '--exclude', 'selftest']) |
110 | 536 | intersection = set_incl.intersection(set_excl) | 537 | finally: |
111 | 537 | self.assertEquals(0, len(intersection)) | 538 | tests.selftest = original_selftest |
112 | 538 | self.assertEquals(len(tests_all), len(tests_incl) + len(tests_excl)) | 539 | |
113 | 539 | 540 | def test_parameters_passed_to_core(self): | |
114 | 540 | def test_list_only_random(self): | 541 | params = [] |
115 | 541 | # check that --randomize works correctly | 542 | def selftest(*args, **kwargs): |
116 | 542 | out_all,err_all = self.run_bzr('selftest --list-only selftest') | 543 | """Capture the arguments selftest was run with.""" |
117 | 543 | tests_all = self._parse_test_list(out_all.splitlines())[1] | 544 | params.append((args, kwargs)) |
118 | 544 | # XXX: It looks like there are some orders for generating tests that | 545 | return True |
119 | 545 | # fail as of 20070504 - maybe because of import order dependencies. | 546 | # Yes this prevents using threads to run the test suite in parallel, |
120 | 546 | # So unfortunately this will rarely intermittently fail at the moment. | 547 | # however we don't have a clean dependency injector for commands, |
121 | 547 | # -- mbp 20070504 | 548 | # and even if we did - we'd still be testing that the glue is wired |
122 | 548 | out_rand,err_rand = self.run_bzr(['selftest', '--list-only', | 549 | # up correctly. XXX: TODO: Solve this testing problem. |
123 | 549 | 'selftest', '--randomize', 'now']) | 550 | original_selftest = tests.selftest |
124 | 550 | (header_rand,tests_rand,dummy) = self._parse_test_list( | 551 | tests.selftest = selftest |
125 | 551 | out_rand.splitlines(), 1) | 552 | try: |
126 | 552 | # XXX: The following line asserts that the randomized order is not the | 553 | self.run_bzr('selftest --list-only') |
127 | 553 | # same as the default order. It is just possible that they'll get | 554 | self.run_bzr('selftest --list-only selftest') |
128 | 554 | # randomized into the same order and this will falsely fail, but | 555 | self.run_bzr(['selftest', '--list-only', '--exclude', 'selftest']) |
129 | 555 | # that's very unlikely in practice because there are thousands of | 556 | self.run_bzr(['selftest', '--list-only', 'selftest', |
130 | 556 | # tests. | 557 | '--randomize', 'now']) |
131 | 557 | self.assertNotEqual(tests_all, tests_rand) | 558 | # list_only should have been passed in each invocation. |
132 | 558 | self.assertEqual(sorted(tests_all), sorted(tests_rand)) | 559 | self.assertTrue("list_only" in params[0][1]) |
133 | 559 | # Check that the seed can be reused to get the exact same order | 560 | self.assertTrue("list_only" in params[1][1]) |
134 | 560 | seed_re = re.compile('Randomizing test order using seed (\w+)') | 561 | self.assertTrue("list_only" in params[2][1]) |
135 | 561 | match_obj = seed_re.search(header_rand[-1]) | 562 | self.assertSubset(["list_only", "random_seed"], params[2][1]) |
136 | 562 | seed = match_obj.group(1) | 563 | finally: |
137 | 563 | out_rand2,err_rand2 = self.run_bzr(['selftest', '--list-only', | 564 | tests.selftest = original_selftest |
85 | 564 | 'selftest', '--randomize', seed]) | ||
86 | 565 | (header_rand2,tests_rand2,dummy) = self._parse_test_list( | ||
87 | 566 | out_rand2.splitlines(), 1) | ||
88 | 567 | self.assertEqual(tests_rand, tests_rand2) | ||
138 | 568 | 565 | ||
139 | 569 | 566 | ||
140 | 570 | class TestSelftestWithIdList(TestCaseInTempDir): | 567 | class TestSelftestWithIdList(TestCaseInTempDir): |
141 | 571 | 568 | ||
142 | === modified file 'bzrlib/tests/test_selftest.py' | |||
143 | --- bzrlib/tests/test_selftest.py 2009-08-17 03:47:03 +0000 | |||
144 | +++ bzrlib/tests/test_selftest.py 2009-08-23 22:35:09 +0000 | |||
145 | @@ -1770,6 +1770,60 @@ | |||
146 | 1770 | test_suite_factory=factory) | 1770 | test_suite_factory=factory) |
147 | 1771 | self.assertEqual([True], factory_called) | 1771 | self.assertEqual([True], factory_called) |
148 | 1772 | 1772 | ||
149 | 1773 | def factory(self): | ||
150 | 1774 | """A test suite factory.""" | ||
151 | 1775 | class Test(tests.TestCase): | ||
152 | 1776 | def a(self): | ||
153 | 1777 | pass | ||
154 | 1778 | def b(self): | ||
155 | 1779 | pass | ||
156 | 1780 | def c(self): | ||
157 | 1781 | pass | ||
158 | 1782 | return TestUtil.TestSuite([Test("a"), Test("b"), Test("c")]) | ||
159 | 1783 | |||
160 | 1784 | def run_selftest(self, **kwargs): | ||
161 | 1785 | """Run selftest returning its output.""" | ||
162 | 1786 | output = StringIO() | ||
163 | 1787 | self.assertEqual(True, tests.selftest(stream=output, **kwargs)) | ||
164 | 1788 | output.seek(0) | ||
165 | 1789 | return output | ||
166 | 1790 | |||
167 | 1791 | def test_list_only(self): | ||
168 | 1792 | output = self.run_selftest(test_suite_factory=self.factory, | ||
169 | 1793 | list_only=True) | ||
170 | 1794 | self.assertEqual(3, len(output.readlines())) | ||
171 | 1795 | |||
172 | 1796 | def test_list_only_filtered(self): | ||
173 | 1797 | output = self.run_selftest(test_suite_factory=self.factory, | ||
174 | 1798 | list_only=True, pattern="Test.b") | ||
175 | 1799 | self.assertEndsWith(output.getvalue(), "Test.b\n") | ||
176 | 1800 | self.assertLength(1, output.readlines()) | ||
177 | 1801 | |||
178 | 1802 | def test_list_only_excludes(self): | ||
179 | 1803 | output = self.run_selftest(test_suite_factory=self.factory, | ||
180 | 1804 | list_only=True, exclude_pattern="Test.b") | ||
181 | 1805 | self.assertNotContainsRe("Test.b", output.getvalue()) | ||
182 | 1806 | self.assertLength(2, output.readlines()) | ||
183 | 1807 | |||
184 | 1808 | def test_random(self): | ||
185 | 1809 | # test randomising by listing a number of tests. | ||
186 | 1810 | output_123 = self.run_selftest(test_suite_factory=self.factory, | ||
187 | 1811 | list_only=True, random_seed="123") | ||
188 | 1812 | output_234 = self.run_selftest(test_suite_factory=self.factory, | ||
189 | 1813 | list_only=True, random_seed="234") | ||
190 | 1814 | self.assertNotEqual(output_123, output_234) | ||
191 | 1815 | # "Randominzing test order..\n\n | ||
192 | 1816 | self.assertLength(5, output_123.readlines()) | ||
193 | 1817 | self.assertLength(5, output_234.readlines()) | ||
194 | 1818 | |||
195 | 1819 | def test_random_reuse_is_same_order(self): | ||
196 | 1820 | # test randomising by listing a number of tests. | ||
197 | 1821 | expected = self.run_selftest(test_suite_factory=self.factory, | ||
198 | 1822 | list_only=True, random_seed="123") | ||
199 | 1823 | repeated = self.run_selftest(test_suite_factory=self.factory, | ||
200 | 1824 | list_only=True, random_seed="123") | ||
201 | 1825 | self.assertEqual(expected.getvalue(), repeated.getvalue()) | ||
202 | 1826 | |||
203 | 1773 | 1827 | ||
204 | 1774 | class TestKnownFailure(tests.TestCase): | 1828 | class TestKnownFailure(tests.TestCase): |
205 | 1775 | 1829 |
This turns two 13 second tests into a few millisecond-scale tests
testing more precise layers.
-Rob
--