annotate tests/test-sshserver.py @ 35816:f6ca1e11d8b4 stable

revset: evaluate filesets against each revision for 'file()' (issue5778) After f2aeff8a87b6, the fileset was evaluated to a set of files against the working directory, and then those files were applied against each revision. The result was nonsense. For example, `hg log -r 'file("set:exec()")'` on the Mercurial repo listed revision 0 because it has the `hg` script, which is currently +x. But that bit wasn't applied until revision 280 (which 'contains()' properly indicates). This technique was borrowed from checkstatus(), which services adds(), modifies(), and removes(), so it seems safe enough. The 'r:' case is explicitly assigned to wdirrev, freeing up rev=None to mean "re-evaluate at each revision". The distinction is important to avoid behavior changes with `hg log set:...` (test-largefiles-misc.t and test-fileset-generated.t drop current log output without this). I'm not sure what the right behavior for that is (1fd352aa08fc explicitly enabled this behavior for graphlog), but the day before the release isn't the time to experiment.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 28 Jan 2018 14:08:59 -0500
parents 7764ff13318e
children 1bf5263fe5cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
1 from __future__ import absolute_import, print_function
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
2
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
3 import io
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
4 import unittest
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
5
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
6 import silenttestrunner
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
7
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
8 from mercurial import (
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
9 sshserver,
35772
7764ff13318e test-sshserver: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35752
diff changeset
10 util,
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
11 wireproto,
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
12 )
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
13
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
14 class SSHServerGetArgsTests(unittest.TestCase):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
15 def testparseknown(self):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
16 tests = [
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
17 ('* 0\nnodes 0\n', ['', {}]),
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
18 ('* 0\nnodes 40\n1111111111111111111111111111111111111111\n',
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
19 ['1111111111111111111111111111111111111111', {}]),
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
20 ]
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
21 for input, expected in tests:
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
22 self.assertparse('known', input, expected)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
23
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
24 def assertparse(self, cmd, input, expected):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
25 server = mockserver(input)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
26 _func, spec = wireproto.commands[cmd]
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
27 self.assertEqual(server.getargs(spec), expected)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
28
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
29 def mockserver(inbytes):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
30 ui = mockui(inbytes)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
31 repo = mockrepo(ui)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
32 return sshserver.sshserver(ui, repo)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
33
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
34 class mockrepo(object):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
35 def __init__(self, ui):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
36 self.ui = ui
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
37
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
38 class mockui(object):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
39 def __init__(self, inbytes):
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
40 self.fin = io.BytesIO(inbytes)
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
41 self.fout = io.BytesIO()
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
42 self.ferr = io.BytesIO()
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
43
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
44 if __name__ == '__main__':
35772
7764ff13318e test-sshserver: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35752
diff changeset
45 # Don't call into msvcrt to set BytesIO to binary mode
7764ff13318e test-sshserver: stabilize for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 35752
diff changeset
46 util.setbinary = lambda fp: True
35752
047581ddb6ce sshserver: add a couple of tests for argument parsing
Siddharth Agarwal <sid0@fb.com>
parents:
diff changeset
47 silenttestrunner.main(__name__)