Rev 5354: Define a 'diff_feature' and use it to simplify tests. in file:///home/vila/src/bzr/reviews/234708-diff/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Jul 22 10:04:06 BST 2010
At file:///home/vila/src/bzr/reviews/234708-diff/
------------------------------------------------------------
revno: 5354
revision-id: v.ladeuil+lp at free.fr-20100722090405-xtc6zn0tiot6z9hn
parent: dev at anteru.net-20100719181656-snkiywdjtpfgtdgh
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 234708-diff
timestamp: Thu 2010-07-22 11:04:05 +0200
message:
Define a 'diff_feature' and use it to simplify tests.
-------------- next part --------------
=== modified file 'bzrlib/tests/blackbox/test_diff.py'
--- a/bzrlib/tests/blackbox/test_diff.py 2010-07-19 18:16:56 +0000
+++ b/bzrlib/tests/blackbox/test_diff.py 2010-07-22 09:04:05 +0000
@@ -29,6 +29,7 @@
DiffTree,
format_registry as diff_format_registry,
)
+from bzrlib.tests import features
def subst_dates(string):
@@ -375,21 +376,20 @@
class TestExternalDiff(DiffBase):
+ _test_needs_features = [features.diff_feature]
+
def test_external_diff(self):
"""Test that we can spawn an external diff process"""
self.disable_missing_extensions_warning()
# We have to use run_bzr_subprocess, because we need to
# test writing directly to stdout, (there was a bug in
# subprocess.py that we had to workaround).
- # However, if 'diff' may not be available
self.make_example_branch()
# this will be automatically restored by the base bzr test class
os.environ['BZR_PROGRESS_BAR'] = 'none'
out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
universal_newlines=True,
retcode=None)
- if 'Diff is not installed on this machine' in err:
- raise tests.TestSkipped("No external 'diff' is available")
self.assertEqual('', err)
# We have to skip the stuff in the middle, because it depends
# on time.time()
@@ -400,14 +400,11 @@
"+baz\n\n")
def test_external_diff_options_and_using(self):
- """Test that the options are passed correctly to an external diff process"""
+ """Test that the options are passed correctly to an external diff."""
self.make_example_branch()
self.build_tree_contents([('hello', 'Foo\n')])
- # no retcode, so we can capture if /usr/bin/diff was not found and skip
- out, err = self.run_bzr('diff --diff-options -i --using /usr/bin/diff',
- retcode=None)
- if 'bzr: ERROR: /usr/bin/diff could not be found on this machine\n' in err:
- raise tests.TestSkipped("No external 'diff' is available")
+ out, err = self.run_bzr('diff --diff-options -i --using diff',
+ retcode=1)
self.assertEquals("=== modified file 'hello'\n", out)
self.assertEquals('', err)
=== modified file 'bzrlib/tests/features.py'
--- a/bzrlib/tests/features.py 2010-05-25 21:30:52 +0000
+++ b/bzrlib/tests/features.py 2010-07-22 09:04:05 +0000
@@ -113,3 +113,4 @@
bash_feature = ExecutableFeature('bash')
sed_feature = ExecutableFeature('sed')
+diff_feature = ExecutableFeature('diff')
More information about the bazaar-commits
mailing list