annotate tests/test-resolve.py @ 188:5609a21fe39a

client: fail gracefully on unexpected prompts (issue5516) Right now, if hglib encounters an unexpected prompt, it fails with a rather opaque "unexpected data on required channel 'L'" error message. Furthermore, if subsequently another command is called on the same client instance, both the client and server processes lock up hard (at least on Windows), and the server process rapidly leaks ~2GB of memory. Fix this by responding with an empty string to any unexpected prompt. This will trigger an "abort: response expected" exception from the server, which is easily handled as a CommandError, and subsequent commands sent from the same client work as expected. This doesn't completely resolve bug 5516, as unexpected requests on another required channel (e.g. I) can still cause a lockup. However, it does fix the most common case of an unexpected password prompt.
author G?bor Stefanik <gabor.stefanik@nng.com>
date Tue, 12 Sep 2017 13:16:36 -0400
parents c1b966866ed7
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
c1b966866ed7 hglib: make all imports absolute (issue4520)
Brett Cannon <brett@python.org>
parents: 143
diff changeset
2 import hglib
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
3 from hglib.util import b
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
4
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
5 class test_resolve(common.basetest):
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
6 def setUp(self):
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
7 common.basetest.setUp(self)
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
8
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
9 self.append('a', 'a')
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
10 self.append('b', 'b')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
11 rev, self.node0 = self.client.commit(b('first'), addremove=True)
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
12
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
13 self.append('a', 'a')
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
14 self.append('b', 'b')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
15 rev, self.node1 = self.client.commit(b('second'))
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
16
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
17 def test_basic(self):
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
18 self.client.update(self.node0)
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
19 self.append('a', 'b')
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
20 self.append('b', 'a')
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
21 rev, self.node3 = self.client.commit(b('third'))
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
22
134
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 63
diff changeset
23 self.assertRaises(hglib.error.CommandError, self.client.merge,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 63
diff changeset
24 self.node1)
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 63
diff changeset
25 self.assertRaises(hglib.error.CommandError,
1b47146a4a2c style: fix long lines
Matt Mackall <mpm@selenic.com>
parents: 63
diff changeset
26 self.client.resolve, all=True)
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
27
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
28 self.assertEquals([(b('U'), b('a')), (b('U'), b('b'))],
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
29 self.client.resolve(listfiles=True))
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
30
143
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
31 self.client.resolve(b('a'), mark=True)
4359cabcb0cc hglib: move string literals in the test code to util.b() (issue4520)
Brett Cannon <brett@python.org>
parents: 134
diff changeset
32 self.assertEquals([(b('R'), b('a')), (b('U'), b('b'))],
63
939d1d763bb1 client: add resolve command
Idan Kamara <idankk86@gmail.com>
parents:
diff changeset
33 self.client.resolve(listfiles=True))