2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2005, 2006 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
||
18 |
"""Black-box tests for bzr diff.
|
|
19 |
"""
|
|
20 |
||
21 |
import os |
|
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
22 |
import re |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
23 |
|
24 |
import bzrlib |
|
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
25 |
from bzrlib import workingtree |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
26 |
from bzrlib.branch import Branch |
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
27 |
from bzrlib.tests import TestSkipped |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
28 |
from bzrlib.tests.blackbox import ExternalBase |
29 |
||
30 |
||
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
31 |
def subst_dates(string): |
32 |
"""Replace date strings with constant values."""
|
|
33 |
return re.sub(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-\+]\d{4}', |
|
34 |
'YYYY-MM-DD HH:MM:SS +ZZZZ', string) |
|
35 |
||
36 |
||
2172.2.1
by Alexander Belchenko
Remove unnecessary duplication of tests in blackbox/test_diff.py |
37 |
class DiffBase(ExternalBase): |
38 |
"""Base class with common setup method"""
|
|
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
39 |
|
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
40 |
def make_example_branch(self): |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
41 |
# FIXME: copied from test_too_much -- share elsewhere?
|
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
42 |
tree = self.make_branch_and_tree('.') |
43 |
open('hello', 'wb').write('foo\n') |
|
44 |
tree.add(['hello']) |
|
45 |
tree.commit('setup') |
|
46 |
open('goodbye', 'wb').write('baz\n') |
|
47 |
tree.add(['goodbye']) |
|
48 |
tree.commit('setup') |
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
49 |
|
2172.2.1
by Alexander Belchenko
Remove unnecessary duplication of tests in blackbox/test_diff.py |
50 |
|
51 |
class TestDiff(DiffBase): |
|
52 |
||
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
53 |
def test_diff(self): |
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
54 |
self.make_example_branch() |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
55 |
file('hello', 'wt').write('hello world!') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
56 |
self.run_bzr('commit -m fixing hello') |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
57 |
output = self.run_bzr('diff -r 2..3', retcode=1)[0] |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
58 |
self.assert_('\n+hello world!' in output) |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
59 |
output = self.run_bzr('diff -r last:3..last:1', |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
60 |
retcode=1)[0] |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
61 |
self.assert_('\n+baz' in output) |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
62 |
self.build_tree(['moo']) |
63 |
self.run_bzr('add moo') |
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
64 |
os.unlink('moo') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
65 |
self.run_bzr('diff') |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
66 |
|
1694.2.2
by Martin Pool
Add test for diff --diff-prefix, which was previously untested. |
67 |
def test_diff_prefix(self): |
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
68 |
"""diff --prefix appends to filenames in output"""
|
69 |
self.make_example_branch() |
|
1711.7.14
by John Arbash Meinel
diff tests check exact texts, should use binary mode for files. |
70 |
file('hello', 'wb').write('hello world!\n') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
71 |
out, err = self.run_bzr('diff --prefix old/:new/', retcode=1) |
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
72 |
self.assertEquals(err, '') |
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
73 |
self.assertEqualDiff(subst_dates(out), '''\ |
1694.2.4
by Martin Pool
When a diff prefix is given, don't show it in === summary lines, only on the diffs themselves. |
74 |
=== modified file 'hello'
|
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
75 |
--- old/hello\tYYYY-MM-DD HH:MM:SS +ZZZZ |
76 |
+++ new/hello\tYYYY-MM-DD HH:MM:SS +ZZZZ |
|
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
77 |
@@ -1,1 +1,1 @@
|
78 |
-foo
|
|
79 |
+hello world!
|
|
80 |
||
81 |
''') |
|
82 |
||
2324.1.2
by Dmitry Vasiliev
Added test for bzr diff --prefix illegal_value |
83 |
def test_diff_illegal_prefix_value(self): |
84 |
# There was an error in error reporting for this option
|
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
85 |
out, err = self.run_bzr('diff --prefix old/', retcode=3) |
2324.1.2
by Dmitry Vasiliev
Added test for bzr diff --prefix illegal_value |
86 |
self.assertContainsRe(err, |
87 |
'--prefix expects two values separated by a colon') |
|
88 |
||
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
89 |
def test_diff_p1(self): |
90 |
"""diff -p1 produces lkml-style diffs"""
|
|
91 |
self.make_example_branch() |
|
1711.7.14
by John Arbash Meinel
diff tests check exact texts, should use binary mode for files. |
92 |
file('hello', 'wb').write('hello world!\n') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
93 |
out, err = self.run_bzr('diff -p1', retcode=1) |
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
94 |
self.assertEquals(err, '') |
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
95 |
self.assertEqualDiff(subst_dates(out), '''\ |
1694.2.4
by Martin Pool
When a diff prefix is given, don't show it in === summary lines, only on the diffs themselves. |
96 |
=== modified file 'hello'
|
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
97 |
--- old/hello\tYYYY-MM-DD HH:MM:SS +ZZZZ |
98 |
+++ new/hello\tYYYY-MM-DD HH:MM:SS +ZZZZ |
|
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
99 |
@@ -1,1 +1,1 @@
|
100 |
-foo
|
|
101 |
+hello world!
|
|
102 |
||
103 |
''') |
|
104 |
||
105 |
def test_diff_p0(self): |
|
106 |
"""diff -p0 produces diffs with no prefix"""
|
|
107 |
self.make_example_branch() |
|
1711.7.14
by John Arbash Meinel
diff tests check exact texts, should use binary mode for files. |
108 |
file('hello', 'wb').write('hello world!\n') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
109 |
out, err = self.run_bzr('diff -p0', retcode=1) |
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
110 |
self.assertEquals(err, '') |
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
111 |
self.assertEqualDiff(subst_dates(out), '''\ |
1694.2.3
by Martin Pool
Add -p0, -p1 options for diff. |
112 |
=== modified file 'hello'
|
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
113 |
--- hello\tYYYY-MM-DD HH:MM:SS +ZZZZ |
114 |
+++ hello\tYYYY-MM-DD HH:MM:SS +ZZZZ |
|
1694.2.2
by Martin Pool
Add test for diff --diff-prefix, which was previously untested. |
115 |
@@ -1,1 +1,1 @@
|
116 |
-foo
|
|
117 |
+hello world!
|
|
118 |
||
119 |
''') |
|
120 |
||
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
121 |
def test_diff_nonexistent(self): |
122 |
# Get an error from a file that does not exist at all
|
|
123 |
# (Malone #3619)
|
|
124 |
self.make_example_branch() |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
125 |
out, err = self.run_bzr('diff does-not-exist', retcode=3) |
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
126 |
self.assertContainsRe(err, 'not versioned.*does-not-exist') |
127 |
||
2197.2.1
by Martin Pool
Refactor cmd_diff |
128 |
def test_diff_illegal_revision_specifiers(self): |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
129 |
out, err = self.run_bzr('diff -r 1..23..123', retcode=3) |
2197.2.1
by Martin Pool
Refactor cmd_diff |
130 |
self.assertContainsRe(err, 'one or two revision specifiers') |
131 |
||
1658.1.10
by Martin Pool
diff on unversiond files should give an error (Malone #3619) |
132 |
def test_diff_unversioned(self): |
133 |
# Get an error when diffing a non-versioned file.
|
|
134 |
# (Malone #3619)
|
|
135 |
self.make_example_branch() |
|
136 |
self.build_tree(['unversioned-file']) |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
137 |
out, err = self.run_bzr('diff unversioned-file', retcode=3) |
1658.1.10
by Martin Pool
diff on unversiond files should give an error (Malone #3619) |
138 |
self.assertContainsRe(err, 'not versioned.*unversioned-file') |
139 |
||
140 |
# TODO: What should diff say for a file deleted in working tree?
|
|
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
141 |
|
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
142 |
def example_branches(self): |
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
143 |
self.build_tree(['branch1/', 'branch1/file'], line_endings='binary') |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
144 |
self.run_bzr(['init', 'branch1'])[0] |
145 |
self.run_bzr(['add', 'branch1/file'])[0] |
|
146 |
self.run_bzr(['commit', '-m', 'add file', 'branch1']) |
|
147 |
self.run_bzr(['branch', 'branch1', 'branch2'])[0] |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
148 |
self.build_tree_contents([('branch2/file', 'new content\n')]) |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
149 |
self.run_bzr(['commit', '-m', 'update file', 'branch2']) |
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
150 |
|
151 |
def test_diff_branches(self): |
|
152 |
self.example_branches() |
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
153 |
# should open branch1 and diff against branch2,
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
154 |
out, err = self.run_bzr(['diff', '-r', 'branch:branch2', |
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
155 |
'branch1'], |
156 |
retcode=1) |
|
157 |
self.assertEquals('', err) |
|
158 |
self.assertEquals("=== modified file 'file'\n" |
|
159 |
"--- file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n" |
|
160 |
"+++ file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n" |
|
161 |
"@@ -1,1 +1,1 @@\n" |
|
162 |
"-new content\n" |
|
163 |
"+contents of branch1/file\n" |
|
164 |
"\n", subst_dates(out)) |
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
165 |
out, err = self.run_bzr(['diff', 'branch2', 'branch1'], |
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
166 |
retcode=1) |
167 |
self.assertEquals('', err) |
|
168 |
self.assertEqualDiff("=== modified file 'file'\n" |
|
169 |
"--- file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n" |
|
170 |
"+++ file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n" |
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
171 |
"@@ -1,1 +1,1 @@\n" |
172 |
"-new content\n" |
|
173 |
"+contents of branch1/file\n" |
|
1740.2.5
by Aaron Bentley
Merge from bzr.dev |
174 |
"\n", subst_dates(out)) |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
175 |
|
1732.3.3
by Matthieu Moy
Testcases for revno:N:path |
176 |
def test_diff_revno_branches(self): |
177 |
self.example_branches() |
|
178 |
print >> open('branch2/file', 'wb'), 'even newer content' |
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
179 |
self.run_bzr(['commit', '-m', |
1881.1.2
by Matthieu Moy
Formatting and style for the last patch. |
180 |
'update file once more', 'branch2']) |
1732.3.3
by Matthieu Moy
Testcases for revno:N:path |
181 |
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
182 |
out, err = self.run_bzr(['diff', '-r', |
1881.1.2
by Matthieu Moy
Formatting and style for the last patch. |
183 |
'revno:1:branch2..revno:1:branch1'], |
1732.3.3
by Matthieu Moy
Testcases for revno:N:path |
184 |
retcode=0) |
185 |
self.assertEquals('', err) |
|
186 |
self.assertEquals('', out) |
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
187 |
out, err = self.run_bzr(['diff', '-r', |
1881.1.2
by Matthieu Moy
Formatting and style for the last patch. |
188 |
'revno:2:branch2..revno:1:branch1'], |
1732.3.3
by Matthieu Moy
Testcases for revno:N:path |
189 |
retcode=1) |
190 |
self.assertEquals('', err) |
|
191 |
self.assertEqualDiff("=== modified file 'file'\n" |
|
192 |
"--- file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n" |
|
193 |
"+++ file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n" |
|
194 |
"@@ -1,1 +1,1 @@\n" |
|
195 |
"-new content\n" |
|
196 |
"+contents of branch1/file\n" |
|
197 |
"\n", subst_dates(out)) |
|
198 |
||
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
199 |
def example_branch2(self): |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
200 |
self.build_tree(['branch1/', 'branch1/file1'], line_endings='binary') |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
201 |
self.run_bzr(['init', 'branch1'])[0] |
202 |
self.run_bzr(['add', 'branch1/file1'])[0] |
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
203 |
print >> open('branch1/file1', 'wb'), 'original line' |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
204 |
self.run_bzr(['commit', '-m', 'first commit', 'branch1']) |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
205 |
|
206 |
print >> open('branch1/file1', 'wb'), 'repo line' |
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
207 |
self.run_bzr(['commit', '-m', 'second commit', 'branch1']) |
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
208 |
|
209 |
def test_diff_to_working_tree(self): |
|
210 |
self.example_branch2() |
|
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
211 |
|
212 |
print >> open('branch1/file1', 'wb'), 'new line' |
|
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
213 |
output = self.run_bzr(['diff', '-r', '1..', 'branch1'], |
1881.1.2
by Matthieu Moy
Formatting and style for the last patch. |
214 |
retcode=1) |
1185.50.44
by John Arbash Meinel
[patch] Robey Pointer: diff -r 1.. should diff against working tree. |
215 |
self.assertTrue('\n-original line\n+new line\n' in output[0]) |
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
216 |
|
1551.7.19
by Aaron Bentley
Always include working tree when calculating file ids for diff |
217 |
def test_diff_across_rename(self): |
218 |
"""The working tree path should always be considered for diffing"""
|
|
219 |
self.make_example_branch() |
|
220 |
self.run_bzr('diff', '-r', '0..1', 'hello', retcode=1) |
|
221 |
wt = workingtree.WorkingTree.open_containing('.')[0] |
|
222 |
wt.rename_one('hello', 'hello1') |
|
223 |
self.run_bzr('diff', 'hello1', retcode=1) |
|
224 |
self.run_bzr('diff', '-r', '0..1', 'hello1', retcode=1) |
|
225 |
||
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
226 |
|
227 |
class TestCheckoutDiff(TestDiff): |
|
228 |
||
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
229 |
def make_example_branch(self): |
230 |
super(TestCheckoutDiff, self).make_example_branch() |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
231 |
self.run_bzr('checkout . checkout') |
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
232 |
os.chdir('checkout') |
233 |
||
234 |
def example_branch2(self): |
|
235 |
super(TestCheckoutDiff, self).example_branch2() |
|
236 |
os.mkdir('checkouts') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
237 |
self.run_bzr('checkout branch1 checkouts/branch1') |
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
238 |
os.chdir('checkouts') |
239 |
||
240 |
def example_branches(self): |
|
241 |
super(TestCheckoutDiff, self).example_branches() |
|
242 |
os.mkdir('checkouts') |
|
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
243 |
self.run_bzr('checkout branch1 checkouts/branch1') |
244 |
self.run_bzr('checkout branch2 checkouts/branch2') |
|
1551.2.13
by Aaron Bentley
Got diff working properly with checkouts |
245 |
os.chdir('checkouts') |
1583.1.1
by Michael Ellerman
Change to -p1 format diffs. Update existing tests to cope, and add some |
246 |
|
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
247 |
|
2172.2.1
by Alexander Belchenko
Remove unnecessary duplication of tests in blackbox/test_diff.py |
248 |
class TestDiffLabels(DiffBase): |
1583.1.1
by Michael Ellerman
Change to -p1 format diffs. Update existing tests to cope, and add some |
249 |
|
250 |
def test_diff_label_removed(self): |
|
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
251 |
super(TestDiffLabels, self).make_example_branch() |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
252 |
self.run_bzr('remove hello') |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
253 |
diff = self.run_bzr(['diff'], retcode=1) |
1694.2.1
by Martin Pool
Remove 'a/', 'b/' default prefixes on diff output. |
254 |
self.assertTrue("=== removed file 'hello'" in diff[0]) |
1583.1.1
by Michael Ellerman
Change to -p1 format diffs. Update existing tests to cope, and add some |
255 |
|
256 |
def test_diff_label_added(self): |
|
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
257 |
super(TestDiffLabels, self).make_example_branch() |
1583.1.1
by Michael Ellerman
Change to -p1 format diffs. Update existing tests to cope, and add some |
258 |
file('barbar', 'wt').write('barbar') |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
259 |
self.run_bzr('add barbar') |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
260 |
diff = self.run_bzr(['diff'], retcode=1) |
1694.2.1
by Martin Pool
Remove 'a/', 'b/' default prefixes on diff output. |
261 |
self.assertTrue("=== added file 'barbar'" in diff[0]) |
1583.1.1
by Michael Ellerman
Change to -p1 format diffs. Update existing tests to cope, and add some |
262 |
|
263 |
def test_diff_label_modified(self): |
|
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
264 |
super(TestDiffLabels, self).make_example_branch() |
1583.1.1
by Michael Ellerman
Change to -p1 format diffs. Update existing tests to cope, and add some |
265 |
file('hello', 'wt').write('barbar') |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
266 |
diff = self.run_bzr(['diff'], retcode=1) |
1694.2.1
by Martin Pool
Remove 'a/', 'b/' default prefixes on diff output. |
267 |
self.assertTrue("=== modified file 'hello'" in diff[0]) |
1583.1.1
by Michael Ellerman
Change to -p1 format diffs. Update existing tests to cope, and add some |
268 |
|
269 |
def test_diff_label_renamed(self): |
|
1658.1.9
by Martin Pool
Give an error for bzr diff on an nonexistent file (Malone #3619) |
270 |
super(TestDiffLabels, self).make_example_branch() |
2530.3.1
by Martin Pool
Cleanup old variations on run_bzr in the test suite |
271 |
self.run_bzr('rename hello gruezi') |
2530.3.4
by Martin Pool
Deprecate run_bzr_captured in favour of just run_bzr |
272 |
diff = self.run_bzr(['diff'], retcode=1) |
1694.2.1
by Martin Pool
Remove 'a/', 'b/' default prefixes on diff output. |
273 |
self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0]) |
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
274 |
|
275 |
||
2172.2.1
by Alexander Belchenko
Remove unnecessary duplication of tests in blackbox/test_diff.py |
276 |
class TestExternalDiff(DiffBase): |
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
277 |
|
278 |
def test_external_diff(self): |
|
279 |
"""Test that we can spawn an external diff process"""
|
|
280 |
# We have to use run_bzr_subprocess, because we need to
|
|
281 |
# test writing directly to stdout, (there was a bug in
|
|
282 |
# subprocess.py that we had to workaround).
|
|
283 |
# However, if 'diff' may not be available
|
|
284 |
self.make_example_branch() |
|
285 |
orig_progress = os.environ.get('BZR_PROGRESS_BAR') |
|
286 |
try: |
|
287 |
os.environ['BZR_PROGRESS_BAR'] = 'none' |
|
2110.1.2
by John Arbash Meinel
Cleanup patch so it only adds universal_newlines |
288 |
out, err = self.run_bzr_subprocess('diff', '-r', '1', |
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
289 |
'--diff-options', '-ub', |
2052.5.1
by Alexander Belchenko
blackbox.test_diff fix: don't load plugins when in test bzr run as subprocess |
290 |
universal_newlines=True, |
1899.1.2
by John Arbash Meinel
Add a test that we can use an external diff program. |
291 |
retcode=None) |
292 |
finally: |
|
293 |
if orig_progress is None: |
|
294 |
del os.environ['BZR_PROGRESS_BAR'] |
|
295 |
else: |
|
296 |
os.environ['BZR_PROGRESS_BAR'] = orig_progress |
|
297 |
||
298 |
if 'Diff is not installed on this machine' in err: |
|
299 |
raise TestSkipped("No external 'diff' is available") |
|
300 |
self.assertEqual('', err) |
|
301 |
# We have to skip the stuff in the middle, because it depends
|
|
302 |
# on time.time()
|
|
303 |
self.assertStartsWith(out, "=== added file 'goodbye'\n" |
|
304 |
"--- goodbye\t1970-01-01 00:00:00 +0000\n" |
|
305 |
"+++ goodbye\t") |
|
306 |
self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n" |
|
1899.1.6
by John Arbash Meinel
internal_diff always adds a trailing \n, make sure external_diff does too |
307 |
"+baz\n\n") |
2178.4.1
by Alexander Belchenko
Provide tests to illustrate bug #55276 on win32. |
308 |
|
309 |
||
310 |
class TestDiffOutput(DiffBase): |
|
311 |
||
312 |
def test_diff_output(self): |
|
2178.4.5
by Alexander Belchenko
Spell-checking (thanks to Aaron) |
313 |
# check that output doesn't mangle line-endings
|
2178.4.1
by Alexander Belchenko
Provide tests to illustrate bug #55276 on win32. |
314 |
self.make_example_branch() |
315 |
file('hello', 'wb').write('hello world!\n') |
|
316 |
output = self.run_bzr_subprocess('diff', retcode=1)[0] |
|
317 |
self.assert_('\n+hello world!\n' in output) |