annotate tests/test_grep.py @ 227:484b56ac4aec default tip

hglib: cat accepts a template argument
author Julien Cristau <jcristau@mozilla.com>
date Mon, 17 Jun 2024 17:17:58 +0200
parents a2afbf236ca8
children
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):
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
6 self.append('a', 'x\n')
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
7 self.append('b', 'xy\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
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
11 self.assertEqual(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):
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
14 self.assertEqual(list(self.client.grep(b('x'))),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
15 [(b('a'), b('x')), (b('b'), b('xy'))])
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
16 self.assertEqual(list(self.client.grep(b('x'), b('a'))),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
17 [(b('a'), b('x'))])
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
19 self.assertEqual(list(self.client.grep(b('y'))),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
20 [(b('b'), b('xy'))])
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
21 else:
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
22 self.assertEqual(list(self.client.grep(b('x'))),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
23 [(b('a'), b('0'), b('x')), (b('b'), b('0'), b('xy'))])
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
24 self.assertEqual(list(self.client.grep(b('x'), b('a'))),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
25 [(b('a'), b('0'), b('x'))])
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
26 self.assertEqual(list(self.client.grep(b('y'))),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
27 [(b('b'), b('0'), b('xy'))])
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
28
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 def test_options(self):
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
30 self.append('a', 'x\n')
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
31 self.append('b', 'xy\n')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
32 rev, node = self.client.commit(b('first'), addremove=True)
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
34 self.assertEqual([(b('a'), b('0'), b('+'), b('x')),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
35 (b('b'), b('0'), b('+'), b('xy'))],
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
36 list(self.client.grep(b('x'), all=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
37
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
38 if self.client.version >= (5, 2):
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
39 self.assertEqual([(b('a'),), (b('b'),)],
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
40 list(self.client.grep(b('x'), fileswithmatches=True)))
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
41
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
42 self.assertEqual([(b('a'), b('1'), b('x')), (b('b'), b('1'), b('xy'))],
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
43 list(self.client.grep(b('x'), line=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
44
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
45 self.assertEqual([(b('a'), b('test'), b('x')),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
46 (b('b'), b('test'), b('xy'))],
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
47 list(self.client.grep(b('x'), user=True)))
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
48 else:
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
49 self.assertEqual([(b('a'), b('0')), (b('b'), b('0'))],
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
50 list(self.client.grep(b('x'), fileswithmatches=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
51
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
52 self.assertEqual([(b('a'), b('0'), b('1'), b('x')),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
53 (b('b'), b('0'), b('1'), b('xy'))],
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
54 list(self.client.grep(b('x'), line=True)))
211
1a318162f06f grep: update tests to cope with behavior change in hg 5.2
Augie Fackler <raf@durin42.com>
parents: 148
diff changeset
55
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
56 self.assertEqual([(b('a'), b('0'), b('test'), b('x')),
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
57 (b('b'), b('0'), b('test'), b('xy'))],
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
58 list(self.client.grep(b('x'), user=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
59
221
a2afbf236ca8 hglib tests: remove deprecated constructions
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 219
diff changeset
60 self.assertEqual([(b('a'), b('0'), b('1'), b('+'), b('test')),
143
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'))],
213
388820908580 hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents: 211
diff changeset
62 list(self.client.grep(b('x'), 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)))