annotate tests/test-grep.py @ 180:ff6efc1ab9e4

protocol: allow hglib user to get call backs for prompts, output and errors setcbout(cbout), setcberr(cberr) and setcbprompt(cbprompt) are used to set the call back function used by the hgclient class. cb stands for call back. cbout is a function that will be called with the stdout data of the command as it runs. cbout is called with output as it is made available, which can be as partial lines or multiple lines. cberr is a function that will be called with the stderr data of the command as it runs. cberr is called with output as it is made available, which can be as partial lines or multiple lines. Command that make remote connects can prompt for username and password for HTTP/HTTPS connections. cbprompt is called when hgclient need a response to a prompt from the server. It receives the max number of bytes to return and the contents of stdout received so far. The last text sent to either cbout or cberr will contain the prompt text itself.
author Barry A. Scott <barry@barrys-emacs.org>
date Fri, 28 Oct 2016 11:33:20 +0100
parents c1b966866ed7
children 1a318162f06f
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
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
13 self.assertEquals(list(self.client.grep(b('a'))),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
14 [(b('a'), b('0'), b('a')), (b('b'), b('0'), b('ab'))])
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
15 self.assertEquals(list(self.client.grep(b('a'), b('a'))),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
16 [(b('a'), b('0'), b('a'))])
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
18 self.assertEquals(list(self.client.grep(b('b'))),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
19 [(b('b'), b('0'), b('ab'))])
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
21 def test_options(self):
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22 self.append('a', 'a\n')
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
23 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
24 rev, node = self.client.commit(b('first'), addremove=True)
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
25
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
26 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
27 (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
28 list(self.client.grep(b('a'), all=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
30 self.assertEquals([(b('a'), b('0')), (b('b'), b('0'))],
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
31 list(self.client.grep(b('a'), fileswithmatches=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
32
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
33 self.assertEquals([(b('a'), b('0'), b('1'), b('a')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
34 (b('b'), b('0'), b('1'), b('ab'))],
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
35 list(self.client.grep(b('a'), line=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
36
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
37 self.assertEquals([(b('a'), b('0'), b('test'), b('a')),
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
38 (b('b'), b('0'), b('test'), b('ab'))],
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
39 list(self.client.grep(b('a'), user=True)))
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
40
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
41 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
42 (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
43 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
44 line=True,
56
9bd819da245a client: add grep command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
45 fileswithmatches=True)))