Mercurial > python-hglib
annotate tests/test-grep.py @ 213:388820908580 2.6.2
hglib: update grep to cope with behavior change in hg 5.2.
Since version 5.2, revision filed not printed without all argument.
Fixed inaccurate pasring result with lastest hg and changed test case.
author | Daehyeok Mun <daehyeok@gmail.com> |
---|---|
date | Sat, 21 Mar 2020 19:59:50 -0700 |
parents | 1a318162f06f |
children |
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 | 3 |
4 class test_grep(common.basetest): | |
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 | 9 |
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 | 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): |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
14 self.assertEquals(list(self.client.grep(b('x'))), |
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'))]) |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
16 self.assertEquals(list(self.client.grep(b('x'), b('a'))), |
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 | 18 |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
19 self.assertEquals(list(self.client.grep(b('y'))), |
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: |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
22 self.assertEquals(list(self.client.grep(b('x'))), |
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'))]) |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
24 self.assertEquals(list(self.client.grep(b('x'), b('a'))), |
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'))]) |
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
26 self.assertEquals(list(self.client.grep(b('y'))), |
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 | 28 |
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 | 33 |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
34 self.assertEquals([(b('a'), b('0'), b('+'), b('x')), |
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 | 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): |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
39 self.assertEquals([(b('a'),), (b('b'),)], |
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 |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
42 self.assertEquals([(b('a'), b('1'), b('x')), (b('b'), 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
|
43 list(self.client.grep(b('x'), line=True))) |
56 | 44 |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
45 self.assertEquals([(b('a'), b('test'), b('x')), |
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: |
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'))], |
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 | 51 |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
52 self.assertEquals([(b('a'), b('0'), b('1'), b('x')), |
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 |
213
388820908580
hglib: update grep to cope with behavior change in hg 5.2.
Daehyeok Mun <daehyeok@gmail.com>
parents:
211
diff
changeset
|
56 self.assertEquals([(b('a'), b('0'), b('test'), b('x')), |
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 | 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'))], |
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 | 63 line=True, |
56 | 64 fileswithmatches=True))) |