~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_diff.py

(vila) Revise legal option names to be less drastic. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Black-box tests for bzr diff.
19
 
"""
 
18
"""Black-box tests for bzr diff."""
20
19
 
21
20
import os
22
21
import re
29
28
    DiffTree,
30
29
    format_registry as diff_format_registry,
31
30
    )
 
31
from bzrlib.tests import (
 
32
    features,
 
33
    )
32
34
 
33
35
 
34
36
def subst_dates(string):
285
287
        self.example_branch2()
286
288
        self.build_tree_contents([('branch1/file1', 'new line')])
287
289
        os.mkdir('branch1/dir1')
288
 
        os.chdir('branch1/dir1')
289
 
        output = self.run_bzr('diff -r 1..', retcode=1)
 
290
        output = self.run_bzr('diff -r 1..', retcode=1,
 
291
                              working_dir='branch1/dir1')
290
292
        self.assertContainsRe(output[0], '\n\\-original line\n\\+new line\n')
291
293
 
292
294
    def test_diff_across_rename(self):
313
315
                return super(BooDiffTree, self).show_diff(specific_files,
314
316
                    extra_trees)
315
317
 
316
 
        diff_format_registry.register("boo", BooDiffTree, 
317
 
            "Scary diff format")
 
318
        diff_format_registry.register("boo", BooDiffTree, "Scary diff format")
318
319
        self.addCleanup(diff_format_registry.remove, "boo")
319
320
        self.make_example_branch()
320
321
        self.build_tree_contents([('hello', 'hello world!\n')])
321
322
        output = self.run_bzr('diff --format=boo', retcode=1)
322
323
        self.assertTrue("BOO!" in output[0])
 
324
        output = self.run_bzr('diff -Fboo', retcode=1)
 
325
        self.assertTrue("BOO!" in output[0])
323
326
 
324
327
 
325
328
class TestCheckoutDiff(TestDiff):
338
341
        return tree
339
342
 
340
343
    def example_branches(self):
341
 
        branch1_tree, branch2_tree = super(TestCheckoutDiff, self).example_branches()
 
344
        branch1_tree, branch2_tree = super(TestCheckoutDiff,
 
345
                                           self).example_branches()
342
346
        os.mkdir('checkouts')
343
347
        branch1_tree = branch1_tree.branch.create_checkout('checkouts/branch1')
344
348
        branch2_tree = branch2_tree.branch.create_checkout('checkouts/branch2')
384
388
        # subprocess.py that we had to workaround).
385
389
        # However, if 'diff' may not be available
386
390
        self.make_example_branch()
387
 
        # this will be automatically restored by the base bzr test class
388
 
        os.environ['BZR_PROGRESS_BAR'] = 'none'
389
 
        out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
390
 
                                           universal_newlines=True,
391
 
                                           retcode=None)
 
391
        out, err = self.run_bzr_subprocess(
 
392
            'diff -Oprogress_bar=none -r 1 --diff-options -ub',
 
393
            universal_newlines=True,
 
394
            retcode=None)
392
395
        if 'Diff is not installed on this machine' in err:
393
396
            raise tests.TestSkipped("No external 'diff' is available")
394
397
        self.assertEqual('', err)
400
403
        self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n"
401
404
                                 "+baz\n\n")
402
405
 
 
406
    def test_external_diff_options_and_using(self):
 
407
        """Test that the options are passed correctly to an external diff process"""
 
408
        self.requireFeature(features.diff_feature)
 
409
        self.make_example_branch()
 
410
        self.build_tree_contents([('hello', 'Foo\n')])
 
411
        out, err = self.run_bzr('diff --diff-options -i --using diff',
 
412
                                    retcode=1)
 
413
        self.assertEquals("=== modified file 'hello'\n", out)
 
414
        self.assertEquals('', err)
 
415
 
403
416
 
404
417
class TestDiffOutput(DiffBase):
405
418