view tests/test-grep.py @ 116:661f78f395ea

Added tag 1.0 for changeset 8867908fe8c7
author Matt Mackall <mpm@selenic.com>
date Sat, 01 Jun 2013 17:13:39 -0500
parents 9bd819da245a
children 1b47146a4a2c
line wrap: on
line source

import common

class test_grep(common.basetest):
    def test_basic(self):
        self.append('a', 'a\n')
        self.append('b', 'ab\n')
        self.client.commit('first', addremove=True)

        # no match
        self.assertEquals(list(self.client.grep('c')), [])

        self.assertEquals(list(self.client.grep('a')),
                          [('a', '0', 'a'), ('b', '0', 'ab')])
        self.assertEquals(list(self.client.grep('a', 'a')), [('a', '0', 'a')])

        self.assertEquals(list(self.client.grep('b')), [('b', '0', 'ab')])

    def test_options(self):
        self.append('a', 'a\n')
        self.append('b', 'ab\n')
        rev, node = self.client.commit('first', addremove=True)

        self.assertEquals([('a', '0', '+', 'a'), ('b', '0', '+', 'ab')],
                          list(self.client.grep('a', all=True)))

        self.assertEquals([('a', '0'), ('b', '0')],
                          list(self.client.grep('a', fileswithmatches=True)))

        self.assertEquals([('a', '0', '1', 'a'), ('b', '0', '1', 'ab')],
                          list(self.client.grep('a', line=True)))

        self.assertEquals([('a', '0', 'test', 'a'), ('b', '0', 'test', 'ab')],
                          list(self.client.grep('a', user=True)))

        self.assertEquals([('a', '0', '1', '+', 'test'),
                           ('b', '0', '1', '+', 'test')],
                          list(self.client.grep('a', all=True, user=True, line=True,
                                                fileswithmatches=True)))