[PATCH 5 of 5 RFC] tests: add --cmdserver option to run tests using the command server
Idan Kamara
idankk86 at gmail.com
Fri Jun 3 20:04:44 UTC 2011
# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1307131444 -10800
# Node ID c11b6d6fb1788f8fdffa0c249c0e5b54cf0178b8
# Parent 1a75ec54cf1092c2e3690511b54d2bf941c974de
tests: add --cmdserver option to run tests using the command server
for now this uses the (seemingly fragile) --with-hg option to run-tests.
alot of tests are failing:
- changes to the ui object aren't reflected in the repo ui. that makes things
like -v and --config not work when accessed through the repo ui.
- interactive tests don't work.
- some output is misordered, stderr presumably. see test-586 for instance.
I also disabled the checkhglib in run-tests for now and added another hack
to make 'import mercurial' work with --with-hg.
diff -r 1a75ec54cf10 -r c11b6d6fb178 tests/cmdserver/hg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/cmdserver/hg Fri Jun 03 23:04:04 2011 +0300
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+# A replacement for the regular hg script that can be used to run tests through
+# the command server
+
+import sys
+import os
+
+root = os.path.join(os.path.abspath(os.path.dirname(sys.argv[0])), '../..')
+sys.path.append(root)
+
+from contrib.hglib import hglib
+from mercurial import dispatch, cmdutil, commands
+
+if __name__ == '__main__':
+ args = sys.argv[1:]
+
+ # get -R early so we can connect to the right repo
+ rpath = dispatch._earlygetopt(["-R", "--repository", "--repo"], args)
+ if rpath:
+ rpath = rpath[0]
+ else:
+ # are we inside a repo?
+ rpath = cmdutil.findrepo(os.getcwd())
+
+ # fallback to regular dispatch for norepo commands or if we didn't find a repo
+ if not rpath or set(args).intersection(set(commands.norepo.split(' '))):
+ import mercurial.util
+
+ for fp in (sys.stdin, sys.stdout, sys.stderr):
+ mercurial.util.setbinary(fp)
+
+ dispatch.run()
+ else:
+ hglib.HGPATH = root + '/hg'
+ sys.exit(hglib.connect(rpath, sys.stdout, sys.stderr).rawcommand(args))
diff -r 1a75ec54cf10 -r c11b6d6fb178 tests/run-tests.py
--- a/tests/run-tests.py Fri Jun 03 23:04:04 2011 +0300
+++ b/tests/run-tests.py Fri Jun 03 23:04:04 2011 +0300
@@ -146,6 +146,8 @@
help="exit on the first test failure")
parser.add_option("--inotify", action="store_true",
help="enable inotify extension when running tests")
+ parser.add_option("--cmdserver", action="store_true",
+ help="execute hg commands through the command server")
parser.add_option("-i", "--interactive", action="store_true",
help="prompt to accept changed output")
parser.add_option("-j", "--jobs", type="int",
@@ -206,7 +208,15 @@
parser.error('--with-hg must specify an executable hg script')
if not os.path.basename(options.with_hg) == 'hg':
sys.stderr.write('warning: --with-hg should specify an hg script\n')
- if options.local:
+ if options.cmdserver:
+ if options.with_hg:
+ sys.stderr.write('warning: --cmdserver overrides --with-hg\n')
+ if options.local:
+ sys.stderr.write('warning: --cmdserver overrides --local\n')
+ testdir = os.path.dirname(os.path.realpath(sys.argv[0]))
+ hgbin = os.path.join(testdir, 'cmdserver', 'hg')
+ options.with_hg = hgbin
+ if options.local and not options.cmdserver:
testdir = os.path.dirname(os.path.realpath(sys.argv[0]))
hgbin = os.path.join(os.path.dirname(testdir), 'hg')
if not os.access(hgbin, os.X_OK):
@@ -926,7 +936,7 @@
def runchildren(options, tests):
if INST:
installhg(options)
- _checkhglib("Testing")
+ #_checkhglib("Testing")
optcopy = dict(options.__dict__)
optcopy['jobs'] = 1
@@ -943,6 +953,8 @@
del optcopy['blacklist']
blacklisted = []
+ del optcopy['cmdserver']
+
if optcopy['with_hg'] is None:
optcopy['with_hg'] = os.path.join(BINDIR, "hg")
optcopy.pop('anycoverage', None)
@@ -1015,7 +1027,7 @@
for s in fails:
print "Failed %s: %s" % (s[0], s[1])
- _checkhglib("Tested")
+ #_checkhglib("Tested")
print "# Ran %d tests, %d skipped, %d failed." % (
tested, skipped, failed)
@@ -1041,7 +1053,7 @@
try:
if INST:
installhg(options)
- _checkhglib("Testing")
+ #_checkhglib("Testing")
if options.restart:
orig = list(tests)
@@ -1074,7 +1086,7 @@
print "Skipped %s: %s" % s
for s in results['f']:
print "Failed %s: %s" % s
- _checkhglib("Tested")
+ #_checkhglib("Tested")
print "# Ran %d tests, %d skipped, %d failed." % (
tested, skipped + ignored, failed)
@@ -1174,7 +1186,7 @@
# Include TESTDIR in PYTHONPATH so that out-of-tree extensions
# can run .../tests/run-tests.py test-foo where test-foo
# adds an extension to HGRC
- pypath = [PYTHONDIR, TESTDIR]
+ pypath = [PYTHONDIR, TESTDIR, TESTDIR + '/..']
# We have to augment PYTHONPATH, rather than simply replacing
# it, in case external libraries are only available via current
# PYTHONPATH. (In particular, the Subversion bindings on OS X
More information about the Mercurial-devel
mailing list