annotate tests/run-tests.py @ 32:4ee030a94d79

Slightly modified run-tests.py so that tests can run self-contained.
author Augie Fackler <durin42@gmail.com>
date Tue, 28 Apr 2009 11:23:15 -0700
parents
children 6d010ec28d7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 #
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 # run-tests.py - Run a set of tests on Mercurial
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 #
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 # Copyright 2006 Matt Mackall <mpm@selenic.com>
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 #
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 # This software may be used and distributed according to the terms of the
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 # GNU General Public License version 2, incorporated herein by reference.
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 import difflib
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 import errno
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 import optparse
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 import os
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
14 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 import subprocess
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 subprocess.Popen # trigger ImportError early
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17 closefds = os.name == 'posix'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 def Popen4(cmd, bufsize=-1):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 p = subprocess.Popen(cmd, shell=True, bufsize=bufsize,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 close_fds=closefds,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 stderr=subprocess.STDOUT)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 p.fromchild = p.stdout
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 p.tochild = p.stdin
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 p.childerr = p.stderr
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
26 return p
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 except ImportError:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 subprocess = None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
29 from popen2 import Popen4
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30 import shutil
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
31 import signal
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 import sys
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 import tempfile
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34 import time
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 # reserved exit code to skip test (used by hghave)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 SKIPPED_STATUS = 80
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 SKIPPED_PREFIX = 'skipped: '
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 FAILED_PREFIX = 'hghave check failed: '
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 PYTHON = sys.executable
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 requiredtools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"]
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
43
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 defaults = {
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 'jobs': ('HGTEST_JOBS', 1),
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 'timeout': ('HGTEST_TIMEOUT', 180),
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 'port': ('HGTEST_PORT', 20059),
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 }
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 def parseargs():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 parser = optparse.OptionParser("%prog [options] [tests]")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 parser.add_option("-C", "--annotate", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53 help="output files annotated with coverage")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 parser.add_option("--child", type="int",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 help="run as child process, summary to given fd")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 parser.add_option("-c", "--cover", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 help="print a test coverage report")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 parser.add_option("-f", "--first", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 help="exit on the first test failure")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 parser.add_option("-i", "--interactive", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 help="prompt to accept changed output")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 parser.add_option("-j", "--jobs", type="int",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 help="number of jobs to run in parallel"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 " (default: $%s or %d)" % defaults['jobs'])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 parser.add_option("--keep-tmpdir", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 help="keep temporary directory after running tests"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 " (best used with --tmpdir)")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 parser.add_option("-R", "--restart", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
69 help="restart at last error")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 parser.add_option("-p", "--port", type="int",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 help="port on which servers should listen"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 " (default: $%s or %d)" % defaults['port'])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 parser.add_option("-r", "--retest", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
74 help="retest failed tests")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
75 parser.add_option("-s", "--cover_stdlib", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
76 help="print a test coverage report inc. standard libraries")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77 parser.add_option("-t", "--timeout", type="int",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
78 help="kill errant tests after TIMEOUT seconds"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
79 " (default: $%s or %d)" % defaults['timeout'])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
80 parser.add_option("--tmpdir", type="string",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
81 help="run tests in the given temporary directory")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
82 parser.add_option("-v", "--verbose", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
83 help="output verbose messages")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84 parser.add_option("-n", "--nodiff", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
85 help="skip showing test changes")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
86 parser.add_option("--with-hg", type="string",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
87 help="test existing install at given location")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
88 parser.add_option("--pure", action="store_true",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
89 help="use pure Python code instead of C extensions")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
90
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
91 for option, default in defaults.items():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 defaults[option] = int(os.environ.get(*default))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93 parser.set_defaults(**defaults)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 (options, args) = parser.parse_args()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 global vlog
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97 options.anycoverage = (options.cover or
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
98 options.cover_stdlib or
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 options.annotate)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 if options.verbose:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
102 def vlog(*msg):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
103 for m in msg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
104 print m,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
105 print
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
106 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
107 vlog = lambda *msg: None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
108
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
109 if options.jobs < 1:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
110 print >> sys.stderr, 'ERROR: -j/--jobs must be positive'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
111 sys.exit(1)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
112 if options.interactive and options.jobs > 1:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
113 print '(--interactive overrides --jobs)'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
114 options.jobs = 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
115
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 return (options, args)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118 def rename(src, dst):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 """Like os.rename(), trade atomicity and opened files friendliness
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 for existing destination support.
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 """
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 shutil.copy(src, dst)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 os.remove(src)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 def splitnewlines(text):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 '''like str.splitlines, but only split on newlines.
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 keep line endings.'''
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 i = 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 lines = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
130 while True:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 n = text.find('\n', i)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
132 if n == -1:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 last = text[i:]
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 if last:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 lines.append(last)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 return lines
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
137 lines.append(text[i:n+1])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
138 i = n + 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
139
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140 def parsehghaveoutput(lines):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 '''Parse hghave log lines.
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 Return tuple of lists (missing, failed):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 * the missing/unknown features
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144 * the features for which existence check failed'''
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
145 missing = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
146 failed = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
147 for line in lines:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
148 if line.startswith(SKIPPED_PREFIX):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
149 line = line.splitlines()[0]
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
150 missing.append(line[len(SKIPPED_PREFIX):])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151 elif line.startswith(FAILED_PREFIX):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
152 line = line.splitlines()[0]
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
153 failed.append(line[len(FAILED_PREFIX):])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
154
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
155 return missing, failed
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
156
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
157 def showdiff(expected, output):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
158 for line in difflib.unified_diff(expected, output,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
159 "Expected output", "Test output"):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
160 sys.stdout.write(line)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
161
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
162 def findprogram(program):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163 """Search PATH for a executable program"""
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 for p in os.environ.get('PATH', os.defpath).split(os.pathsep):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 name = os.path.join(p, program)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
166 if os.access(name, os.X_OK):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
167 return name
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
168 return None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
169
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
170 def checktools():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
171 # Before we go any further, check for pre-requisite tools
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
172 # stuff from coreutils (cat, rm, etc) are not tested
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
173 for p in requiredtools:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
174 if os.name == 'nt':
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
175 p += '.exe'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
176 found = findprogram(p)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
177 if found:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
178 vlog("# Found prerequisite", p, "at", found)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
179 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
180 print "WARNING: Did not find prerequisite tool: "+p
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
181
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
182 def cleanup(options):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
183 if not options.keep_tmpdir:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
184 if options.verbose:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
185 print "# Cleaning up HGTMP", HGTMP
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
186 shutil.rmtree(HGTMP, True)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
187
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
188 def usecorrectpython():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
189 # some tests run python interpreter. they must use same
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
190 # interpreter we use or bad things will happen.
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191 exedir, exename = os.path.split(sys.executable)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192 if exename == 'python':
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
193 path = findprogram('python')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
194 if os.path.dirname(path) == exedir:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
195 return
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
196 vlog('# Making python executable in test path use correct Python')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
197 mypython = os.path.join(BINDIR, 'python')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
198 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
199 os.symlink(sys.executable, mypython)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200 except AttributeError:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
201 # windows fallback
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
202 shutil.copyfile(sys.executable, mypython)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
203 shutil.copymode(sys.executable, mypython)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
204
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
205 def installhg(options):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
206 global PYTHON
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
207 vlog("# Performing temporary installation of HG")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
208 installerrs = os.path.join("tests", "install.err")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
209 pure = options.pure and "--pure" or ""
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
210
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 # Run installer in hg root
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
212 os.chdir(os.path.join(os.path.dirname(sys.argv[0]), '..'))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213 cmd = ('%s setup.py %s clean --all'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
214 ' install --force --prefix="%s" --install-lib="%s"'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
215 ' --install-scripts="%s" >%s 2>&1'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
216 % (sys.executable, pure, INST, PYTHONDIR, BINDIR, installerrs))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
217 vlog("# Running", cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
218 if os.system(cmd) == 0:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
219 if not options.verbose:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
220 os.remove(installerrs)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
221 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
222 f = open(installerrs)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
223 for line in f:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
224 print line,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
225 f.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
226 sys.exit(1)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
227 os.chdir(TESTDIR)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
228
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
229 os.environ["PATH"] = "%s%s%s" % (BINDIR, os.pathsep, os.environ["PATH"])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
230
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
231 pydir = os.pathsep.join([PYTHONDIR, TESTDIR])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
232 pythonpath = os.environ.get("PYTHONPATH")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
233 if pythonpath:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
234 pythonpath = pydir + os.pathsep + pythonpath
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
235 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
236 pythonpath = pydir
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
237 os.environ["PYTHONPATH"] = pythonpath
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
238
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
239 usecorrectpython()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
240 global hgpkg
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
241 hgpkg = _hgpath()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
242
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
243 vlog("# Installing dummy diffstat")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
244 f = open(os.path.join(BINDIR, 'diffstat'), 'w')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
245 f.write('#!' + sys.executable + '\n'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
246 'import sys\n'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
247 'files = 0\n'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
248 'for line in sys.stdin:\n'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
249 ' if line.startswith("diff "):\n'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
250 ' files += 1\n'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
251 'sys.stdout.write("files patched: %d\\n" % files)\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
252 f.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
253 os.chmod(os.path.join(BINDIR, 'diffstat'), 0700)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
254
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
255 if options.anycoverage:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
256 vlog("# Installing coverage wrapper")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
257 os.environ['COVERAGE_FILE'] = COVERAGE_FILE
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
258 if os.path.exists(COVERAGE_FILE):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
259 os.unlink(COVERAGE_FILE)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
260 # Create a wrapper script to invoke hg via coverage.py
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
261 os.rename(os.path.join(BINDIR, "hg"), os.path.join(BINDIR, "_hg.py"))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
262 f = open(os.path.join(BINDIR, 'hg'), 'w')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
263 f.write('#!' + sys.executable + '\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
264 f.write('import sys, os; os.execv(sys.executable, [sys.executable, '
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
265 '"%s", "-x", "%s"] + sys.argv[1:])\n' %
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
266 (os.path.join(TESTDIR, 'coverage.py'),
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
267 os.path.join(BINDIR, '_hg.py')))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
268 f.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
269 os.chmod(os.path.join(BINDIR, 'hg'), 0700)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
270 PYTHON = '"%s" "%s" -x' % (sys.executable,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
271 os.path.join(TESTDIR,'coverage.py'))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
272
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
273 def _hgpath():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
274 cmd = '%s -c "import mercurial; print mercurial.__path__[0]"'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
275 hgpath = os.popen(cmd % PYTHON)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
276 path = hgpath.read().strip()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
277 hgpath.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
278 return path
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
279
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
280 def outputcoverage(options):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
281 vlog("# Producing coverage report")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
282 omit = [BINDIR, TESTDIR, PYTHONDIR]
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
283 if not options.cover_stdlib:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
284 # Exclude as system paths (ignoring empty strings seen on win)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
285 omit += [x for x in sys.path if x != '']
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
286 omit = ','.join(omit)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
287 os.chdir(PYTHONDIR)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
288 cmd = '"%s" "%s" -i -r "--omit=%s"' % (
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
289 sys.executable, os.path.join(TESTDIR, 'coverage.py'), omit)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
290 vlog("# Running: "+cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
291 os.system(cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
292 if options.annotate:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
293 adir = os.path.join(TESTDIR, 'annotated')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
294 if not os.path.isdir(adir):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
295 os.mkdir(adir)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
296 cmd = '"%s" "%s" -i -a "--directory=%s" "--omit=%s"' % (
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
297 sys.executable, os.path.join(TESTDIR, 'coverage.py'),
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
298 adir, omit)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
299 vlog("# Running: "+cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
300 os.system(cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
301
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
302 class Timeout(Exception):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
303 pass
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
304
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
305 def alarmed(signum, frame):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
306 raise Timeout
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
307
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
308 def run(cmd, options):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
309 """Run command in a sub-process, capturing the output (stdout and stderr).
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
310 Return the exist code, and output."""
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
311 # TODO: Use subprocess.Popen if we're running on Python 2.4
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
312 if os.name == 'nt' or sys.platform.startswith('java'):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
313 tochild, fromchild = os.popen4(cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
314 tochild.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
315 output = fromchild.read()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
316 ret = fromchild.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
317 if ret == None:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
318 ret = 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
319 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
320 proc = Popen4(cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
321 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
322 output = ''
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
323 proc.tochild.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
324 output = proc.fromchild.read()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
325 ret = proc.wait()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
326 if os.WIFEXITED(ret):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
327 ret = os.WEXITSTATUS(ret)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
328 except Timeout:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
329 vlog('# Process %d timed out - killing it' % proc.pid)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
330 os.kill(proc.pid, signal.SIGTERM)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
331 ret = proc.wait()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
332 if ret == 0:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
333 ret = signal.SIGTERM << 8
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
334 output += ("\n### Abort: timeout after %d seconds.\n"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
335 % options.timeout)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
336 return ret, splitnewlines(output)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
337
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
338 def runone(options, test, skips, fails):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
339 '''tristate output:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
340 None -> skipped
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
341 True -> passed
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
342 False -> failed'''
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
343
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
344 def skip(msg):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
345 if not options.verbose:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
346 skips.append((test, msg))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
347 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
348 print "\nSkipping %s: %s" % (test, msg)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
349 return None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
350
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
351 def fail(msg):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
352 fails.append((test, msg))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
353 if not options.nodiff:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
354 print "\nERROR: %s %s" % (test, msg)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
355 return None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
356
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
357 vlog("# Test", test)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
358
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
359 # create a fresh hgrc
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
360 hgrc = file(HGRCPATH, 'w+')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
361 hgrc.write('[ui]\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
362 hgrc.write('slash = True\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
363 hgrc.write('[defaults]\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
364 hgrc.write('backout = -d "0 0"\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
365 hgrc.write('commit = -d "0 0"\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
366 hgrc.write('debugrawcommit = -d "0 0"\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
367 hgrc.write('tag = -d "0 0"\n')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
368 hgrc.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
369
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
370 err = os.path.join(TESTDIR, test+".err")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
371 ref = os.path.join(TESTDIR, test+".out")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
372 testpath = os.path.join(TESTDIR, test)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
373
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
374 if os.path.exists(err):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
375 os.remove(err) # Remove any previous output files
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
376
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
377 # Make a tmp subdirectory to work in
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
378 tmpd = os.path.join(HGTMP, test)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
379 os.mkdir(tmpd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
380 os.chdir(tmpd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
381
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
382 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
383 tf = open(testpath)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
384 firstline = tf.readline().rstrip()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
385 tf.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
386 except:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
387 firstline = ''
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
388 lctest = test.lower()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
389
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
390 if lctest.endswith('.py') or firstline == '#!/usr/bin/env python':
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
391 cmd = '%s "%s"' % (PYTHON, testpath)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
392 elif lctest.endswith('.bat'):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
393 # do not run batch scripts on non-windows
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
394 if os.name != 'nt':
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
395 return skip("batch script")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
396 # To reliably get the error code from batch files on WinXP,
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
397 # the "cmd /c call" prefix is needed. Grrr
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
398 cmd = 'cmd /c call "%s"' % testpath
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
399 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
400 # do not run shell scripts on windows
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
401 if os.name == 'nt':
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
402 return skip("shell script")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
403 # do not try to run non-executable programs
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
404 if not os.path.exists(testpath):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
405 return fail("does not exist")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
406 elif not os.access(testpath, os.X_OK):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
407 return skip("not executable")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
408 cmd = '"%s"' % testpath
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
409
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
410 if options.timeout > 0:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
411 signal.alarm(options.timeout)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
412
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
413 vlog("# Running", cmd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
414 ret, out = run(cmd, options)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
415 vlog("# Ret was:", ret)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
416
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
417 if options.timeout > 0:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
418 signal.alarm(0)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
419
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
420 mark = '.'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
421
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
422 skipped = (ret == SKIPPED_STATUS)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
423 # If reference output file exists, check test output against it
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
424 if os.path.exists(ref):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
425 f = open(ref, "r")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
426 refout = splitnewlines(f.read())
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
427 f.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
428 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
429 refout = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
430 if skipped:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
431 mark = 's'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
432 missing, failed = parsehghaveoutput(out)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
433 if not missing:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
434 missing = ['irrelevant']
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
435 if failed:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
436 fail("hghave failed checking for %s" % failed[-1])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
437 skipped = False
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
438 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
439 skip(missing[-1])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
440 elif out != refout:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
441 mark = '!'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
442 if ret:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
443 fail("output changed and returned error code %d" % ret)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
444 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
445 fail("output changed")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
446 if not options.nodiff:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
447 showdiff(refout, out)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
448 ret = 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
449 elif ret:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
450 mark = '!'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
451 fail("returned error code %d" % ret)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
452
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
453 if not options.verbose:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
454 sys.stdout.write(mark)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
455 sys.stdout.flush()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
456
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
457 if ret != 0 and not skipped:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
458 # Save errors to a file for diagnosis
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
459 f = open(err, "wb")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
460 for line in out:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
461 f.write(line)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
462 f.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
463
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
464 # Kill off any leftover daemon processes
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
465 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
466 fp = file(DAEMON_PIDS)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
467 for line in fp:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
468 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
469 pid = int(line)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
470 except ValueError:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
471 continue
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
472 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
473 os.kill(pid, 0)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
474 vlog('# Killing daemon process %d' % pid)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
475 os.kill(pid, signal.SIGTERM)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
476 time.sleep(0.25)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
477 os.kill(pid, 0)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
478 vlog('# Daemon process %d is stuck - really killing it' % pid)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
479 os.kill(pid, signal.SIGKILL)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
480 except OSError, err:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
481 if err.errno != errno.ESRCH:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
482 raise
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
483 fp.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
484 os.unlink(DAEMON_PIDS)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
485 except IOError:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
486 pass
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
487
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
488 os.chdir(TESTDIR)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
489 if not options.keep_tmpdir:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
490 shutil.rmtree(tmpd, True)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
491 if skipped:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
492 return None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
493 return ret == 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
494
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
495 def runchildren(options, expecthg, tests):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
496 if not options.with_hg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
497 installhg(options)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
498 if hgpkg != expecthg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
499 print '# Testing unexpected mercurial: %s' % hgpkg
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
500
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
501 optcopy = dict(options.__dict__)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
502 optcopy['jobs'] = 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
503 optcopy['with_hg'] = INST
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
504 opts = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
505 for opt, value in optcopy.iteritems():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
506 name = '--' + opt.replace('_', '-')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
507 if value is True:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
508 opts.append(name)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
509 elif value is not None:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
510 opts.append(name + '=' + str(value))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
511
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
512 tests.reverse()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
513 jobs = [[] for j in xrange(options.jobs)]
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
514 while tests:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
515 for job in jobs:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
516 if not tests: break
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
517 job.append(tests.pop())
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
518 fps = {}
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
519 for j, job in enumerate(jobs):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
520 if not job:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
521 continue
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
522 rfd, wfd = os.pipe()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
523 childopts = ['--child=%d' % wfd, '--port=%d' % (options.port + j * 3)]
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
524 cmdline = [PYTHON, sys.argv[0]] + opts + childopts + job
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
525 vlog(' '.join(cmdline))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
526 fps[os.spawnvp(os.P_NOWAIT, cmdline[0], cmdline)] = os.fdopen(rfd, 'r')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
527 os.close(wfd)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
528 failures = 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
529 tested, skipped, failed = 0, 0, 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
530 skips = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
531 fails = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
532 while fps:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
533 pid, status = os.wait()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
534 fp = fps.pop(pid)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
535 l = fp.read().splitlines()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
536 test, skip, fail = map(int, l[:3])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
537 split = -fail or len(l)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
538 for s in l[3:split]:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
539 skips.append(s.split(" ", 1))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
540 for s in l[split:]:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
541 fails.append(s.split(" ", 1))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
542 tested += test
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
543 skipped += skip
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
544 failed += fail
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
545 vlog('pid %d exited, status %d' % (pid, status))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
546 failures |= status
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
547 print
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
548 for s in skips:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
549 print "Skipped %s: %s" % (s[0], s[1])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
550 for s in fails:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
551 print "Failed %s: %s" % (s[0], s[1])
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
552
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
553 if hgpkg != expecthg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
554 print '# Tested unexpected mercurial: %s' % hgpkg
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
555 print "# Ran %d tests, %d skipped, %d failed." % (
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
556 tested, skipped, failed)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
557 sys.exit(failures != 0)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
558
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
559 def runtests(options, expecthg, tests):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
560 global DAEMON_PIDS, HGRCPATH
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
561 DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
562 HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
563
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
564 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
565 if not options.with_hg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
566 installhg(options)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
567
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
568 if hgpkg != expecthg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
569 print '# Testing unexpected mercurial: %s' % hgpkg
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
570
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
571 if options.timeout > 0:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
572 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
573 signal.signal(signal.SIGALRM, alarmed)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
574 vlog('# Running tests with %d-second timeout' %
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
575 options.timeout)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
576 except AttributeError:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
577 print 'WARNING: cannot run tests with timeouts'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
578 options.timeout = 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
579
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
580 tested = 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
581 failed = 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
582 skipped = 0
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
583
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
584 if options.restart:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
585 orig = list(tests)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
586 while tests:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
587 if os.path.exists(tests[0] + ".err"):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
588 break
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
589 tests.pop(0)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
590 if not tests:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
591 print "running all tests"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
592 tests = orig
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
593
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
594 skips = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
595 fails = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
596 for test in tests:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
597 if options.retest and not os.path.exists(test + ".err"):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
598 skipped += 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
599 continue
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
600 ret = runone(options, test, skips, fails)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
601 if ret is None:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
602 skipped += 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
603 elif not ret:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
604 if options.interactive:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
605 print "Accept this change? [n] ",
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
606 answer = sys.stdin.readline().strip()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
607 if answer.lower() in "y yes".split():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
608 rename(test + ".err", test + ".out")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
609 tested += 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
610 fails.pop()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
611 continue
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
612 failed += 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
613 if options.first:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
614 break
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
615 tested += 1
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
616
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
617 if options.child:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
618 fp = os.fdopen(options.child, 'w')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
619 fp.write('%d\n%d\n%d\n' % (tested, skipped, failed))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
620 for s in skips:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
621 fp.write("%s %s\n" % s)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
622 for s in fails:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
623 fp.write("%s %s\n" % s)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
624 fp.close()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
625 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
626 print
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
627 for s in skips:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
628 print "Skipped %s: %s" % s
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
629 for s in fails:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
630 print "Failed %s: %s" % s
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
631 if hgpkg != expecthg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
632 print '# Tested unexpected mercurial: %s' % hgpkg
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
633 print "# Ran %d tests, %d skipped, %d failed." % (
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
634 tested, skipped, failed)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
635
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
636 if options.anycoverage:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
637 outputcoverage(options)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
638 except KeyboardInterrupt:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
639 failed = True
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
640 print "\ninterrupted!"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
641
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
642 if failed:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
643 sys.exit(1)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
644
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
645 hgpkg = None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
646 def main():
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
647 (options, args) = parseargs()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
648 if not options.child:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
649 os.umask(022)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
650
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
651 checktools()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
652
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
653 # Reset some environment variables to well-known values so that
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
654 # the tests produce repeatable output.
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
655 os.environ['LANG'] = os.environ['LC_ALL'] = 'C'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
656 os.environ['TZ'] = 'GMT'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
657 os.environ["EMAIL"] = "Foo Bar <foo.bar@example.com>"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
658 os.environ['CDPATH'] = ''
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
659
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
660 global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
661 TESTDIR = os.environ["TESTDIR"] = os.getcwd()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
662 HGTMP = os.environ['HGTMP'] = os.path.realpath(tempfile.mkdtemp('', 'hgtests.',
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
663 options.tmpdir))
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
664 DAEMON_PIDS = None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
665 HGRCPATH = None
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
666
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
667 os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"'
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
668 os.environ["HGMERGE"] = "internal:merge"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
669 os.environ["HGUSER"] = "test"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
670 os.environ["HGENCODING"] = "ascii"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
671 os.environ["HGENCODINGMODE"] = "strict"
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
672 os.environ["HGPORT"] = str(options.port)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
673 os.environ["HGPORT1"] = str(options.port + 1)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
674 os.environ["HGPORT2"] = str(options.port + 2)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
675
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
676 if options.with_hg:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
677 INST = options.with_hg
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
678 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
679 INST = os.path.join(HGTMP, "install")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
680 BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
681 PYTHONDIR = os.path.join(INST, "lib", "python")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
682 COVERAGE_FILE = os.path.join(TESTDIR, ".coverage")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
683
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
684 expecthg = os.path.join(HGTMP, 'install', 'lib', 'python', 'mercurial')
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
685
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
686 if len(args) == 0:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
687 args = os.listdir(".")
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
688 args.sort()
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
689
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
690 tests = []
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
691 for test in args:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
692 if (test.startswith("test-") and '~' not in test and
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
693 ('.' not in test or test.endswith('.py') or
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
694 test.endswith('.bat'))):
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
695 tests.append(test)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
696
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
697 vlog("# Using TESTDIR", TESTDIR)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
698 vlog("# Using HGTMP", HGTMP)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
699
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
700 try:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
701 if len(tests) > 1 and options.jobs > 1:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
702 runchildren(options, expecthg, tests)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
703 else:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
704 runtests(options, expecthg, tests)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
705 finally:
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
706 cleanup(options)
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
707
4ee030a94d79 Slightly modified run-tests.py so that tests can run self-contained.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
708 main()