annotate tests/test-grep.py @ 211:1a318162f06f

grep: update tests to cope with behavior change in hg 5.2 I wonder if we should make hglib's grep behave consistently across all hg versions somehow, but I'm not going to attempt that for now.
author Augie Fackler <raf@durin42.com>
date Wed, 11 Dec 2019 10:20:58 -0500
parents c1b966866ed7
children 388820908580
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
148
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 143
diff changeset
1 from tests import common
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
2 from hglib.util import b
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
3
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4 class test_grep(common.basetest):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 def test_basic(self):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 self.append('a', 'a\n')
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 self.append('b', 'ab\n')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
8 self.client.commit(b('first'), addremove=True)
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 # no match
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
11 self.assertEquals(list(self.client.grep(b('c'))), [])
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
13 if self.client.version >= (5, 2):
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
14 self.assertEquals(list(self.client.grep(b('a'))),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
15 [(b('a'), b('a'), b('b'))])
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
16 self.assertEquals(list(self.client.grep(b('a'), b('a'))),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
17 [(b('a'), b('a'), b(''))])
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
19 self.assertEquals(list(self.client.grep(b('b'))),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
20 [(b('b'), b('ab'), b(''))])
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
21 else:
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
22 self.assertEquals(list(self.client.grep(b('a'))),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
23 [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))])
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
24 self.assertEquals(list(self.client.grep(b('a'), b('a'))),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
25 [(b('a'), b('0'), b('a'))])
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
26
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
27 self.assertEquals(list(self.client.grep(b('b'))),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
28 [(b('b'), b('0'), b('ab'))])
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30 def test_options(self):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
31 self.append('a', 'a\n')
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32 self.append('b', 'ab\n')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
33 rev, node = self.client.commit(b('first'), addremove=True)
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
34
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
35 self.assertEquals([(b('a'), b('0'), b('+'), b('a')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
36 (b('b'), b('0'), b('+'), b('ab'))],
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
37 list(self.client.grep(b('a'), all=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
38
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
39 if self.client.version >= (5, 2):
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
40 self.assertEquals([(b('a'), b('b'))],
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
41 list(self.client.grep(b('a'), fileswithmatches=True)))
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
42
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
43 self.assertEquals([(b('a'), b('1'), b('a'), b('b'))],
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
44 list(self.client.grep(b('a'), line=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
46 self.assertEquals([(b('a'), b('test'), b('a'), b('b'))],
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
47 list(self.client.grep(b('a'), user=True)))
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
48 else:
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
49 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))],
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
50 list(self.client.grep(b('a'), fileswithmatches=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
52 self.assertEquals([(b('a'), b('0'), b('1'), b('a')),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
53 (b('b'), b('0'), b('1'), b('ab'))],
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
54 list(self.client.grep(b('a'), line=True)))
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
55
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
56 self.assertEquals([(b('a'), b('0'), b('test'), b('a')),
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
57 (b('b'), b('0'), b('test'), b('ab'))],
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
58 list(self.client.grep(b('a'), user=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
60 self.assertEquals([(b('a'), b('0'), b('1'), b('+'), b('test')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
61 (b('b'), b('0'), b('1'), b('+'), b('test'))],
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
62 list(self.client.grep(b('a'), all=True, user=True,
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 56
diff changeset
63 line=True,
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
64 fileswithmatches=True)))