13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
"""Black-box tests for bzr diff.
33
34
'YYYY-MM-DD HH:MM:SS +ZZZZ', string)
36
class DiffBase(tests.TestCaseWithTransport):
37
class DiffBase(ExternalBase):
37
38
"""Base class with common setup method"""
39
40
def make_example_branch(self):
125
126
# Get an error from a file that does not exist at all
127
128
self.make_example_branch()
128
out, err = self.run_bzr('diff does-not-exist', retcode=3,
129
error_regexes=('not versioned.*does-not-exist',))
129
out, err = self.run_bzr('diff does-not-exist', retcode=3)
130
self.assertContainsRe(err, 'not versioned.*does-not-exist')
131
132
def test_diff_illegal_revision_specifiers(self):
132
out, err = self.run_bzr('diff -r 1..23..123', retcode=3,
133
error_regexes=('one or two revision specifiers',))
135
def test_diff_nonexistent_revision(self):
136
out, err = self.run_bzr('diff -r 123', retcode=3,
137
error_regexes=("Requested revision: '123' does not "
138
"exist in branch:",))
140
def test_diff_nonexistent_dotted_revision(self):
141
out, err = self.run_bzr('diff -r 1.1', retcode=3)
142
self.assertContainsRe(err,
143
"Requested revision: '1.1' does not exist in branch:")
145
def test_diff_nonexistent_dotted_revision_change(self):
146
out, err = self.run_bzr('diff -c 1.1', retcode=3)
147
self.assertContainsRe(err,
148
"Requested revision: '1.1' does not exist in branch:")
133
out, err = self.run_bzr('diff -r 1..23..123', retcode=3)
134
self.assertContainsRe(err, 'one or two revision specifiers')
150
136
def test_diff_unversioned(self):
151
137
# Get an error when diffing a non-versioned file.
202
188
def test_diff_branches(self):
203
189
self.example_branches()
204
# should open branch1 and diff against branch2,
190
# should open branch1 and diff against branch2,
205
191
self.check_b2_vs_b1('diff -r branch:branch2 branch1')
206
192
# Compare two working trees using various syntax forms
207
193
self.check_b2_vs_b1('diff --old branch2 --new branch1')
355
341
def test_external_diff(self):
356
342
"""Test that we can spawn an external diff process"""
357
self.disable_missing_extensions_warning()
358
343
# We have to use run_bzr_subprocess, because we need to
359
344
# test writing directly to stdout, (there was a bug in
360
345
# subprocess.py that we had to workaround).
361
346
# However, if 'diff' may not be available
362
347
self.make_example_branch()
363
# this will be automatically restored by the base bzr test class
364
os.environ['BZR_PROGRESS_BAR'] = 'none'
365
out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
366
universal_newlines=True,
348
orig_progress = os.environ.get('BZR_PROGRESS_BAR')
350
os.environ['BZR_PROGRESS_BAR'] = 'none'
351
out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
352
universal_newlines=True,
355
if orig_progress is None:
356
del os.environ['BZR_PROGRESS_BAR']
358
os.environ['BZR_PROGRESS_BAR'] = orig_progress
368
360
if 'Diff is not installed on this machine' in err:
369
raise tests.TestSkipped("No external 'diff' is available")
361
raise TestSkipped("No external 'diff' is available")
370
362
self.assertEqual('', err)
371
363
# We have to skip the stuff in the middle, because it depends