summaryrefslogtreecommitdiff
path: root/tests/test-commandserver.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-commandserver.py')
-rw-r--r--tests/test-commandserver.py101
1 files changed, 6 insertions, 95 deletions
diff --git a/tests/test-commandserver.py b/tests/test-commandserver.py
index db6e76d..66e405e 100644
--- a/tests/test-commandserver.py
+++ b/tests/test-commandserver.py
@@ -18,7 +18,7 @@ def writeblock(server, data):
def readchannel(server):
data = server.stdout.read(5)
if not data:
- raise EOFError
+ raise EOFError()
channel, length = struct.unpack('>cI', data)
if channel in 'IL':
return channel, length
@@ -26,8 +26,6 @@ def readchannel(server):
return channel, server.stdout.read(length)
def runcommand(server, args, output=sys.stdout, error=sys.stderr, input=None):
- print ' runcommand', ' '.join(args)
- sys.stdout.flush()
server.stdin.write('runcommand\n')
writeblock(server, '\0'.join(args))
@@ -54,10 +52,6 @@ def runcommand(server, args, output=sys.stdout, error=sys.stderr, input=None):
return
def check(func, repopath=None):
- print
- print 'testing %s:' % func.__name__
- print
- sys.stdout.flush()
server = connect(repopath)
try:
return func(server)
@@ -71,8 +65,7 @@ def unknowncommand(server):
def hellomessage(server):
ch, data = readchannel(server)
# escaping python tests output not supported
- print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***',
- data))
+ print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', 'encoding: ***', data))
# run an arbitrary command to make sure the next thing the server sends
# isn't part of the hello message
@@ -131,7 +124,7 @@ def cwd(server):
""" check that --cwd doesn't persist between requests """
readchannel(server)
os.mkdir('foo')
- f = open('foo/bar', 'wb')
+ f = open('foo/bar', 'w')
f.write('a')
f.close()
runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
@@ -143,13 +136,12 @@ def localhgrc(server):
is used """
readchannel(server)
- # the cached repo local hgrc contains ui.foo=bar, so showconfig should
- # show it
+ # the cached repo local hgrc contains ui.foo=bar, so showconfig should show it
runcommand(server, ['showconfig'])
# but not for this repo
runcommand(server, ['init', 'foo'])
- runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
+ runcommand(server, ['-R', 'foo', 'showconfig'])
shutil.rmtree('foo')
def hook(**args):
@@ -159,83 +151,9 @@ def hook(**args):
def hookoutput(server):
readchannel(server)
runcommand(server, ['--config',
- 'hooks.pre-identify=python:test-commandserver.hook',
- 'id'],
+ 'hooks.pre-identify=python:test-commandserver.hook', 'id'],
input=cStringIO.StringIO('some input'))
-def outsidechanges(server):
- readchannel(server)
- f = open('a', 'ab')
- f.write('a\n')
- f.close()
- runcommand(server, ['status'])
- os.system('hg ci -Am2')
- runcommand(server, ['tip'])
- runcommand(server, ['status'])
-
-def bookmarks(server):
- readchannel(server)
- runcommand(server, ['bookmarks'])
-
- # changes .hg/bookmarks
- os.system('hg bookmark -i bm1')
- os.system('hg bookmark -i bm2')
- runcommand(server, ['bookmarks'])
-
- # changes .hg/bookmarks.current
- os.system('hg upd bm1 -q')
- runcommand(server, ['bookmarks'])
-
- runcommand(server, ['bookmarks', 'bm3'])
- f = open('a', 'ab')
- f.write('a\n')
- f.close()
- runcommand(server, ['commit', '-Amm'])
- runcommand(server, ['bookmarks'])
-
-def tagscache(server):
- readchannel(server)
- runcommand(server, ['id', '-t', '-r', '0'])
- os.system('hg tag -r 0 foo')
- runcommand(server, ['id', '-t', '-r', '0'])
-
-def setphase(server):
- readchannel(server)
- runcommand(server, ['phase', '-r', '.'])
- os.system('hg phase -r . -p')
- runcommand(server, ['phase', '-r', '.'])
-
-def rollback(server):
- readchannel(server)
- runcommand(server, ['phase', '-r', '.', '-p'])
- f = open('a', 'ab')
- f.write('a\n')
- f.close()
- runcommand(server, ['commit', '-Am.'])
- runcommand(server, ['rollback'])
- runcommand(server, ['phase', '-r', '.'])
-
-def branch(server):
- readchannel(server)
- runcommand(server, ['branch'])
- os.system('hg branch foo')
- runcommand(server, ['branch'])
- os.system('hg branch default')
-
-def hgignore(server):
- readchannel(server)
- f = open('.hgignore', 'ab')
- f.write('')
- f.close()
- runcommand(server, ['commit', '-Am.'])
- f = open('ignored-file', 'ab')
- f.write('')
- f.close()
- f = open('.hgignore', 'ab')
- f.write('ignored-file')
- f.close()
- runcommand(server, ['status', '-i', '-u'])
-
if __name__ == '__main__':
os.system('hg init')
@@ -251,10 +169,3 @@ if __name__ == '__main__':
hgrc.close()
check(localhgrc)
check(hookoutput)
- check(outsidechanges)
- check(bookmarks)
- check(tagscache)
- check(setphase)
- check(rollback)
- check(branch)
- check(hgignore)