--- a/hgkw/keyword.py Sun Apr 10 20:51:39 2011 +0200
+++ b/hgkw/keyword.py Mon Apr 25 01:42:21 2011 +0100
@@ -83,6 +83,7 @@
from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
from mercurial import localrepo, match, patch, templatefilters, templater, util
+from mercurial import scmutil
from mercurial.hgweb import webcommands
from mercurial.i18n import _
import os, re, shutil, tempfile
@@ -619,8 +620,8 @@
expansion. '''
source = repo.dirstate.copied(dest)
if 'l' in wctx.flags(source):
- source = util.canonpath(repo.root, cwd,
- os.path.realpath(source))
+ source = scmutil.canonpath(repo.root, cwd,
+ os.path.realpath(source))
return kwt.match(source)
candidates = [f for f in repo.dirstate.copies() if
--- a/tests/run-tests.py Sun Apr 10 20:51:39 2011 +0200
+++ b/tests/run-tests.py Mon Apr 25 01:42:21 2011 +0100
@@ -633,25 +633,72 @@
output = re.sub(s, r, output)
return ret, splitnewlines(output)
-def runone(options, test, skips, fails):
+def runone(options, test, results):
'''tristate output:
None -> skipped
True -> passed
False -> failed'''
+ testpath = os.path.join(TESTDIR, test)
+
def skip(msg):
if not options.verbose:
- skips.append((test, msg))
+ results['s'].append((test, msg))
else:
print "\nSkipping %s: %s" % (testpath, msg)
return None
- def fail(msg):
- fails.append((test, msg))
+ def fail(msg, ret):
if not options.nodiff:
print "\nERROR: %s %s" % (testpath, msg)
+ if (not ret and options.interactive
+ and os.path.exists(testpath + ".err")):
+ print "Accept this change? [n] ",
+ answer = sys.stdin.readline().strip()
+ if answer.lower() in "y yes".split():
+ if test.endswith(".t"):
+ rename(testpath + ".err", testpath)
+ else:
+ rename(testpath + ".err", testpath + ".out")
+ return
+ results['f'].append((test, msg))
+
+ def success():
+ results['p'].append(test)
+
+ def ignore(msg):
+ results['i'].append((test, msg))
+
+ if (test.startswith("test-") and '~' not in test and
+ ('.' not in test or test.endswith('.py') or
+ test.endswith('.bat') or test.endswith('.t'))):
+ if not os.path.exists(test):
+ skip("doesn't exist")
+ return None
+ else:
+ return None # not a supported test, don't record
+
+ if options.blacklist:
+ filename = options.blacklist.get(test)
+ if filename is not None:
+ skipped.append((test, "blacklisted (%s)" % filename))
+ return None
+
+ if options.retest and not os.path.exists(test + ".err"):
+ ignore("not retesting")
return None
+ if options.keywords:
+ fp = open(test)
+ t = fp.read().lower() + test.lower()
+ fp.close()
+ for k in options.keywords.lower().split():
+ if k in t:
+ break
+ else:
+ ignore("doesn't match keyword")
+ return None
+
vlog("# Test", test)
# create a fresh hgrc
@@ -670,7 +717,6 @@
hgrc.write('appendpid=True\n')
hgrc.close()
- testpath = os.path.join(TESTDIR, test)
ref = os.path.join(TESTDIR, test+".out")
err = os.path.join(TESTDIR, test+".err")
if os.path.exists(err):
@@ -716,6 +762,8 @@
signal.alarm(0)
mark = '.'
+ if ret == 0:
+ success()
skipped = (ret == SKIPPED_STATUS)
@@ -747,18 +795,18 @@
if not missing:
missing = ['irrelevant']
if failed:
- fail("hghave failed checking for %s" % failed[-1])
+ fail("hghave failed checking for %s" % failed[-1], ret)
skipped = False
else:
skip(missing[-1])
elif out != refout:
mark = '!'
if ret == 'timeout':
- fail("timed out")
+ fail("timed out", ret)
elif ret:
- fail("output changed and returned error code %d" % ret)
+ fail("output changed and returned error code %d" % ret, ret)
else:
- fail("output changed")
+ fail("output changed", ret)
if ret != 'timeout' and not options.nodiff:
if options.view:
os.system("%s %s %s" % (options.view, ref, err))
@@ -767,7 +815,7 @@
ret = 1
elif ret:
mark = '!'
- fail("returned error code %d" % ret)
+ fail("returned error code %d" % ret, ret)
if not options.verbose:
sys.stdout.write(mark)
@@ -887,11 +935,19 @@
outputcoverage(options)
sys.exit(failures != 0)
+def runqueue(options, tests, results):
+ for test in tests:
+ ret = runone(options, test, results)
+ if options.first and ret is not None and not ret:
+ break
+
def runtests(options, tests):
global DAEMON_PIDS, HGRCPATH
DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids')
HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc')
+ results = dict(p=[], f=[], s=[], i=[])
+
try:
if INST:
installhg(options)
@@ -906,10 +962,6 @@
print 'WARNING: cannot run tests with timeouts'
options.timeout = 0
- tested = 0
- failed = 0
- skipped = 0
-
if options.restart:
orig = list(tests)
while tests:
@@ -920,69 +972,30 @@
print "running all tests"
tests = orig
- skips = []
- fails = []
-
- for test in tests:
- if options.blacklist:
- filename = options.blacklist.get(test)
- if filename is not None:
- skips.append((test, "blacklisted (%s)" % filename))
- skipped += 1
- continue
-
- if options.retest and not os.path.exists(test + ".err"):
- skipped += 1
- continue
+ runqueue(options, tests, results)
- if options.keywords:
- fp = open(test)
- t = fp.read().lower() + test.lower()
- fp.close()
- for k in options.keywords.lower().split():
- if k in t:
- break
- else:
- skipped += 1
- continue
-
- ret = runone(options, test, skips, fails)
- if ret is None:
- skipped += 1
- elif not ret:
- if options.interactive:
- print "Accept this change? [n] ",
- answer = sys.stdin.readline().strip()
- if answer.lower() in "y yes".split():
- if test.endswith(".t"):
- rename(test + ".err", test)
- else:
- rename(test + ".err", test + ".out")
- tested += 1
- fails.pop()
- continue
- failed += 1
- if options.first:
- break
- tested += 1
+ failed = len(results['f'])
+ tested = len(results['p']) + failed
+ skipped = len(results['s'])
+ ignored = len(results['i'])
if options.child:
fp = os.fdopen(options.child, 'w')
fp.write('%d\n%d\n%d\n' % (tested, skipped, failed))
- for s in skips:
+ for s in results['s']:
fp.write("%s %s\n" % s)
- for s in fails:
+ for s in results['f']:
fp.write("%s %s\n" % s)
fp.close()
else:
print
- for s in skips:
+ for s in results['s']:
print "Skipped %s: %s" % s
- for s in fails:
+ for s in results['f']:
print "Failed %s: %s" % s
_checkhglib("Tested")
print "# Ran %d tests, %d skipped, %d failed." % (
- tested, skipped, failed)
+ tested, skipped + ignored, failed)
if options.anycoverage:
outputcoverage(options)
@@ -1004,22 +1017,7 @@
args = os.listdir(".")
args.sort()
- tests = []
- skipped = []
- for test in args:
- if (test.startswith("test-") and '~' not in test and
- ('.' not in test or test.endswith('.py') or
- test.endswith('.bat') or test.endswith('.t'))):
- if not os.path.exists(test):
- skipped.append(test)
- else:
- tests.append(test)
- if not tests:
- for test in skipped:
- print 'Skipped %s: does not exist' % test
- print "# Ran 0 tests, %d skipped, 0 failed." % len(skipped)
- return
- tests = tests + skipped
+ tests = args
# Reset some environment variables to well-known values so that
# the tests produce repeatable output.