~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to test_grep.py

  • Committer: Parth Malwankar
  • Date: 2010-05-22 15:11:00 UTC
  • mto: (0.44.2 grep) (6531.3.1 merge-grep)
  • mto: This revision was merged to the branch mainline in revision 6555.
  • Revision ID: parth.malwankar@gmail.com-20100522151100-y9198n1m20zxs8yn
bzr grep now allows grepping with -r even when no tree exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    def _mk_versioned_dir(self, path):
70
70
        self._mk_dir(path, versioned=True)
71
71
 
 
72
 
72
73
class TestGrep(GrepTestBase):
73
74
    """Core functional tests for grep."""
74
75
 
1914
1915
        self.assertContainsRe(out, "^file1.txt~7$", flags=TestGrep._reflags)
1915
1916
        self.assertEqual(len(out.splitlines()), 1)
1916
1917
 
 
1918
    def test_no_tree(self):
 
1919
        """Ensure grep works without working tree.
 
1920
        """
 
1921
        wd0 = 'foobar0'
 
1922
        wd1 = 'foobar1'
 
1923
        self.make_branch_and_tree(wd0)
 
1924
        os.chdir(wd0)
 
1925
        self._mk_versioned_file('file0.txt')
 
1926
        os.chdir('..')
 
1927
        out, err = self.run_bzr(['branch', '--no-tree', wd0, wd1])
 
1928
        os.chdir(wd1)
 
1929
 
 
1930
        out, err = self.run_bzr(['grep', 'line1'], 3)
 
1931
        self.assertContainsRe(err, "Cannot search working tree", flags=TestGrep._reflags)
 
1932
        self.assertEqual(out, '')
 
1933
 
 
1934
        out, err = self.run_bzr(['grep', '-r', '1', 'line1'])
 
1935
        self.assertContainsRe(out, "file0.txt~1:line1", flags=TestGrep._reflags)
 
1936
        self.assertEqual(len(out.splitlines()), 2) # finds line1 and line10
 
1937
 
1917
1938
 
1918
1939
class TestColorGrep(GrepTestBase):
1919
1940
    """Tests for the --color option."""