Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | John A Meinel | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 5476 | ||||
Proposed branch: | lp:~mbp/bzr/scripts | ||||
Merge into: | lp:bzr | ||||
Diff against target: |
582 lines (+167/-86) 11 files modified
NEWS (+4/-0) bzrlib/commands.py (+6/-1) bzrlib/tests/__init__.py (+4/-0) bzrlib/tests/blackbox/test_bound_branches.py (+3/-0) bzrlib/tests/blackbox/test_dpush.py (+2/-0) bzrlib/tests/blackbox/test_shelve.py (+8/-0) bzrlib/tests/script.py (+18/-8) bzrlib/tests/test_conflicts.py (+73/-73) bzrlib/tests/test_delta.py (+1/-2) bzrlib/tests/test_script.py (+42/-2) doc/developers/testing.txt (+6/-0) |
||||
To merge this branch: | bzr merge lp:~mbp/bzr/scripts | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John A Meinel | Approve | ||
Vincent Ladeuil | Needs Fixing | ||
Review via email: mp+35386@code.launchpad.net |
Commit message
empty output in shell-like tests is no longer a wildcard
Description of the change
This changes the scriptrunner behaviour so that
"""
$ echo foo
"""
will fail, because it asserts echo doesn't produce output.
I think this is less confusing. If you want to allow for a command that might produce output but you don't care, you can say '...'. It's also more consistent with regular doctest.
This is going to put on a slight extra burden that you need to think about commands that may produce output, and if we change a command that is initially silent to produce output, we may need to update a bunch of tests. However I think this is much safer than not letting people check things actually are silent.
test_resolve is a bit messy, but I think it's actually better after the changes: more clear about which bits it actually is or isn't testing, and it points out the usefulness of -q when you don't want to see the output for a particular command.
Martin Pool (mbp) wrote : | # |
On 15 September 2010 03:29, Vincent Ladeuil <email address hidden> wrote:
> Review: Needs Fixing
> I agree, having the test writer think about -q and '...' sounds like a good plan.
> The only drawback I could think of is that it will require a bit more expertise
> than a mere copy/paste. No big loss here, I'm still waiting for bug reporters to
> do that anyway :-D
>
> 127 - test_case.
> 128 + test_case.
>
> Why ??? EqualDiff provides valuable info, please don't remove that !
The diff is nicer to read, but it's less precise when there are
differences of whitespace etc, to the extent that I couldn't work out
what was going wrong. Perhaps I'll write a separate method that tries
to get the best of both, in a followon patch. For now I'll just
revert that.
--
Martin
Martin Pool (mbp) wrote : | # |
sent to pqm by email
Martin Pool (mbp) wrote : | # |
sent to pqm by email
Andrew Bennetts (spiv) wrote : | # |
sent to pqm by email
John A Meinel (jameinel) wrote : | # |
sent to pqm by email
John A Meinel (jameinel) wrote : | # |
Manually updated to resolve NEWS and submitted to pqm via pqm-submit.
John A Meinel (jameinel) wrote : | # |
The tests are failing, not just a NEWS conflict, so I'm bouncing this back to Martin.
Martin Pool (mbp) wrote : | # |
The script failures are fixed by <https:/
John A Meinel (jameinel) wrote : | # |
seems fine to me
Martin Pool (mbp) wrote : | # |
sent to pqm by email
Preview Diff
1 | === modified file 'NEWS' | |||
2 | --- NEWS 2010-10-08 01:47:43 +0000 | |||
3 | +++ NEWS 2010-10-08 06:36:46 +0000 | |||
4 | @@ -504,6 +504,10 @@ | |||
5 | 504 | Testing | 504 | Testing |
6 | 505 | ******* | 505 | ******* |
7 | 506 | 506 | ||
8 | 507 | * Blank output section in scriptrunner tests no longer match any output. | ||
9 | 508 | Instead, use '...' as a wildcard if you don't care about the output. | ||
10 | 509 | (Martin Pool, #637830) | ||
11 | 510 | |||
12 | 507 | * ``build_tree_contents`` can create symlinks. | 511 | * ``build_tree_contents`` can create symlinks. |
13 | 508 | (Martin Pool, John Arbash Meinel) | 512 | (Martin Pool, John Arbash Meinel) |
14 | 509 | 513 | ||
15 | 510 | 514 | ||
16 | === modified file 'bzrlib/commands.py' | |||
17 | --- bzrlib/commands.py 2010-08-13 07:56:06 +0000 | |||
18 | +++ bzrlib/commands.py 2010-10-08 06:36:46 +0000 | |||
19 | @@ -687,7 +687,12 @@ | |||
20 | 687 | 687 | ||
21 | 688 | self._setup_outf() | 688 | self._setup_outf() |
22 | 689 | 689 | ||
24 | 690 | return self.run(**all_cmd_args) | 690 | try: |
25 | 691 | return self.run(**all_cmd_args) | ||
26 | 692 | finally: | ||
27 | 693 | # reset it, so that other commands run in the same process won't | ||
28 | 694 | # inherit state | ||
29 | 695 | trace.set_verbosity_level(0) | ||
30 | 691 | 696 | ||
31 | 692 | def _setup_run(self): | 697 | def _setup_run(self): |
32 | 693 | """Wrap the defined run method on self with a cleanup. | 698 | """Wrap the defined run method on self with a cleanup. |
33 | 694 | 699 | ||
34 | === modified file 'bzrlib/tests/__init__.py' | |||
35 | --- bzrlib/tests/__init__.py 2010-10-08 01:43:13 +0000 | |||
36 | +++ bzrlib/tests/__init__.py 2010-10-08 06:36:46 +0000 | |||
37 | @@ -858,6 +858,10 @@ | |||
38 | 858 | self._track_transports() | 858 | self._track_transports() |
39 | 859 | self._track_locks() | 859 | self._track_locks() |
40 | 860 | self._clear_debug_flags() | 860 | self._clear_debug_flags() |
41 | 861 | # Isolate global verbosity level, to make sure it's reproducible | ||
42 | 862 | # between tests. We should get rid of this altogether: bug 656694. -- | ||
43 | 863 | # mbp 20101008 | ||
44 | 864 | self.overrideAttr(bzrlib.trace, '_verbosity_level', 0) | ||
45 | 861 | 865 | ||
46 | 862 | def debug(self): | 866 | def debug(self): |
47 | 863 | # debug a frame up. | 867 | # debug a frame up. |
48 | 864 | 868 | ||
49 | === modified file 'bzrlib/tests/blackbox/test_bound_branches.py' | |||
50 | --- bzrlib/tests/blackbox/test_bound_branches.py 2010-05-02 20:10:25 +0000 | |||
51 | +++ bzrlib/tests/blackbox/test_bound_branches.py 2010-10-08 06:36:46 +0000 | |||
52 | @@ -443,7 +443,9 @@ | |||
53 | 443 | def test_bind_when_bound(self): | 443 | def test_bind_when_bound(self): |
54 | 444 | self.run_script(""" | 444 | self.run_script(""" |
55 | 445 | $ bzr init trunk | 445 | $ bzr init trunk |
56 | 446 | ... | ||
57 | 446 | $ bzr init copy | 447 | $ bzr init copy |
58 | 448 | ... | ||
59 | 447 | $ cd copy | 449 | $ cd copy |
60 | 448 | $ bzr bind ../trunk | 450 | $ bzr bind ../trunk |
61 | 449 | $ bzr bind | 451 | $ bzr bind |
62 | @@ -453,6 +455,7 @@ | |||
63 | 453 | def test_bind_before_bound(self): | 455 | def test_bind_before_bound(self): |
64 | 454 | self.run_script(""" | 456 | self.run_script(""" |
65 | 455 | $ bzr init trunk | 457 | $ bzr init trunk |
66 | 458 | ... | ||
67 | 456 | $ cd trunk | 459 | $ cd trunk |
68 | 457 | $ bzr bind | 460 | $ bzr bind |
69 | 458 | 2>bzr: ERROR: No location supplied and no previous location known | 461 | 2>bzr: ERROR: No location supplied and no previous location known |
70 | 459 | 462 | ||
71 | === modified file 'bzrlib/tests/blackbox/test_dpush.py' | |||
72 | --- bzrlib/tests/blackbox/test_dpush.py 2010-06-23 08:19:28 +0000 | |||
73 | +++ bzrlib/tests/blackbox/test_dpush.py 2010-10-08 06:36:46 +0000 | |||
74 | @@ -104,6 +104,7 @@ | |||
75 | 104 | 104 | ||
76 | 105 | script.run_script(self, ''' | 105 | script.run_script(self, ''' |
77 | 106 | $ bzr dpush -d dc d | 106 | $ bzr dpush -d dc d |
78 | 107 | 2>Pushed up to revision 2. | ||
79 | 107 | $ bzr revno dc | 108 | $ bzr revno dc |
80 | 108 | 2 | 109 | 2 |
81 | 109 | $ bzr status dc | 110 | $ bzr status dc |
82 | @@ -121,6 +122,7 @@ | |||
83 | 121 | self.build_tree_contents([("dc/foofile", "blaaaal")]) | 122 | self.build_tree_contents([("dc/foofile", "blaaaal")]) |
84 | 122 | script.run_script(self, ''' | 123 | script.run_script(self, ''' |
85 | 123 | $ bzr dpush -d dc d --no-strict | 124 | $ bzr dpush -d dc d --no-strict |
86 | 125 | 2>Pushed up to revision 2. | ||
87 | 124 | ''') | 126 | ''') |
88 | 125 | self.assertFileEqual("blaaaal", "dc/foofile") | 127 | self.assertFileEqual("blaaaal", "dc/foofile") |
89 | 126 | # if the dummy vcs wasn't that dummy we could uncomment the line below | 128 | # if the dummy vcs wasn't that dummy we could uncomment the line below |
90 | 127 | 129 | ||
91 | === modified file 'bzrlib/tests/blackbox/test_shelve.py' | |||
92 | --- bzrlib/tests/blackbox/test_shelve.py 2010-09-29 12:58:17 +0000 | |||
93 | +++ bzrlib/tests/blackbox/test_shelve.py 2010-10-08 06:36:46 +0000 | |||
94 | @@ -77,10 +77,18 @@ | |||
95 | 77 | sr = ScriptRunner() | 77 | sr = ScriptRunner() |
96 | 78 | sr.run_script(self, ''' | 78 | sr.run_script(self, ''' |
97 | 79 | $ bzr add file | 79 | $ bzr add file |
98 | 80 | adding file | ||
99 | 80 | $ bzr shelve --all -m Foo | 81 | $ bzr shelve --all -m Foo |
100 | 82 | 2>Selected changes: | ||
101 | 83 | 2>-D file | ||
102 | 84 | 2>Changes shelved with id "1". | ||
103 | 81 | $ bzr shelve --list | 85 | $ bzr shelve --list |
104 | 82 | 1: Foo | 86 | 1: Foo |
105 | 83 | $ bzr unshelve --keep | 87 | $ bzr unshelve --keep |
106 | 88 | 2>Using changes with id "1". | ||
107 | 89 | 2>Message: Foo | ||
108 | 90 | 2>+N file | ||
109 | 91 | 2>All changes applied successfully. | ||
110 | 84 | $ bzr shelve --list | 92 | $ bzr shelve --list |
111 | 85 | 1: Foo | 93 | 1: Foo |
112 | 86 | $ cat file | 94 | $ cat file |
113 | 87 | 95 | ||
114 | === modified file 'bzrlib/tests/script.py' | |||
115 | --- bzrlib/tests/script.py 2010-09-13 08:14:44 +0000 | |||
116 | +++ bzrlib/tests/script.py 2010-10-08 06:36:46 +0000 | |||
117 | @@ -221,20 +221,30 @@ | |||
118 | 221 | retcode, actual_output, actual_error = method(test_case, | 221 | retcode, actual_output, actual_error = method(test_case, |
119 | 222 | str_input, args) | 222 | str_input, args) |
120 | 223 | 223 | ||
123 | 224 | self._check_output(output, actual_output, test_case) | 224 | try: |
124 | 225 | self._check_output(error, actual_error, test_case) | 225 | self._check_output(output, actual_output, test_case) |
125 | 226 | except AssertionError, e: | ||
126 | 227 | raise AssertionError(str(e) + " in stdout of command %s" % cmd) | ||
127 | 228 | try: | ||
128 | 229 | self._check_output(error, actual_error, test_case) | ||
129 | 230 | except AssertionError, e: | ||
130 | 231 | raise AssertionError(str(e) + | ||
131 | 232 | " in stderr of running command %s" % cmd) | ||
132 | 226 | if retcode and not error and actual_error: | 233 | if retcode and not error and actual_error: |
133 | 227 | test_case.fail('In \n\t%s\nUnexpected error: %s' | 234 | test_case.fail('In \n\t%s\nUnexpected error: %s' |
134 | 228 | % (' '.join(cmd), actual_error)) | 235 | % (' '.join(cmd), actual_error)) |
135 | 229 | return retcode, actual_output, actual_error | 236 | return retcode, actual_output, actual_error |
136 | 230 | 237 | ||
137 | 231 | def _check_output(self, expected, actual, test_case): | 238 | def _check_output(self, expected, actual, test_case): |
144 | 232 | if expected is None: | 239 | if not actual: |
145 | 233 | # Specifying None means: any output is accepted | 240 | if expected is None: |
146 | 234 | return | 241 | return |
147 | 235 | if actual is None: | 242 | elif expected == '...\n': |
148 | 236 | test_case.fail('We expected output: %r, but found None' | 243 | return |
149 | 237 | % (expected,)) | 244 | else: |
150 | 245 | test_case.fail('expected output: %r, but found nothing' | ||
151 | 246 | % (expected,)) | ||
152 | 247 | expected = expected or '' | ||
153 | 238 | matching = self.output_checker.check_output( | 248 | matching = self.output_checker.check_output( |
154 | 239 | expected, actual, self.check_options) | 249 | expected, actual, self.check_options) |
155 | 240 | if not matching: | 250 | if not matching: |
156 | 241 | 251 | ||
157 | === modified file 'bzrlib/tests/test_conflicts.py' | |||
158 | --- bzrlib/tests/test_conflicts.py 2010-04-06 10:12:42 +0000 | |||
159 | +++ bzrlib/tests/test_conflicts.py 2010-10-08 06:36:46 +0000 | |||
160 | @@ -625,20 +625,18 @@ | |||
161 | 625 | # tests MissingParent resolution :-/ | 625 | # tests MissingParent resolution :-/ |
162 | 626 | preamble = """ | 626 | preamble = """ |
163 | 627 | $ bzr init trunk | 627 | $ bzr init trunk |
164 | 628 | ... | ||
165 | 628 | $ cd trunk | 629 | $ cd trunk |
166 | 629 | $ mkdir dir | 630 | $ mkdir dir |
170 | 630 | $ bzr add dir | 631 | $ bzr add -q dir |
171 | 631 | $ bzr commit -m 'Create trunk' | 632 | $ bzr commit -m 'Create trunk' -q |
169 | 632 | |||
172 | 633 | $ echo 'trunk content' >dir/file | 633 | $ echo 'trunk content' >dir/file |
177 | 634 | $ bzr add dir/file | 634 | $ bzr add -q dir/file |
178 | 635 | $ bzr commit -m 'Add dir/file in trunk' | 635 | $ bzr commit -q -m 'Add dir/file in trunk' |
179 | 636 | 636 | $ bzr branch -q . -r 1 ../branch | |
176 | 637 | $ bzr branch . -r 1 ../branch | ||
180 | 638 | $ cd ../branch | 637 | $ cd ../branch |
184 | 639 | $ bzr rm dir | 638 | $ bzr rm dir -q |
185 | 640 | $ bzr commit -m 'Remove dir in branch' | 639 | $ bzr commit -q -m 'Remove dir in branch' |
183 | 641 | |||
186 | 642 | $ bzr merge ../trunk | 640 | $ bzr merge ../trunk |
187 | 643 | 2>+N dir/ | 641 | 2>+N dir/ |
188 | 644 | 2>+N dir/file | 642 | 2>+N dir/file |
189 | @@ -649,15 +647,15 @@ | |||
190 | 649 | 647 | ||
191 | 650 | def test_take_this(self): | 648 | def test_take_this(self): |
192 | 651 | self.run_script(""" | 649 | self.run_script(""" |
194 | 652 | $ bzr rm dir --force | 650 | $ bzr rm -q dir --force |
195 | 653 | $ bzr resolve dir | 651 | $ bzr resolve dir |
197 | 654 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 652 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
198 | 655 | """) | 653 | """) |
199 | 656 | 654 | ||
200 | 657 | def test_take_other(self): | 655 | def test_take_other(self): |
201 | 658 | self.run_script(""" | 656 | self.run_script(""" |
202 | 659 | $ bzr resolve dir | 657 | $ bzr resolve dir |
204 | 660 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 658 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
205 | 661 | """) | 659 | """) |
206 | 662 | 660 | ||
207 | 663 | 661 | ||
208 | @@ -665,22 +663,20 @@ | |||
209 | 665 | 663 | ||
210 | 666 | preamble = """ | 664 | preamble = """ |
211 | 667 | $ bzr init trunk | 665 | $ bzr init trunk |
212 | 666 | ... | ||
213 | 668 | $ cd trunk | 667 | $ cd trunk |
214 | 669 | $ mkdir dir | 668 | $ mkdir dir |
215 | 670 | $ echo 'trunk content' >dir/file | 669 | $ echo 'trunk content' >dir/file |
219 | 671 | $ bzr add | 670 | $ bzr add -q |
220 | 672 | $ bzr commit -m 'Create trunk' | 671 | $ bzr commit -m 'Create trunk' -q |
218 | 673 | |||
221 | 674 | $ echo 'trunk content' >dir/file2 | 672 | $ echo 'trunk content' >dir/file2 |
226 | 675 | $ bzr add dir/file2 | 673 | $ bzr add -q dir/file2 |
227 | 676 | $ bzr commit -m 'Add dir/file2 in branch' | 674 | $ bzr commit -q -m 'Add dir/file2 in branch' |
228 | 677 | 675 | $ bzr branch -q . -r 1 ../branch | |
225 | 678 | $ bzr branch . -r 1 ../branch | ||
229 | 679 | $ cd ../branch | 676 | $ cd ../branch |
234 | 680 | $ bzr rm dir/file --force | 677 | $ bzr rm -q dir/file --force |
235 | 681 | $ bzr rm dir | 678 | $ bzr rm -q dir |
236 | 682 | $ bzr commit -m 'Remove dir/file' | 679 | $ bzr commit -q -m 'Remove dir/file' |
233 | 683 | |||
237 | 684 | $ bzr merge ../trunk | 680 | $ bzr merge ../trunk |
238 | 685 | 2>+N dir/ | 681 | 2>+N dir/ |
239 | 686 | 2>+N dir/file2 | 682 | 2>+N dir/file2 |
240 | @@ -692,34 +688,36 @@ | |||
241 | 692 | def test_keep_them_all(self): | 688 | def test_keep_them_all(self): |
242 | 693 | self.run_script(""" | 689 | self.run_script(""" |
243 | 694 | $ bzr resolve dir | 690 | $ bzr resolve dir |
245 | 695 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 691 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
246 | 696 | """) | 692 | """) |
247 | 697 | 693 | ||
248 | 698 | def test_adopt_child(self): | 694 | def test_adopt_child(self): |
249 | 699 | self.run_script(""" | 695 | self.run_script(""" |
252 | 700 | $ bzr mv dir/file2 file2 | 696 | $ bzr mv -q dir/file2 file2 |
253 | 701 | $ bzr rm dir --force | 697 | $ bzr rm -q dir --force |
254 | 702 | $ bzr resolve dir | 698 | $ bzr resolve dir |
256 | 703 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 699 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
257 | 704 | """) | 700 | """) |
258 | 705 | 701 | ||
259 | 706 | def test_kill_them_all(self): | 702 | def test_kill_them_all(self): |
260 | 707 | self.run_script(""" | 703 | self.run_script(""" |
262 | 708 | $ bzr rm dir --force | 704 | $ bzr rm -q dir --force |
263 | 709 | $ bzr resolve dir | 705 | $ bzr resolve dir |
265 | 710 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 706 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
266 | 711 | """) | 707 | """) |
267 | 712 | 708 | ||
268 | 713 | def test_resolve_taking_this(self): | 709 | def test_resolve_taking_this(self): |
269 | 714 | self.run_script(""" | 710 | self.run_script(""" |
270 | 715 | $ bzr resolve --take-this dir | 711 | $ bzr resolve --take-this dir |
272 | 716 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 712 | 2>... |
273 | 713 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' | ||
274 | 717 | """) | 714 | """) |
275 | 718 | 715 | ||
276 | 719 | def test_resolve_taking_other(self): | 716 | def test_resolve_taking_other(self): |
277 | 720 | self.run_script(""" | 717 | self.run_script(""" |
278 | 721 | $ bzr resolve --take-other dir | 718 | $ bzr resolve --take-other dir |
280 | 722 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 719 | 2>... |
281 | 720 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' | ||
282 | 723 | """) | 721 | """) |
283 | 724 | 722 | ||
284 | 725 | 723 | ||
285 | @@ -727,22 +725,20 @@ | |||
286 | 727 | 725 | ||
287 | 728 | preamble = """ | 726 | preamble = """ |
288 | 729 | $ bzr init trunk | 727 | $ bzr init trunk |
289 | 728 | ... | ||
290 | 730 | $ cd trunk | 729 | $ cd trunk |
291 | 731 | $ mkdir dir | 730 | $ mkdir dir |
292 | 732 | $ echo 'trunk content' >dir/file | 731 | $ echo 'trunk content' >dir/file |
301 | 733 | $ bzr add | 732 | $ bzr add -q |
302 | 734 | $ bzr commit -m 'Create trunk' | 733 | $ bzr commit -m 'Create trunk' -q |
303 | 735 | 734 | $ bzr rm -q dir/file --force | |
304 | 736 | $ bzr rm dir/file --force | 735 | $ bzr rm -q dir --force |
305 | 737 | $ bzr rm dir --force | 736 | $ bzr commit -q -m 'Remove dir/file' |
306 | 738 | $ bzr commit -m 'Remove dir/file' | 737 | $ bzr branch -q . -r 1 ../branch |
299 | 739 | |||
300 | 740 | $ bzr branch . -r 1 ../branch | ||
307 | 741 | $ cd ../branch | 738 | $ cd ../branch |
308 | 742 | $ echo 'branch content' >dir/file2 | 739 | $ echo 'branch content' >dir/file2 |
312 | 743 | $ bzr add dir/file2 | 740 | $ bzr add -q dir/file2 |
313 | 744 | $ bzr commit -m 'Add dir/file2 in branch' | 741 | $ bzr commit -q -m 'Add dir/file2 in branch' |
311 | 745 | |||
314 | 746 | $ bzr merge ../trunk | 742 | $ bzr merge ../trunk |
315 | 747 | 2>-D dir/file | 743 | 2>-D dir/file |
316 | 748 | 2>Conflict: can't delete dir because it is not empty. Not deleting. | 744 | 2>Conflict: can't delete dir because it is not empty. Not deleting. |
317 | @@ -753,34 +749,36 @@ | |||
318 | 753 | def test_keep_them_all(self): | 749 | def test_keep_them_all(self): |
319 | 754 | self.run_script(""" | 750 | self.run_script(""" |
320 | 755 | $ bzr resolve dir | 751 | $ bzr resolve dir |
322 | 756 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 752 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
323 | 757 | """) | 753 | """) |
324 | 758 | 754 | ||
325 | 759 | def test_adopt_child(self): | 755 | def test_adopt_child(self): |
326 | 760 | self.run_script(""" | 756 | self.run_script(""" |
329 | 761 | $ bzr mv dir/file2 file2 | 757 | $ bzr mv -q dir/file2 file2 |
330 | 762 | $ bzr rm dir --force | 758 | $ bzr rm -q dir --force |
331 | 763 | $ bzr resolve dir | 759 | $ bzr resolve dir |
333 | 764 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 760 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
334 | 765 | """) | 761 | """) |
335 | 766 | 762 | ||
336 | 767 | def test_kill_them_all(self): | 763 | def test_kill_them_all(self): |
337 | 768 | self.run_script(""" | 764 | self.run_script(""" |
339 | 769 | $ bzr rm dir --force | 765 | $ bzr rm -q dir --force |
340 | 770 | $ bzr resolve dir | 766 | $ bzr resolve dir |
342 | 771 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 767 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
343 | 772 | """) | 768 | """) |
344 | 773 | 769 | ||
345 | 774 | def test_resolve_taking_this(self): | 770 | def test_resolve_taking_this(self): |
346 | 775 | self.run_script(""" | 771 | self.run_script(""" |
347 | 776 | $ bzr resolve --take-this dir | 772 | $ bzr resolve --take-this dir |
349 | 777 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 773 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
350 | 778 | """) | 774 | """) |
351 | 779 | 775 | ||
352 | 780 | def test_resolve_taking_other(self): | 776 | def test_resolve_taking_other(self): |
353 | 781 | self.run_script(""" | 777 | self.run_script(""" |
354 | 782 | $ bzr resolve --take-other dir | 778 | $ bzr resolve --take-other dir |
356 | 783 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 779 | 2>deleted dir/file2 |
357 | 780 | 2>deleted dir | ||
358 | 781 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' | ||
359 | 784 | """) | 782 | """) |
360 | 785 | 783 | ||
361 | 786 | 784 | ||
362 | @@ -882,19 +880,19 @@ | |||
363 | 882 | 880 | ||
364 | 883 | preamble = """ | 881 | preamble = """ |
365 | 884 | $ bzr init trunk | 882 | $ bzr init trunk |
366 | 883 | ... | ||
367 | 885 | $ cd trunk | 884 | $ cd trunk |
368 | 886 | $ bzr mkdir foo | 885 | $ bzr mkdir foo |
370 | 887 | $ bzr commit -m 'Create trunk' | 886 | ... |
371 | 887 | $ bzr commit -m 'Create trunk' -q | ||
372 | 888 | $ echo "Boing" >foo/bar | 888 | $ echo "Boing" >foo/bar |
377 | 889 | $ bzr add foo/bar | 889 | $ bzr add -q foo/bar |
378 | 890 | $ bzr commit -m 'Add foo/bar' | 890 | $ bzr commit -q -m 'Add foo/bar' |
379 | 891 | 891 | $ bzr branch -q . -r 1 ../branch | |
376 | 892 | $ bzr branch . -r 1 ../branch | ||
380 | 893 | $ cd ../branch | 892 | $ cd ../branch |
381 | 894 | $ rm -r foo | 893 | $ rm -r foo |
382 | 895 | $ echo "Boo!" >foo | 894 | $ echo "Boo!" >foo |
385 | 896 | $ bzr commit -m 'foo is now a file' | 895 | $ bzr commit -q -m 'foo is now a file' |
384 | 897 | |||
386 | 898 | $ bzr merge ../trunk | 896 | $ bzr merge ../trunk |
387 | 899 | 2>+N foo.new/bar | 897 | 2>+N foo.new/bar |
388 | 900 | 2>RK foo => foo.new/ | 898 | 2>RK foo => foo.new/ |
389 | @@ -906,32 +904,34 @@ | |||
390 | 906 | 904 | ||
391 | 907 | def test_take_this(self): | 905 | def test_take_this(self): |
392 | 908 | self.run_script(""" | 906 | self.run_script(""" |
394 | 909 | $ bzr rm foo.new --force | 907 | $ bzr rm -q foo.new --force |
395 | 910 | # FIXME: Isn't it weird that foo is now unkown even if foo.new has been put | 908 | # FIXME: Isn't it weird that foo is now unkown even if foo.new has been put |
396 | 911 | # aside ? -- vila 090916 | 909 | # aside ? -- vila 090916 |
398 | 912 | $ bzr add foo | 910 | $ bzr add -q foo |
399 | 913 | $ bzr resolve foo.new | 911 | $ bzr resolve foo.new |
401 | 914 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 912 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
402 | 915 | """) | 913 | """) |
403 | 916 | 914 | ||
404 | 917 | def test_take_other(self): | 915 | def test_take_other(self): |
405 | 918 | self.run_script(""" | 916 | self.run_script(""" |
408 | 919 | $ bzr rm foo --force | 917 | $ bzr rm -q foo --force |
409 | 920 | $ bzr mv foo.new foo | 918 | $ bzr mv -q foo.new foo |
410 | 921 | $ bzr resolve foo | 919 | $ bzr resolve foo |
412 | 922 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 920 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' |
413 | 923 | """) | 921 | """) |
414 | 924 | 922 | ||
415 | 925 | def test_resolve_taking_this(self): | 923 | def test_resolve_taking_this(self): |
416 | 926 | self.run_script(""" | 924 | self.run_script(""" |
417 | 927 | $ bzr resolve --take-this foo.new | 925 | $ bzr resolve --take-this foo.new |
419 | 928 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 926 | 2>... |
420 | 927 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' | ||
421 | 929 | """) | 928 | """) |
422 | 930 | 929 | ||
423 | 931 | def test_resolve_taking_other(self): | 930 | def test_resolve_taking_other(self): |
424 | 932 | self.run_script(""" | 931 | self.run_script(""" |
425 | 933 | $ bzr resolve --take-other foo.new | 932 | $ bzr resolve --take-other foo.new |
427 | 934 | $ bzr commit --strict -m 'No more conflicts nor unknown files' | 933 | 2>... |
428 | 934 | $ bzr commit -q --strict -m 'No more conflicts nor unknown files' | ||
429 | 935 | """) | 935 | """) |
430 | 936 | 936 | ||
431 | 937 | 937 | ||
432 | @@ -943,19 +943,19 @@ | |||
433 | 943 | # conflict. | 943 | # conflict. |
434 | 944 | self.run_script(""" | 944 | self.run_script(""" |
435 | 945 | $ bzr init trunk | 945 | $ bzr init trunk |
436 | 946 | ... | ||
437 | 946 | $ cd trunk | 947 | $ cd trunk |
438 | 947 | $ bzr mkdir foo | 948 | $ bzr mkdir foo |
440 | 948 | $ bzr commit -m 'Create trunk' | 949 | ... |
441 | 950 | $ bzr commit -m 'Create trunk' -q | ||
442 | 949 | $ rm -r foo | 951 | $ rm -r foo |
443 | 950 | $ echo "Boo!" >foo | 952 | $ echo "Boo!" >foo |
447 | 951 | $ bzr commit -m 'foo is now a file' | 953 | $ bzr commit -m 'foo is now a file' -q |
448 | 952 | 954 | $ bzr branch -q . -r 1 ../branch -q | |
446 | 953 | $ bzr branch . -r 1 ../branch | ||
449 | 954 | $ cd ../branch | 955 | $ cd ../branch |
450 | 955 | $ echo "Boing" >foo/bar | 956 | $ echo "Boing" >foo/bar |
454 | 956 | $ bzr add foo/bar | 957 | $ bzr add -q foo/bar -q |
455 | 957 | $ bzr commit -m 'Add foo/bar' | 958 | $ bzr commit -m 'Add foo/bar' -q |
453 | 958 | |||
456 | 959 | $ bzr merge ../trunk | 959 | $ bzr merge ../trunk |
457 | 960 | 2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')] | 960 | 2>bzr: ERROR: Tree transform is malformed [('unversioned executability', 'new-1')] |
458 | 961 | """) | 961 | """) |
459 | 962 | 962 | ||
460 | === modified file 'bzrlib/tests/test_delta.py' | |||
461 | --- bzrlib/tests/test_delta.py 2010-04-26 16:59:56 +0000 | |||
462 | +++ bzrlib/tests/test_delta.py 2010-10-08 06:36:46 +0000 | |||
463 | @@ -65,8 +65,7 @@ | |||
464 | 65 | reporter.report(file_id, (old_path, path), versioned_change, renamed, | 65 | reporter.report(file_id, (old_path, path), versioned_change, renamed, |
465 | 66 | modified, exe_change, kind) | 66 | modified, exe_change, kind) |
466 | 67 | if expected_lines is not None: | 67 | if expected_lines is not None: |
469 | 68 | for i in range(len(expected_lines)): | 68 | self.assertEqualDiff('\n'.join(expected_lines), '\n'.join(result)) |
468 | 69 | self.assertEqualDiff(expected_lines[i], result[i]) | ||
470 | 70 | else: | 69 | else: |
471 | 71 | self.assertEqual([], result) | 70 | self.assertEqual([], result) |
472 | 72 | 71 | ||
473 | 73 | 72 | ||
474 | === modified file 'bzrlib/tests/test_script.py' | |||
475 | --- bzrlib/tests/test_script.py 2010-09-13 09:00:03 +0000 | |||
476 | +++ bzrlib/tests/test_script.py 2010-10-08 06:36:46 +0000 | |||
477 | @@ -19,6 +19,7 @@ | |||
478 | 19 | commands, | 19 | commands, |
479 | 20 | osutils, | 20 | osutils, |
480 | 21 | tests, | 21 | tests, |
481 | 22 | trace, | ||
482 | 22 | ui, | 23 | ui, |
483 | 23 | ) | 24 | ) |
484 | 24 | from bzrlib.tests import script | 25 | from bzrlib.tests import script |
485 | @@ -162,6 +163,31 @@ | |||
486 | 162 | def test_unknown_command(self): | 163 | def test_unknown_command(self): |
487 | 163 | self.assertRaises(SyntaxError, self.run_script, 'foo') | 164 | self.assertRaises(SyntaxError, self.run_script, 'foo') |
488 | 164 | 165 | ||
489 | 166 | def test_blank_output_mismatches_output(self): | ||
490 | 167 | """If you give output, the output must actually be blank. | ||
491 | 168 | |||
492 | 169 | See <https://bugs.launchpad.net/bzr/+bug/637830>: previously blank | ||
493 | 170 | output was a wildcard. Now you must say ... if you want that. | ||
494 | 171 | """ | ||
495 | 172 | self.assertRaises(AssertionError, | ||
496 | 173 | self.run_script, | ||
497 | 174 | """ | ||
498 | 175 | $ echo foo | ||
499 | 176 | """) | ||
500 | 177 | |||
501 | 178 | def test_ellipsis_everything(self): | ||
502 | 179 | """A simple ellipsis matches everything.""" | ||
503 | 180 | self.run_script(""" | ||
504 | 181 | $ echo foo | ||
505 | 182 | ... | ||
506 | 183 | """) | ||
507 | 184 | |||
508 | 185 | def test_ellipsis_matches_empty(self): | ||
509 | 186 | self.run_script(""" | ||
510 | 187 | $ cd . | ||
511 | 188 | ... | ||
512 | 189 | """) | ||
513 | 190 | |||
514 | 165 | def test_stops_on_unexpected_output(self): | 191 | def test_stops_on_unexpected_output(self): |
515 | 166 | story = """ | 192 | story = """ |
516 | 167 | $ mkdir dir | 193 | $ mkdir dir |
517 | @@ -170,7 +196,6 @@ | |||
518 | 170 | """ | 196 | """ |
519 | 171 | self.assertRaises(AssertionError, self.run_script, story) | 197 | self.assertRaises(AssertionError, self.run_script, story) |
520 | 172 | 198 | ||
521 | 173 | |||
522 | 174 | def test_stops_on_unexpected_error(self): | 199 | def test_stops_on_unexpected_error(self): |
523 | 175 | story = """ | 200 | story = """ |
524 | 176 | $ cat | 201 | $ cat |
525 | @@ -190,10 +215,13 @@ | |||
526 | 190 | # The status matters, not the output | 215 | # The status matters, not the output |
527 | 191 | story = """ | 216 | story = """ |
528 | 192 | $ bzr init | 217 | $ bzr init |
529 | 218 | ... | ||
530 | 193 | $ cat >file | 219 | $ cat >file |
531 | 194 | <Hello | 220 | <Hello |
532 | 195 | $ bzr add file | 221 | $ bzr add file |
533 | 222 | ... | ||
534 | 196 | $ bzr commit -m 'adding file' | 223 | $ bzr commit -m 'adding file' |
535 | 224 | 2>... | ||
536 | 197 | """ | 225 | """ |
537 | 198 | self.run_script(story) | 226 | self.run_script(story) |
538 | 199 | 227 | ||
539 | @@ -245,6 +273,15 @@ | |||
540 | 245 | cat dog "chicken" 'dragon' | 273 | cat dog "chicken" 'dragon' |
541 | 246 | """) | 274 | """) |
542 | 247 | 275 | ||
543 | 276 | def test_verbosity_isolated(self): | ||
544 | 277 | """Global verbosity is isolated from commands run in scripts. | ||
545 | 278 | """ | ||
546 | 279 | # see also 656694; we should get rid of global verbosity | ||
547 | 280 | self.run_script(""" | ||
548 | 281 | $ bzr init --quiet a | ||
549 | 282 | """) | ||
550 | 283 | self.assertEquals(trace.is_quiet(), False) | ||
551 | 284 | |||
552 | 248 | 285 | ||
553 | 249 | class TestCat(script.TestCaseWithTransportAndScript): | 286 | class TestCat(script.TestCaseWithTransportAndScript): |
554 | 250 | 287 | ||
555 | @@ -356,7 +393,10 @@ | |||
556 | 356 | class TestBzr(script.TestCaseWithTransportAndScript): | 393 | class TestBzr(script.TestCaseWithTransportAndScript): |
557 | 357 | 394 | ||
558 | 358 | def test_bzr_smoke(self): | 395 | def test_bzr_smoke(self): |
560 | 359 | self.run_script('$ bzr init branch') | 396 | self.run_script(""" |
561 | 397 | $ bzr init branch | ||
562 | 398 | Created a standalone tree (format: ...) | ||
563 | 399 | """) | ||
564 | 360 | self.failUnlessExists('branch') | 400 | self.failUnlessExists('branch') |
565 | 361 | 401 | ||
566 | 362 | 402 | ||
567 | 363 | 403 | ||
568 | === modified file 'doc/developers/testing.txt' | |||
569 | --- doc/developers/testing.txt 2010-09-23 09:54:51 +0000 | |||
570 | +++ doc/developers/testing.txt 2010-10-08 06:36:46 +0000 | |||
571 | @@ -388,6 +388,12 @@ | |||
572 | 388 | If you want the command to succeed for any output, just use:: | 388 | If you want the command to succeed for any output, just use:: |
573 | 389 | 389 | ||
574 | 390 | $ bzr add file | 390 | $ bzr add file |
575 | 391 | ... | ||
576 | 392 | 2>... | ||
577 | 393 | |||
578 | 394 | or use the ``--quiet`` option:: | ||
579 | 395 | |||
580 | 396 | $ bzr add -q file | ||
581 | 391 | 397 | ||
582 | 392 | The following will stop with an error:: | 398 | The following will stop with an error:: |
583 | 393 | 399 |
I agree, having the test writer think about -q and '...' sounds like a good plan.
The only drawback I could think of is that it will require a bit more expertise
than a mere copy/paste. No big loss here, I'm still waiting for bug reporters to
do that anyway :-D
127 - test_case. assertEqualDiff (expected, actual) assertEquals( expected, actual)
128 + test_case.
Why ??? EqualDiff provides valuable info, please don't remove that !