--- a/tests/run-tests.py Fri Feb 05 17:57:36 2010 +0000
+++ b/tests/run-tests.py Wed Feb 17 11:15:18 2010 +0100
@@ -41,11 +41,11 @@
# completes fairly quickly, includes both shell and Python scripts, and
# includes some scripts that run daemon processes.)
-from ConfigParser import ConfigParser
import difflib
import errno
import optparse
import os
+import signal
import subprocess
import shutil
import signal
@@ -134,8 +134,7 @@
parser.add_option("--inotify", action="store_true",
help="enable inotify extension when running tests")
parser.add_option("--blacklist", action="append",
- help="skip tests listed in the specified section of "
- "the blacklist file")
+ help="skip tests listed in the specified blacklist file")
for option, default in defaults.items():
defaults[option] = int(os.environ.get(*default))
@@ -202,12 +201,22 @@
if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0):
parser.error('--py3k-warnings can only be used on Python 2.6+')
if options.blacklist:
- configparser = ConfigParser()
- configparser.read("blacklist")
blacklist = dict()
- for section in options.blacklist:
- for (item, value) in configparser.items(section):
- blacklist["test-" + item] = section
+ for filename in options.blacklist:
+ try:
+ path = os.path.expanduser(os.path.expandvars(filename))
+ f = open(path, "r")
+ except IOError, err:
+ if err.errno != errno.ENOENT:
+ raise
+ print "warning: no such blacklist file: %s" % filename
+ continue
+
+ for line in f.readlines():
+ line = line.strip()
+ if line and not line.startswith('#'):
+ blacklist[line] = filename
+
options.blacklist = blacklist
return (options, args)
@@ -231,7 +240,7 @@
if last:
lines.append(last)
return lines
- lines.append(text[i:n+1])
+ lines.append(text[i:n + 1])
i = n + 1
def parsehghaveoutput(lines):
@@ -275,6 +284,31 @@
else:
print "WARNING: Did not find prerequisite tool: "+p
+def killdaemons():
+ # Kill off any leftover daemon processes
+ try:
+ fp = open(DAEMON_PIDS)
+ for line in fp:
+ try:
+ pid = int(line)
+ except ValueError:
+ continue
+ try:
+ os.kill(pid, 0)
+ vlog('# Killing daemon process %d' % pid)
+ os.kill(pid, signal.SIGTERM)
+ time.sleep(0.25)
+ os.kill(pid, 0)
+ vlog('# Daemon process %d is stuck - really killing it' % pid)
+ os.kill(pid, signal.SIGKILL)
+ except OSError, err:
+ if err.errno != errno.ESRCH:
+ raise
+ fp.close()
+ os.unlink(DAEMON_PIDS)
+ except IOError:
+ pass
+
def cleanup(options):
if not options.keep_tmpdir:
vlog("# Cleaning up HGTMP", HGTMP)
@@ -424,6 +458,14 @@
ret = 0
else:
proc = Popen4(cmd)
+ def cleanup():
+ os.kill(proc.pid, signal.SIGTERM)
+ ret = proc.wait()
+ if ret == 0:
+ ret = signal.SIGTERM << 8
+ killdaemons()
+ return ret
+
try:
output = ''
proc.tochild.close()
@@ -433,12 +475,14 @@
ret = os.WEXITSTATUS(ret)
except Timeout:
vlog('# Process %d timed out - killing it' % proc.pid)
- os.kill(proc.pid, signal.SIGTERM)
- ret = proc.wait()
- if ret == 0:
- ret = signal.SIGTERM << 8
+ ret = cleanup()
output += ("\n### Abort: timeout after %d seconds.\n"
% options.timeout)
+ except KeyboardInterrupt:
+ vlog('# Handling keyboard interrupt')
+ cleanup()
+ raise
+
return ret, splitnewlines(output)
def runone(options, test, skips, fails):
@@ -581,29 +625,7 @@
f.write(line)
f.close()
- # Kill off any leftover daemon processes
- try:
- fp = open(DAEMON_PIDS)
- for line in fp:
- try:
- pid = int(line)
- except ValueError:
- continue
- try:
- os.kill(pid, 0)
- vlog('# Killing daemon process %d' % pid)
- os.kill(pid, signal.SIGTERM)
- time.sleep(0.25)
- os.kill(pid, 0)
- vlog('# Daemon process %d is stuck - really killing it' % pid)
- os.kill(pid, signal.SIGKILL)
- except OSError, err:
- if err.errno != errno.ESRCH:
- raise
- fp.close()
- os.unlink(DAEMON_PIDS)
- except IOError:
- pass
+ killdaemons()
os.chdir(TESTDIR)
if not options.keep_tmpdir:
@@ -660,9 +682,11 @@
jobs = [[] for j in xrange(options.jobs)]
while tests:
for job in jobs:
- if not tests: break
+ if not tests:
+ break
job.append(tests.pop())
fps = {}
+
for j, job in enumerate(jobs):
if not job:
continue
@@ -674,6 +698,7 @@
vlog(' '.join(cmdline))
fps[os.spawnvp(os.P_NOWAIT, cmdline[0], cmdline)] = os.fdopen(rfd, 'r')
os.close(wfd)
+ signal.signal(signal.SIGINT, signal.SIG_IGN)
failures = 0
tested, skipped, failed = 0, 0, 0
skips = []
@@ -682,7 +707,10 @@
pid, status = os.wait()
fp = fps.pop(pid)
l = fp.read().splitlines()
- test, skip, fail = map(int, l[:3])
+ try:
+ test, skip, fail = map(int, l[:3])
+ except ValueError:
+ test, skip, fail = 0, 0, 0
split = -fail or len(l)
for s in l[3:split]:
skips.append(s.split(" ", 1))
@@ -743,9 +771,9 @@
for test in tests:
if options.blacklist:
- section = options.blacklist.get(test)
- if section is not None:
- skips.append((test, "blacklisted (%s section)" % section))
+ filename = options.blacklist.get(test)
+ if filename is not None:
+ skips.append((test, "blacklisted (%s)" % filename))
skipped += 1
continue
@@ -759,7 +787,7 @@
if k in t:
break
else:
- skipped +=1
+ skipped += 1
continue
ret = runone(options, test, skips, fails)
@@ -915,6 +943,7 @@
else:
runtests(options, tests)
finally:
+ time.sleep(1)
cleanup(options)
main()
--- a/tests/test-keyword.out Fri Feb 05 17:57:36 2010 +0000
+++ b/tests/test-keyword.out Wed Feb 17 11:15:18 2010 +0100
@@ -169,12 +169,12 @@
c
c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
overwriting c expanding keywords
-committed changeset 2:e22d299ac0c2bd8897b3df5114374b9e4d4ca62f
+committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
% cat a c
expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
do not process $Id:
xxx $
-expand $Id: c,v e22d299ac0c2 1970/01/01 00:00:01 user $
+expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
do not process $Id:
xxx $
% touch copied c
@@ -320,9 +320,9 @@
x/a
x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
overwriting x/a expanding keywords
-committed changeset 3:cfa68229c1167443337266ebac453c73b1d5d16e
+committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
% cat a
-expand $Id: x/a cfa68229c116 Thu, 01 Jan 1970 00:00:03 +0000 user $
+expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
do not process $Id:
xxx $
$Xinfo: User Name <user@example.com>: xa $
@@ -364,11 +364,11 @@
# HG changeset patch
# User User Name <user@example.com>
# Date 3 0
-# Node ID cfa68229c1167443337266ebac453c73b1d5d16e
+# Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
# Parent bb948857c743469b22bbf51f7ec8112279ca5d83
xa
-diff -r bb948857c743 -r cfa68229c116 x/a
+diff -r bb948857c743 -r b4560182a3f9 x/a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/x/a Thu Jan 01 00:00:03 1970 +0000
@@ -0,0 +1,4 @@
@@ -400,7 +400,7 @@
created new head
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
-$Id: m 8731e1dadc99 Thu, 01 Jan 1970 00:00:00 +0000 test $
+$Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
foo
% conflict
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -418,24 +418,24 @@
foo
>>>>>>> other
% resolve to local
-$Id: m 43dfd2854b5b Thu, 01 Jan 1970 00:00:00 +0000 test $
+$Id: m 41efa6d38e9b Thu, 01 Jan 1970 00:00:00 +0000 test $
bar
% test restricted mode with transplant -b
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
marked working directory as branch foo
created new head
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-applying 1c4378f51c4d
-1c4378f51c4d transplanted to 7d855abcab87
+applying 4aa30d025d50
+4aa30d025d50 transplanted to 5a4da427c162
% no expansion in changeset
-changeset: 11:7d855abcab87
+changeset: 11:5a4da427c162
tag: tip
-parent: 9:43dfd2854b5b
+parent: 9:41efa6d38e9b
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: 9foobranch
-diff -r 43dfd2854b5b -r 7d855abcab87 a
+diff -r 41efa6d38e9b -r 5a4da427c162 a
--- a/a Thu Jan 01 00:00:00 1970 +0000
+++ b/a Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +1,4 @@
@@ -446,7 +446,7 @@
% expansion in file
foobranch
-expand $Id: a 7d855abcab87 Thu, 01 Jan 1970 00:00:00 +0000 test $
+expand $Id: a 5a4da427c162 Thu, 01 Jan 1970 00:00:00 +0000 test $
% switch off expansion
% kwshrink with unknown file u
overwriting a shrinking keywords