author | Christian Ebert <blacktrash@gmx.net> |
Fri, 05 Nov 2010 10:01:23 +0000 | |
branch | stable |
changeset 855 | eca16536349a |
parent 852 | fb1e8925292d |
child 856 | e1a5259b3d03 |
permissions | -rwxr-xr-x |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
2 |
# |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
3 |
# run-tests.py - Run a set of tests on Mercurial |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
4 |
# |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
5 |
# Copyright 2006 Matt Mackall <mpm@selenic.com> |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
6 |
# |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
7 |
# This software may be used and distributed according to the terms of the |
674 | 8 |
# GNU General Public License version 2 or any later version. |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
9 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
10 |
# Modifying this script is tricky because it has many modes: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
11 |
# - serial (default) vs parallel (-jN, N > 1) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
12 |
# - no coverage (default) vs coverage (-c, -C, -s) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
13 |
# - temp install (default) vs specific hg script (--with-hg, --local) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
14 |
# - tests are a mix of shell scripts and Python scripts |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
15 |
# |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
16 |
# If you change this script, it is recommended that you ensure you |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
17 |
# haven't broken it by running it in various modes with a representative |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
18 |
# sample of test scripts. For example: |
670 | 19 |
# |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
20 |
# 1) serial, no coverage, temp install: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
21 |
# ./run-tests.py test-s* |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
22 |
# 2) serial, no coverage, local hg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
23 |
# ./run-tests.py --local test-s* |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
24 |
# 3) serial, coverage, temp install: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
25 |
# ./run-tests.py -c test-s* |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
26 |
# 4) serial, coverage, local hg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
27 |
# ./run-tests.py -c --local test-s* # unsupported |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
28 |
# 5) parallel, no coverage, temp install: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
29 |
# ./run-tests.py -j2 test-s* |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
30 |
# 6) parallel, no coverage, local hg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
31 |
# ./run-tests.py -j2 --local test-s* |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
32 |
# 7) parallel, coverage, temp install: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
33 |
# ./run-tests.py -j2 -c test-s* # currently broken |
670 | 34 |
# 8) parallel, coverage, local install: |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
35 |
# ./run-tests.py -j2 -c --local test-s* # unsupported (and broken) |
670 | 36 |
# 9) parallel, custom tmp dir: |
37 |
# ./run-tests.py -j2 --tmpdir /tmp/myhgtests |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
38 |
# |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
39 |
# (You could use any subset of the tests: test-s* happens to match |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
40 |
# enough that it's worth doing parallel runs, few enough that it |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
41 |
# completes fairly quickly, includes both shell and Python scripts, and |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
42 |
# includes some scripts that run daemon processes.) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
43 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
44 |
from distutils import version |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
45 |
import difflib |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
46 |
import errno |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
47 |
import optparse |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
48 |
import os |
726
f7050b041b5f
pylint, pyflakes: remove unused or duplicate imports
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
725
diff
changeset
|
49 |
import shutil |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
50 |
import subprocess |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
51 |
import signal |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
52 |
import sys |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
53 |
import tempfile |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
54 |
import time |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
55 |
import re |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
56 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
57 |
closefds = os.name == 'posix' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
58 |
def Popen4(cmd, bufsize=-1): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
59 |
p = subprocess.Popen(cmd, shell=True, bufsize=bufsize, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
60 |
close_fds=closefds, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
61 |
stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
62 |
stderr=subprocess.STDOUT) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
63 |
p.fromchild = p.stdout |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
64 |
p.tochild = p.stdin |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
65 |
p.childerr = p.stderr |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
66 |
return p |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
67 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
68 |
# reserved exit code to skip test (used by hghave) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
69 |
SKIPPED_STATUS = 80 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
70 |
SKIPPED_PREFIX = 'skipped: ' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
71 |
FAILED_PREFIX = 'hghave check failed: ' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
72 |
PYTHON = sys.executable |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
73 |
IMPL_PATH = 'PYTHONPATH' |
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
74 |
if 'java' in sys.platform: |
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
75 |
IMPL_PATH = 'JYTHONPATH' |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
76 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
77 |
requiredtools = ["python", "diff", "grep", "unzip", "gunzip", "bunzip2", "sed"] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
78 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
79 |
defaults = { |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
80 |
'jobs': ('HGTEST_JOBS', 1), |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
81 |
'timeout': ('HGTEST_TIMEOUT', 180), |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
82 |
'port': ('HGTEST_PORT', 20059), |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
83 |
} |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
84 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
85 |
def parseargs(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
86 |
parser = optparse.OptionParser("%prog [options] [tests]") |
740 | 87 |
|
88 |
# keep these sorted |
|
89 |
parser.add_option("--blacklist", action="append", |
|
90 |
help="skip tests listed in the specified blacklist file") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
91 |
parser.add_option("-C", "--annotate", action="store_true", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
92 |
help="output files annotated with coverage") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
93 |
parser.add_option("--child", type="int", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
94 |
help="run as child process, summary to given fd") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
95 |
parser.add_option("-c", "--cover", action="store_true", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
96 |
help="print a test coverage report") |
740 | 97 |
parser.add_option("-d", "--debug", action="store_true", |
98 |
help="debug mode: write output of test scripts to console" |
|
99 |
" rather than capturing and diff'ing it (disables timeout)") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
100 |
parser.add_option("-f", "--first", action="store_true", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
101 |
help="exit on the first test failure") |
740 | 102 |
parser.add_option("--inotify", action="store_true", |
103 |
help="enable inotify extension when running tests") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
104 |
parser.add_option("-i", "--interactive", action="store_true", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
105 |
help="prompt to accept changed output") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
106 |
parser.add_option("-j", "--jobs", type="int", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
107 |
help="number of jobs to run in parallel" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
108 |
" (default: $%s or %d)" % defaults['jobs']) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
109 |
parser.add_option("--keep-tmpdir", action="store_true", |
670 | 110 |
help="keep temporary directory after running tests") |
740 | 111 |
parser.add_option("-k", "--keywords", |
112 |
help="run tests matching keywords") |
|
113 |
parser.add_option("-l", "--local", action="store_true", |
|
114 |
help="shortcut for --with-hg=<testdir>/../hg") |
|
115 |
parser.add_option("-n", "--nodiff", action="store_true", |
|
116 |
help="skip showing test changes") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
117 |
parser.add_option("-p", "--port", type="int", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
118 |
help="port on which servers should listen" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
119 |
" (default: $%s or %d)" % defaults['port']) |
740 | 120 |
parser.add_option("--pure", action="store_true", |
121 |
help="use pure Python code instead of C extensions") |
|
122 |
parser.add_option("-R", "--restart", action="store_true", |
|
123 |
help="restart at last error") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
124 |
parser.add_option("-r", "--retest", action="store_true", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
125 |
help="retest failed tests") |
670 | 126 |
parser.add_option("-S", "--noskips", action="store_true", |
127 |
help="don't report skip tests verbosely") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
128 |
parser.add_option("-t", "--timeout", type="int", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
129 |
help="kill errant tests after TIMEOUT seconds" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
130 |
" (default: $%s or %d)" % defaults['timeout']) |
740 | 131 |
parser.add_option("--tmpdir", type="string", |
132 |
help="run tests in the given temporary directory" |
|
133 |
" (implies --keep-tmpdir)") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
134 |
parser.add_option("-v", "--verbose", action="store_true", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
135 |
help="output verbose messages") |
741
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
136 |
parser.add_option("--view", type="string", |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
137 |
help="external diff viewer") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
138 |
parser.add_option("--with-hg", type="string", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
139 |
metavar="HG", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
140 |
help="test using specified hg script rather than a " |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
141 |
"temporary installation") |
670 | 142 |
parser.add_option("-3", "--py3k-warnings", action="store_true", |
143 |
help="enable Py3k warnings on Python 2.6+") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
144 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
145 |
for option, default in defaults.items(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
146 |
defaults[option] = int(os.environ.get(*default)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
147 |
parser.set_defaults(**defaults) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
148 |
(options, args) = parser.parse_args() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
149 |
|
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
150 |
# jython is always pure |
722
85da4926cf39
run-tests: force to test pure on pypy as well
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
721
diff
changeset
|
151 |
if 'java' in sys.platform or '__pypy__' in sys.modules: |
721
1dbc96b10ebd
Fix run-tests.py -jX after 2ed667a9dfcb
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
720
diff
changeset
|
152 |
options.pure = True |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
153 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
154 |
if options.with_hg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
155 |
if not (os.path.isfile(options.with_hg) and |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
156 |
os.access(options.with_hg, os.X_OK)): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
157 |
parser.error('--with-hg must specify an executable hg script') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
158 |
if not os.path.basename(options.with_hg) == 'hg': |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
159 |
sys.stderr.write('warning: --with-hg should specify an hg script') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
160 |
if options.local: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
161 |
testdir = os.path.dirname(os.path.realpath(sys.argv[0])) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
162 |
hgbin = os.path.join(os.path.dirname(testdir), 'hg') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
163 |
if not os.access(hgbin, os.X_OK): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
164 |
parser.error('--local specified, but %r not found or not executable' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
165 |
% hgbin) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
166 |
options.with_hg = hgbin |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
167 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
168 |
options.anycoverage = options.cover or options.annotate |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
169 |
if options.anycoverage: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
170 |
try: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
171 |
import coverage |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
172 |
covver = version.StrictVersion(coverage.__version__).version |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
173 |
if covver < (3, 3): |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
174 |
parser.error('coverage options require coverage 3.3 or later') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
175 |
except ImportError: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
176 |
parser.error('coverage options now require the coverage package') |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
177 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
178 |
if options.anycoverage and options.local: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
179 |
# this needs some path mangling somewhere, I guess |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
180 |
parser.error("sorry, coverage options do not work when --local " |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
181 |
"is specified") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
182 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
183 |
global vlog |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
184 |
if options.verbose: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
185 |
if options.jobs > 1 or options.child is not None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
186 |
pid = "[%d]" % os.getpid() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
187 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
188 |
pid = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
189 |
def vlog(*msg): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
190 |
if pid: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
191 |
print pid, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
192 |
for m in msg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
193 |
print m, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
194 |
print |
670 | 195 |
sys.stdout.flush() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
196 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
197 |
vlog = lambda *msg: None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
198 |
|
670 | 199 |
if options.tmpdir: |
200 |
options.tmpdir = os.path.expanduser(options.tmpdir) |
|
201 |
||
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
202 |
if options.jobs < 1: |
670 | 203 |
parser.error('--jobs must be positive') |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
204 |
if options.interactive and options.jobs > 1: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
205 |
print '(--interactive overrides --jobs)' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
206 |
options.jobs = 1 |
670 | 207 |
if options.interactive and options.debug: |
208 |
parser.error("-i/--interactive and -d/--debug are incompatible") |
|
209 |
if options.debug: |
|
210 |
if options.timeout != defaults['timeout']: |
|
211 |
sys.stderr.write( |
|
212 |
'warning: --timeout option ignored with --debug\n') |
|
213 |
options.timeout = 0 |
|
214 |
if options.py3k_warnings: |
|
215 |
if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0): |
|
216 |
parser.error('--py3k-warnings can only be used on Python 2.6+') |
|
217 |
if options.blacklist: |
|
218 |
blacklist = dict() |
|
681
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
219 |
for filename in options.blacklist: |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
220 |
try: |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
221 |
path = os.path.expanduser(os.path.expandvars(filename)) |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
222 |
f = open(path, "r") |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
223 |
except IOError, err: |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
224 |
if err.errno != errno.ENOENT: |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
225 |
raise |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
226 |
print "warning: no such blacklist file: %s" % filename |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
227 |
continue |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
228 |
|
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
229 |
for line in f.readlines(): |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
230 |
line = line.strip() |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
231 |
if line and not line.startswith('#'): |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
232 |
blacklist[line] = filename |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
233 |
|
670 | 234 |
options.blacklist = blacklist |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
235 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
236 |
return (options, args) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
237 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
238 |
def rename(src, dst): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
239 |
"""Like os.rename(), trade atomicity and opened files friendliness |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
240 |
for existing destination support. |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
241 |
""" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
242 |
shutil.copy(src, dst) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
243 |
os.remove(src) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
244 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
245 |
def splitnewlines(text): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
246 |
'''like str.splitlines, but only split on newlines. |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
247 |
keep line endings.''' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
248 |
i = 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
249 |
lines = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
250 |
while True: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
251 |
n = text.find('\n', i) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
252 |
if n == -1: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
253 |
last = text[i:] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
254 |
if last: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
255 |
lines.append(last) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
256 |
return lines |
680
f10a5301d082
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
674
diff
changeset
|
257 |
lines.append(text[i:n + 1]) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
258 |
i = n + 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
259 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
260 |
def parsehghaveoutput(lines): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
261 |
'''Parse hghave log lines. |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
262 |
Return tuple of lists (missing, failed): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
263 |
* the missing/unknown features |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
264 |
* the features for which existence check failed''' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
265 |
missing = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
266 |
failed = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
267 |
for line in lines: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
268 |
if line.startswith(SKIPPED_PREFIX): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
269 |
line = line.splitlines()[0] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
270 |
missing.append(line[len(SKIPPED_PREFIX):]) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
271 |
elif line.startswith(FAILED_PREFIX): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
272 |
line = line.splitlines()[0] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
273 |
failed.append(line[len(FAILED_PREFIX):]) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
274 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
275 |
return missing, failed |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
276 |
|
670 | 277 |
def showdiff(expected, output, ref, err): |
278 |
for line in difflib.unified_diff(expected, output, ref, err): |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
279 |
sys.stdout.write(line) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
280 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
281 |
def findprogram(program): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
282 |
"""Search PATH for a executable program""" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
283 |
for p in os.environ.get('PATH', os.defpath).split(os.pathsep): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
284 |
name = os.path.join(p, program) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
285 |
if os.access(name, os.X_OK): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
286 |
return name |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
287 |
return None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
288 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
289 |
def checktools(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
290 |
# Before we go any further, check for pre-requisite tools |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
291 |
# stuff from coreutils (cat, rm, etc) are not tested |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
292 |
for p in requiredtools: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
293 |
if os.name == 'nt': |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
294 |
p += '.exe' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
295 |
found = findprogram(p) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
296 |
if found: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
297 |
vlog("# Found prerequisite", p, "at", found) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
298 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
299 |
print "WARNING: Did not find prerequisite tool: "+p |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
300 |
|
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
301 |
def killdaemons(): |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
302 |
# Kill off any leftover daemon processes |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
303 |
try: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
304 |
fp = open(DAEMON_PIDS) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
305 |
for line in fp: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
306 |
try: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
307 |
pid = int(line) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
308 |
except ValueError: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
309 |
continue |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
310 |
try: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
311 |
os.kill(pid, 0) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
312 |
vlog('# Killing daemon process %d' % pid) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
313 |
os.kill(pid, signal.SIGTERM) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
314 |
time.sleep(0.25) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
315 |
os.kill(pid, 0) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
316 |
vlog('# Daemon process %d is stuck - really killing it' % pid) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
317 |
os.kill(pid, signal.SIGKILL) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
318 |
except OSError, err: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
319 |
if err.errno != errno.ESRCH: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
320 |
raise |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
321 |
fp.close() |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
322 |
os.unlink(DAEMON_PIDS) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
323 |
except IOError: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
324 |
pass |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
325 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
326 |
def cleanup(options): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
327 |
if not options.keep_tmpdir: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
328 |
vlog("# Cleaning up HGTMP", HGTMP) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
329 |
shutil.rmtree(HGTMP, True) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
330 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
331 |
def usecorrectpython(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
332 |
# some tests run python interpreter. they must use same |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
333 |
# interpreter we use or bad things will happen. |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
334 |
exedir, exename = os.path.split(sys.executable) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
335 |
if exename == 'python': |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
336 |
path = findprogram('python') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
337 |
if os.path.dirname(path) == exedir: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
338 |
return |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
339 |
vlog('# Making python executable in test path use correct Python') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
340 |
mypython = os.path.join(BINDIR, 'python') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
341 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
342 |
os.symlink(sys.executable, mypython) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
343 |
except AttributeError: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
344 |
# windows fallback |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
345 |
shutil.copyfile(sys.executable, mypython) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
346 |
shutil.copymode(sys.executable, mypython) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
347 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
348 |
def installhg(options): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
349 |
vlog("# Performing temporary installation of HG") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
350 |
installerrs = os.path.join("tests", "install.err") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
351 |
pure = options.pure and "--pure" or "" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
352 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
353 |
# Run installer in hg root |
670 | 354 |
script = os.path.realpath(sys.argv[0]) |
355 |
hgroot = os.path.dirname(os.path.dirname(script)) |
|
356 |
os.chdir(hgroot) |
|
357 |
nohome = '--home=""' |
|
358 |
if os.name == 'nt': |
|
359 |
# The --home="" trick works only on OS where os.sep == '/' |
|
360 |
# because of a distutils convert_path() fast-path. Avoid it at |
|
361 |
# least on Windows for now, deal with .pydistutils.cfg bugs |
|
362 |
# when they happen. |
|
363 |
nohome = '' |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
364 |
cmd = ('%s setup.py %s clean --all' |
822
842e2c76e64b
run-tests: move build/ directory to HGTMP
Martin Geisler <mg@lazybytes.net>
parents:
802
diff
changeset
|
365 |
' build --build-base="%s"' |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
366 |
' install --force --prefix="%s" --install-lib="%s"' |
670 | 367 |
' --install-scripts="%s" %s >%s 2>&1' |
822
842e2c76e64b
run-tests: move build/ directory to HGTMP
Martin Geisler <mg@lazybytes.net>
parents:
802
diff
changeset
|
368 |
% (sys.executable, pure, os.path.join(HGTMP, "build"), |
842e2c76e64b
run-tests: move build/ directory to HGTMP
Martin Geisler <mg@lazybytes.net>
parents:
802
diff
changeset
|
369 |
INST, PYTHONDIR, BINDIR, nohome, installerrs)) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
370 |
vlog("# Running", cmd) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
371 |
if os.system(cmd) == 0: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
372 |
if not options.verbose: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
373 |
os.remove(installerrs) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
374 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
375 |
f = open(installerrs) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
376 |
for line in f: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
377 |
print line, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
378 |
f.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
379 |
sys.exit(1) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
380 |
os.chdir(TESTDIR) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
381 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
382 |
usecorrectpython() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
383 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
384 |
vlog("# Installing dummy diffstat") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
385 |
f = open(os.path.join(BINDIR, 'diffstat'), 'w') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
386 |
f.write('#!' + sys.executable + '\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
387 |
'import sys\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
388 |
'files = 0\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
389 |
'for line in sys.stdin:\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
390 |
' if line.startswith("diff "):\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
391 |
' files += 1\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
392 |
'sys.stdout.write("files patched: %d\\n" % files)\n') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
393 |
f.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
394 |
os.chmod(os.path.join(BINDIR, 'diffstat'), 0700) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
395 |
|
670 | 396 |
if options.py3k_warnings and not options.anycoverage: |
397 |
vlog("# Updating hg command to enable Py3k Warnings switch") |
|
398 |
f = open(os.path.join(BINDIR, 'hg'), 'r') |
|
399 |
lines = [line.rstrip() for line in f] |
|
400 |
lines[0] += ' -3' |
|
401 |
f.close() |
|
402 |
f = open(os.path.join(BINDIR, 'hg'), 'w') |
|
403 |
for line in lines: |
|
404 |
f.write(line + '\n') |
|
405 |
f.close() |
|
406 |
||
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
407 |
if options.anycoverage: |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
408 |
custom = os.path.join(TESTDIR, 'sitecustomize.py') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
409 |
target = os.path.join(PYTHONDIR, 'sitecustomize.py') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
410 |
vlog('# Installing coverage trigger to %s' % target) |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
411 |
shutil.copyfile(custom, target) |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
412 |
rc = os.path.join(TESTDIR, '.coveragerc') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
413 |
vlog('# Installing coverage rc to %s' % rc) |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
414 |
os.environ['COVERAGE_PROCESS_START'] = rc |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
415 |
fn = os.path.join(INST, '..', '.coverage') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
416 |
os.environ['COVERAGE_FILE'] = fn |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
417 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
418 |
def outputcoverage(options): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
419 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
420 |
vlog('# Producing coverage report') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
421 |
os.chdir(PYTHONDIR) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
422 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
423 |
def covrun(*args): |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
424 |
cmd = 'coverage %s' % ' '.join(args) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
425 |
vlog('# Running: %s' % cmd) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
426 |
os.system(cmd) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
427 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
428 |
if options.child: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
429 |
return |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
430 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
431 |
covrun('-c') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
432 |
omit = ','.join([BINDIR, TESTDIR]) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
433 |
covrun('-i', '-r', '"--omit=%s"' % omit) # report |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
434 |
if options.annotate: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
435 |
adir = os.path.join(TESTDIR, 'annotated') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
436 |
if not os.path.isdir(adir): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
437 |
os.mkdir(adir) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
438 |
covrun('-i', '-a', '"--directory=%s"' % adir, '"--omit=%s"' % omit) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
439 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
440 |
class Timeout(Exception): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
441 |
pass |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
442 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
443 |
def alarmed(signum, frame): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
444 |
raise Timeout |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
445 |
|
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
446 |
def pytest(test, options, replacements): |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
447 |
py3kswitch = options.py3k_warnings and ' -3' or '' |
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
448 |
cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test) |
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
449 |
vlog("# Running", cmd) |
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
450 |
return run(cmd, options, replacements) |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
451 |
|
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
452 |
def shtest(test, options, replacements): |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
453 |
cmd = '"%s"' % test |
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
454 |
vlog("# Running", cmd) |
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
455 |
return run(cmd, options, replacements) |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
456 |
|
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
457 |
def tsttest(test, options, replacements): |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
458 |
t = open(test) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
459 |
out = [] |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
460 |
script = [] |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
461 |
salt = "SALT" + str(time.time()) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
462 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
463 |
pos = prepos = -1 |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
464 |
after = {} |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
465 |
expected = {} |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
466 |
for n, l in enumerate(t): |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
467 |
if l.startswith(' $ '): # commands |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
468 |
after.setdefault(pos, []).append(l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
469 |
prepos = pos |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
470 |
pos = n |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
471 |
script.append('echo %s %s $?\n' % (salt, n)) |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
472 |
script.append(l[4:]) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
473 |
elif l.startswith(' > '): # continuations |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
474 |
after.setdefault(prepos, []).append(l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
475 |
script.append(l[4:]) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
476 |
elif l.startswith(' '): # results |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
477 |
# queue up a list of expected results |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
478 |
expected.setdefault(pos, []).append(l[2:]) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
479 |
else: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
480 |
# non-command/result - queue up for merged output |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
481 |
after.setdefault(pos, []).append(l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
482 |
|
824
6d3f8caef3b3
run-tests: handle .tst not ending with an LF
Patrick Mezard <pmezard@gmail.com>
parents:
823
diff
changeset
|
483 |
if script and not script[-1].endswith('\n'): |
6d3f8caef3b3
run-tests: handle .tst not ending with an LF
Patrick Mezard <pmezard@gmail.com>
parents:
823
diff
changeset
|
484 |
script[-1] = script[-1] + '\n' |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
485 |
script.append('echo %s %s $?\n' % (salt, n + 1)) |
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
486 |
|
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
487 |
fd, name = tempfile.mkstemp(suffix='hg-tst') |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
488 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
489 |
try: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
490 |
for l in script: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
491 |
os.write(fd, l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
492 |
os.close(fd) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
493 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
494 |
cmd = '/bin/sh "%s"' % name |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
495 |
vlog("# Running", cmd) |
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
496 |
exitcode, output = run(cmd, options, replacements) |
823
ab2ba4e79bed
tests: show skip reason instead of "irrelevant" with unified tests, too
Thomas Arendsen Hein <thomas@intevation.de>
parents:
822
diff
changeset
|
497 |
# do not merge output if skipped, return hghave message instead |
ab2ba4e79bed
tests: show skip reason instead of "irrelevant" with unified tests, too
Thomas Arendsen Hein <thomas@intevation.de>
parents:
822
diff
changeset
|
498 |
if exitcode == SKIPPED_STATUS: |
ab2ba4e79bed
tests: show skip reason instead of "irrelevant" with unified tests, too
Thomas Arendsen Hein <thomas@intevation.de>
parents:
822
diff
changeset
|
499 |
return exitcode, output |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
500 |
finally: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
501 |
os.remove(name) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
502 |
|
777
cd294ce45931
tests: catch re.error if test line is not a valid regular expression
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
776
diff
changeset
|
503 |
def rematch(el, l): |
cd294ce45931
tests: catch re.error if test line is not a valid regular expression
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
776
diff
changeset
|
504 |
try: |
799
c20c12c560dd
tests: ensure regexes match to the end of the string
Brodie Rao <brodie@bitheap.org>
parents:
798
diff
changeset
|
505 |
# ensure that the regex matches to the end of the string |
c20c12c560dd
tests: ensure regexes match to the end of the string
Brodie Rao <brodie@bitheap.org>
parents:
798
diff
changeset
|
506 |
return re.match(el + r'\Z', l) |
777
cd294ce45931
tests: catch re.error if test line is not a valid regular expression
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
776
diff
changeset
|
507 |
except re.error: |
cd294ce45931
tests: catch re.error if test line is not a valid regular expression
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
776
diff
changeset
|
508 |
# el is an invalid regex |
cd294ce45931
tests: catch re.error if test line is not a valid regular expression
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
776
diff
changeset
|
509 |
return False |
cd294ce45931
tests: catch re.error if test line is not a valid regular expression
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
776
diff
changeset
|
510 |
|
801
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
511 |
def globmatch(el, l): |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
512 |
# The only supported special characters are * and ?. Escaping is |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
513 |
# supported. |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
514 |
i, n = 0, len(el) |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
515 |
res = '' |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
516 |
while i < n: |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
517 |
c = el[i] |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
518 |
i += 1 |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
519 |
if c == '\\' and el[i] in '*?\\': |
802
630d72ae4f76
tests: various fixes for new unified test pattern format
Matt Mackall <mpm@selenic.com>
parents:
801
diff
changeset
|
520 |
res += el[i - 1:i + 1] |
801
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
521 |
i += 1 |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
522 |
elif c == '*': |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
523 |
res += '.*' |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
524 |
elif c == '?': |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
525 |
res += '.' |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
526 |
else: |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
527 |
res += re.escape(c) |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
528 |
return rematch(res, l) |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
529 |
|
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
530 |
pos = -1 |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
531 |
postout = [] |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
532 |
ret = 0 |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
533 |
for n, l in enumerate(output): |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
534 |
if l.startswith(salt): |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
535 |
# add on last return code |
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
536 |
ret = int(l.split()[2]) |
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
537 |
if ret != 0: |
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
538 |
postout.append(" [%s]\n" % ret) |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
539 |
if pos in after: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
540 |
postout += after.pop(pos) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
541 |
pos = int(l.split()[1]) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
542 |
else: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
543 |
el = None |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
544 |
if pos in expected and expected[pos]: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
545 |
el = expected[pos].pop(0) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
546 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
547 |
if el == l: # perfect match (fast) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
548 |
postout.append(" " + l) |
844
e5e1c16fe5b7
tests: accept \-escaped test output
Yuya Nishihara <yuya@tcha.org>
parents:
834
diff
changeset
|
549 |
elif el and el.decode('string-escape') == l: |
e5e1c16fe5b7
tests: accept \-escaped test output
Yuya Nishihara <yuya@tcha.org>
parents:
834
diff
changeset
|
550 |
postout.append(" " + el) # \-escape match |
801
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
551 |
elif (el and |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
552 |
(el.endswith(" (re)\n") and rematch(el[:-6] + '\n', l) or |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
553 |
el.endswith(" (glob)\n") and globmatch(el[:-8] + '\n', l))): |
413c6fe6d1e3
tests: add glob matching for unified tests
Brodie Rao <brodie@bitheap.org>
parents:
800
diff
changeset
|
554 |
postout.append(" " + el) # fallback regex/glob match |
800
c4211177a2fc
tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
799
diff
changeset
|
555 |
else: |
c4211177a2fc
tests: require regexes in unified tests to be marked with " (re)"
Brodie Rao <brodie@bitheap.org>
parents:
799
diff
changeset
|
556 |
postout.append(" " + l) # let diff deal with it |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
557 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
558 |
if pos in after: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
559 |
postout += after.pop(pos) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
560 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
561 |
return exitcode, postout |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
562 |
|
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
563 |
def run(cmd, options, replacements): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
564 |
"""Run command in a sub-process, capturing the output (stdout and stderr). |
670 | 565 |
Return a tuple (exitcode, output). output is None in debug mode.""" |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
566 |
# TODO: Use subprocess.Popen if we're running on Python 2.4 |
670 | 567 |
if options.debug: |
568 |
proc = subprocess.Popen(cmd, shell=True) |
|
569 |
ret = proc.wait() |
|
570 |
return (ret, None) |
|
571 |
||
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
572 |
if os.name == 'nt' or sys.platform.startswith('java'): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
573 |
tochild, fromchild = os.popen4(cmd) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
574 |
tochild.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
575 |
output = fromchild.read() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
576 |
ret = fromchild.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
577 |
if ret == None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
578 |
ret = 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
579 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
580 |
proc = Popen4(cmd) |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
581 |
def cleanup(): |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
582 |
os.kill(proc.pid, signal.SIGTERM) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
583 |
ret = proc.wait() |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
584 |
if ret == 0: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
585 |
ret = signal.SIGTERM << 8 |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
586 |
killdaemons() |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
587 |
return ret |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
588 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
589 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
590 |
output = '' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
591 |
proc.tochild.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
592 |
output = proc.fromchild.read() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
593 |
ret = proc.wait() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
594 |
if os.WIFEXITED(ret): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
595 |
ret = os.WEXITSTATUS(ret) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
596 |
except Timeout: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
597 |
vlog('# Process %d timed out - killing it' % proc.pid) |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
598 |
ret = cleanup() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
599 |
output += ("\n### Abort: timeout after %d seconds.\n" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
600 |
% options.timeout) |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
601 |
except KeyboardInterrupt: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
602 |
vlog('# Handling keyboard interrupt') |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
603 |
cleanup() |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
604 |
raise |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
605 |
|
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
606 |
for s, r in replacements: |
852
fb1e8925292d
run-tests: use regex when searching for $HGPORT in test output
Martin Geisler <mg@aragost.com>
parents:
844
diff
changeset
|
607 |
output = re.sub(s, r, output) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
608 |
return ret, splitnewlines(output) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
609 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
610 |
def runone(options, test, skips, fails): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
611 |
'''tristate output: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
612 |
None -> skipped |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
613 |
True -> passed |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
614 |
False -> failed''' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
615 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
616 |
def skip(msg): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
617 |
if not options.verbose: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
618 |
skips.append((test, msg)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
619 |
else: |
670 | 620 |
print "\nSkipping %s: %s" % (testpath, msg) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
621 |
return None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
622 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
623 |
def fail(msg): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
624 |
fails.append((test, msg)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
625 |
if not options.nodiff: |
670 | 626 |
print "\nERROR: %s %s" % (testpath, msg) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
627 |
return None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
628 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
629 |
vlog("# Test", test) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
630 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
631 |
# create a fresh hgrc |
670 | 632 |
hgrc = open(HGRCPATH, 'w+') |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
633 |
hgrc.write('[ui]\n') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
634 |
hgrc.write('slash = True\n') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
635 |
hgrc.write('[defaults]\n') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
636 |
hgrc.write('backout = -d "0 0"\n') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
637 |
hgrc.write('commit = -d "0 0"\n') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
638 |
hgrc.write('tag = -d "0 0"\n') |
670 | 639 |
if options.inotify: |
640 |
hgrc.write('[extensions]\n') |
|
641 |
hgrc.write('inotify=\n') |
|
642 |
hgrc.write('[inotify]\n') |
|
643 |
hgrc.write('pidfile=%s\n' % DAEMON_PIDS) |
|
644 |
hgrc.write('appendpid=True\n') |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
645 |
hgrc.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
646 |
|
693
8428f3bda904
run-tests.py: skipped tests shouldn't change working directory
Mads Kiilerich <mads@kiilerich.com>
parents:
692
diff
changeset
|
647 |
testpath = os.path.join(TESTDIR, test) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
648 |
ref = os.path.join(TESTDIR, test+".out") |
693
8428f3bda904
run-tests.py: skipped tests shouldn't change working directory
Mads Kiilerich <mads@kiilerich.com>
parents:
692
diff
changeset
|
649 |
err = os.path.join(TESTDIR, test+".err") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
650 |
if os.path.exists(err): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
651 |
os.remove(err) # Remove any previous output files |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
652 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
653 |
tf = open(testpath) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
654 |
firstline = tf.readline().rstrip() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
655 |
tf.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
656 |
except: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
657 |
firstline = '' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
658 |
lctest = test.lower() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
659 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
660 |
if lctest.endswith('.py') or firstline == '#!/usr/bin/env python': |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
661 |
runner = pytest |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
662 |
elif lctest.endswith('.t'): |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
663 |
runner = tsttest |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
664 |
ref = testpath |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
665 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
666 |
# do not try to run non-executable programs |
834
5a6898736b1a
run-tests.py: remove support for .bat files
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
833
diff
changeset
|
667 |
if not os.access(testpath, os.X_OK): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
668 |
return skip("not executable") |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
669 |
runner = shtest |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
670 |
|
693
8428f3bda904
run-tests.py: skipped tests shouldn't change working directory
Mads Kiilerich <mads@kiilerich.com>
parents:
692
diff
changeset
|
671 |
# Make a tmp subdirectory to work in |
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
672 |
testtmp = os.environ["TESTTMP"] = os.path.join(HGTMP, test) |
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
673 |
os.mkdir(testtmp) |
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
674 |
os.chdir(testtmp) |
693
8428f3bda904
run-tests.py: skipped tests shouldn't change working directory
Mads Kiilerich <mads@kiilerich.com>
parents:
692
diff
changeset
|
675 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
676 |
if options.timeout > 0: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
677 |
signal.alarm(options.timeout) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
678 |
|
829
7d66d78e6179
tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
826
diff
changeset
|
679 |
ret, out = runner(testpath, options, [ |
852
fb1e8925292d
run-tests: use regex when searching for $HGPORT in test output
Martin Geisler <mg@aragost.com>
parents:
844
diff
changeset
|
680 |
(re.escape(testtmp), '$TESTTMP'), |
fb1e8925292d
run-tests: use regex when searching for $HGPORT in test output
Martin Geisler <mg@aragost.com>
parents:
844
diff
changeset
|
681 |
(r':%s\b' % options.port, ':$HGPORT'), |
fb1e8925292d
run-tests: use regex when searching for $HGPORT in test output
Martin Geisler <mg@aragost.com>
parents:
844
diff
changeset
|
682 |
(r':%s\b' % (options.port + 1), ':$HGPORT1'), |
fb1e8925292d
run-tests: use regex when searching for $HGPORT in test output
Martin Geisler <mg@aragost.com>
parents:
844
diff
changeset
|
683 |
(r':%s\b' % (options.port + 2), ':$HGPORT2'), |
829
7d66d78e6179
tests: reintroduce ":$HGPORT" in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
826
diff
changeset
|
684 |
]) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
685 |
vlog("# Ret was:", ret) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
686 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
687 |
if options.timeout > 0: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
688 |
signal.alarm(0) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
689 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
690 |
mark = '.' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
691 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
692 |
skipped = (ret == SKIPPED_STATUS) |
741
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
693 |
|
670 | 694 |
# If we're not in --debug mode and reference output file exists, |
695 |
# check test output against it. |
|
696 |
if options.debug: |
|
697 |
refout = None # to match out == None |
|
698 |
elif os.path.exists(ref): |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
699 |
f = open(ref, "r") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
700 |
refout = splitnewlines(f.read()) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
701 |
f.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
702 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
703 |
refout = [] |
670 | 704 |
|
741
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
705 |
if (ret != 0 or out != refout) and not skipped and not options.debug: |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
706 |
# Save errors to a file for diagnosis |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
707 |
f = open(err, "wb") |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
708 |
for line in out: |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
709 |
f.write(line) |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
710 |
f.close() |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
711 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
712 |
if skipped: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
713 |
mark = 's' |
670 | 714 |
if out is None: # debug mode: nothing to parse |
715 |
missing = ['unknown'] |
|
716 |
failed = None |
|
717 |
else: |
|
718 |
missing, failed = parsehghaveoutput(out) |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
719 |
if not missing: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
720 |
missing = ['irrelevant'] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
721 |
if failed: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
722 |
fail("hghave failed checking for %s" % failed[-1]) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
723 |
skipped = False |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
724 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
725 |
skip(missing[-1]) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
726 |
elif out != refout: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
727 |
mark = '!' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
728 |
if ret: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
729 |
fail("output changed and returned error code %d" % ret) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
730 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
731 |
fail("output changed") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
732 |
if not options.nodiff: |
741
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
733 |
if options.view: |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
734 |
os.system("%s %s %s" % (options.view, ref, err)) |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
735 |
else: |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
736 |
showdiff(refout, out, ref, err) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
737 |
ret = 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
738 |
elif ret: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
739 |
mark = '!' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
740 |
fail("returned error code %d" % ret) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
741 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
742 |
if not options.verbose: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
743 |
sys.stdout.write(mark) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
744 |
sys.stdout.flush() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
745 |
|
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
746 |
killdaemons() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
747 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
748 |
os.chdir(TESTDIR) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
749 |
if not options.keep_tmpdir: |
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
750 |
shutil.rmtree(testtmp, True) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
751 |
if skipped: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
752 |
return None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
753 |
return ret == 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
754 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
755 |
_hgpath = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
756 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
757 |
def _gethgpath(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
758 |
"""Return the path to the mercurial package that is actually found by |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
759 |
the current Python interpreter.""" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
760 |
global _hgpath |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
761 |
if _hgpath is not None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
762 |
return _hgpath |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
763 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
764 |
cmd = '%s -c "import mercurial; print mercurial.__path__[0]"' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
765 |
pipe = os.popen(cmd % PYTHON) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
766 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
767 |
_hgpath = pipe.read().strip() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
768 |
finally: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
769 |
pipe.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
770 |
return _hgpath |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
771 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
772 |
def _checkhglib(verb): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
773 |
"""Ensure that the 'mercurial' package imported by python is |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
774 |
the one we expect it to be. If not, print a warning to stderr.""" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
775 |
expecthg = os.path.join(PYTHONDIR, 'mercurial') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
776 |
actualhg = _gethgpath() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
777 |
if actualhg != expecthg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
778 |
sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
779 |
' (expected %s)\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
780 |
% (verb, actualhg, expecthg)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
781 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
782 |
def runchildren(options, tests): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
783 |
if INST: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
784 |
installhg(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
785 |
_checkhglib("Testing") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
786 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
787 |
optcopy = dict(options.__dict__) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
788 |
optcopy['jobs'] = 1 |
725
212432db2043
Fix --blacklist when --jobs > 1 in run_tests.py.
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
724
diff
changeset
|
789 |
del optcopy['blacklist'] |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
790 |
if optcopy['with_hg'] is None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
791 |
optcopy['with_hg'] = os.path.join(BINDIR, "hg") |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
792 |
optcopy.pop('anycoverage', None) |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
793 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
794 |
opts = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
795 |
for opt, value in optcopy.iteritems(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
796 |
name = '--' + opt.replace('_', '-') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
797 |
if value is True: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
798 |
opts.append(name) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
799 |
elif value is not None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
800 |
opts.append(name + '=' + str(value)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
801 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
802 |
tests.reverse() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
803 |
jobs = [[] for j in xrange(options.jobs)] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
804 |
while tests: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
805 |
for job in jobs: |
680
f10a5301d082
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
674
diff
changeset
|
806 |
if not tests: |
f10a5301d082
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
674
diff
changeset
|
807 |
break |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
808 |
job.append(tests.pop()) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
809 |
fps = {} |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
810 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
811 |
for j, job in enumerate(jobs): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
812 |
if not job: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
813 |
continue |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
814 |
rfd, wfd = os.pipe() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
815 |
childopts = ['--child=%d' % wfd, '--port=%d' % (options.port + j * 3)] |
670 | 816 |
childtmp = os.path.join(HGTMP, 'child%d' % j) |
817 |
childopts += ['--tmpdir', childtmp] |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
818 |
cmdline = [PYTHON, sys.argv[0]] + opts + childopts + job |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
819 |
vlog(' '.join(cmdline)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
820 |
fps[os.spawnvp(os.P_NOWAIT, cmdline[0], cmdline)] = os.fdopen(rfd, 'r') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
821 |
os.close(wfd) |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
822 |
signal.signal(signal.SIGINT, signal.SIG_IGN) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
823 |
failures = 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
824 |
tested, skipped, failed = 0, 0, 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
825 |
skips = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
826 |
fails = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
827 |
while fps: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
828 |
pid, status = os.wait() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
829 |
fp = fps.pop(pid) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
830 |
l = fp.read().splitlines() |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
831 |
try: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
832 |
test, skip, fail = map(int, l[:3]) |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
833 |
except ValueError: |
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
834 |
test, skip, fail = 0, 0, 0 |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
835 |
split = -fail or len(l) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
836 |
for s in l[3:split]: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
837 |
skips.append(s.split(" ", 1)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
838 |
for s in l[split:]: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
839 |
fails.append(s.split(" ", 1)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
840 |
tested += test |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
841 |
skipped += skip |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
842 |
failed += fail |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
843 |
vlog('pid %d exited, status %d' % (pid, status)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
844 |
failures |= status |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
845 |
print |
670 | 846 |
if not options.noskips: |
847 |
for s in skips: |
|
848 |
print "Skipped %s: %s" % (s[0], s[1]) |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
849 |
for s in fails: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
850 |
print "Failed %s: %s" % (s[0], s[1]) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
851 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
852 |
_checkhglib("Tested") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
853 |
print "# Ran %d tests, %d skipped, %d failed." % ( |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
854 |
tested, skipped, failed) |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
855 |
|
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
856 |
if options.anycoverage: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
857 |
outputcoverage(options) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
858 |
sys.exit(failures != 0) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
859 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
860 |
def runtests(options, tests): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
861 |
global DAEMON_PIDS, HGRCPATH |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
862 |
DAEMON_PIDS = os.environ["DAEMON_PIDS"] = os.path.join(HGTMP, 'daemon.pids') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
863 |
HGRCPATH = os.environ["HGRCPATH"] = os.path.join(HGTMP, '.hgrc') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
864 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
865 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
866 |
if INST: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
867 |
installhg(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
868 |
_checkhglib("Testing") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
869 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
870 |
if options.timeout > 0: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
871 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
872 |
signal.signal(signal.SIGALRM, alarmed) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
873 |
vlog('# Running each test with %d second timeout' % |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
874 |
options.timeout) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
875 |
except AttributeError: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
876 |
print 'WARNING: cannot run tests with timeouts' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
877 |
options.timeout = 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
878 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
879 |
tested = 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
880 |
failed = 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
881 |
skipped = 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
882 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
883 |
if options.restart: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
884 |
orig = list(tests) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
885 |
while tests: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
886 |
if os.path.exists(tests[0] + ".err"): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
887 |
break |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
888 |
tests.pop(0) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
889 |
if not tests: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
890 |
print "running all tests" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
891 |
tests = orig |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
892 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
893 |
skips = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
894 |
fails = [] |
670 | 895 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
896 |
for test in tests: |
670 | 897 |
if options.blacklist: |
681
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
898 |
filename = options.blacklist.get(test) |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
899 |
if filename is not None: |
d0a410e49776
run-tests: split tests/blacklist in tests/blacklists/*
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
680
diff
changeset
|
900 |
skips.append((test, "blacklisted (%s)" % filename)) |
670 | 901 |
skipped += 1 |
902 |
continue |
|
903 |
||
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
904 |
if options.retest and not os.path.exists(test + ".err"): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
905 |
skipped += 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
906 |
continue |
670 | 907 |
|
908 |
if options.keywords: |
|
909 |
t = open(test).read().lower() + test.lower() |
|
910 |
for k in options.keywords.lower().split(): |
|
911 |
if k in t: |
|
912 |
break |
|
913 |
else: |
|
683
26ca426a04e1
fix up a bunch of check-code warnings
Matt Mackall <mpm@selenic.com>
parents:
682
diff
changeset
|
914 |
skipped += 1 |
670 | 915 |
continue |
916 |
||
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
917 |
ret = runone(options, test, skips, fails) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
918 |
if ret is None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
919 |
skipped += 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
920 |
elif not ret: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
921 |
if options.interactive: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
922 |
print "Accept this change? [n] ", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
923 |
answer = sys.stdin.readline().strip() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
924 |
if answer.lower() in "y yes".split(): |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
925 |
if test.endswith(".t"): |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
926 |
rename(test + ".err", test) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
927 |
else: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
928 |
rename(test + ".err", test + ".out") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
929 |
tested += 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
930 |
fails.pop() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
931 |
continue |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
932 |
failed += 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
933 |
if options.first: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
934 |
break |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
935 |
tested += 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
936 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
937 |
if options.child: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
938 |
fp = os.fdopen(options.child, 'w') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
939 |
fp.write('%d\n%d\n%d\n' % (tested, skipped, failed)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
940 |
for s in skips: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
941 |
fp.write("%s %s\n" % s) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
942 |
for s in fails: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
943 |
fp.write("%s %s\n" % s) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
944 |
fp.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
945 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
946 |
print |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
947 |
for s in skips: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
948 |
print "Skipped %s: %s" % s |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
949 |
for s in fails: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
950 |
print "Failed %s: %s" % s |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
951 |
_checkhglib("Tested") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
952 |
print "# Ran %d tests, %d skipped, %d failed." % ( |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
953 |
tested, skipped, failed) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
954 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
955 |
if options.anycoverage: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
956 |
outputcoverage(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
957 |
except KeyboardInterrupt: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
958 |
failed = True |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
959 |
print "\ninterrupted!" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
960 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
961 |
if failed: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
962 |
sys.exit(1) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
963 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
964 |
def main(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
965 |
(options, args) = parseargs() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
966 |
if not options.child: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
967 |
os.umask(022) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
968 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
969 |
checktools() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
970 |
|
833
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
971 |
if len(args) == 0: |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
972 |
args = os.listdir(".") |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
973 |
args.sort() |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
974 |
|
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
975 |
tests = [] |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
976 |
skipped = [] |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
977 |
for test in args: |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
978 |
if (test.startswith("test-") and '~' not in test and |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
979 |
('.' not in test or test.endswith('.py') or |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
980 |
test.endswith('.bat') or test.endswith('.t'))): |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
981 |
if not os.path.exists(test): |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
982 |
skipped.append(test) |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
983 |
else: |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
984 |
tests.append(test) |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
985 |
if not tests: |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
986 |
for test in skipped: |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
987 |
print 'Skipped %s: does not exist' % test |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
988 |
print "# Ran 0 tests, %d skipped, 0 failed." % len(skipped) |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
989 |
return |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
990 |
tests = tests + skipped |
a9c6ada32647
run-tests.py: do not install hg when the tests do no exist
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
829
diff
changeset
|
991 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
992 |
# Reset some environment variables to well-known values so that |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
993 |
# the tests produce repeatable output. |
670 | 994 |
os.environ['LANG'] = os.environ['LC_ALL'] = os.environ['LANGUAGE'] = 'C' |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
995 |
os.environ['TZ'] = 'GMT' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
996 |
os.environ["EMAIL"] = "Foo Bar <foo.bar@example.com>" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
997 |
os.environ['CDPATH'] = '' |
670 | 998 |
os.environ['COLUMNS'] = '80' |
719
ad3048630bd8
run-tests: make sure GREP_OPTIONS isn't set
Brodie Rao <brodie@bitheap.org>
parents:
718
diff
changeset
|
999 |
os.environ['GREP_OPTIONS'] = '' |
692
5ac40b193130
run-tests.py: clears http_proxy for all tests
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
683
diff
changeset
|
1000 |
os.environ['http_proxy'] = '' |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1001 |
|
724
211fa4b9803d
run-tests.py: reset env variables set by hooks
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
722
diff
changeset
|
1002 |
# unset env related to hooks |
211fa4b9803d
run-tests.py: reset env variables set by hooks
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
722
diff
changeset
|
1003 |
for k in os.environ.keys(): |
211fa4b9803d
run-tests.py: reset env variables set by hooks
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
722
diff
changeset
|
1004 |
if k.startswith('HG_'): |
728
5df6643c39e9
run-tests.py: can't remove from os.environ on solaris
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
726
diff
changeset
|
1005 |
# can't remove on solaris |
5df6643c39e9
run-tests.py: can't remove from os.environ on solaris
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
726
diff
changeset
|
1006 |
os.environ[k] = '' |
724
211fa4b9803d
run-tests.py: reset env variables set by hooks
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
722
diff
changeset
|
1007 |
del os.environ[k] |
211fa4b9803d
run-tests.py: reset env variables set by hooks
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
722
diff
changeset
|
1008 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1009 |
global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1010 |
TESTDIR = os.environ["TESTDIR"] = os.getcwd() |
670 | 1011 |
if options.tmpdir: |
1012 |
options.keep_tmpdir = True |
|
1013 |
tmpdir = options.tmpdir |
|
1014 |
if os.path.exists(tmpdir): |
|
1015 |
# Meaning of tmpdir has changed since 1.3: we used to create |
|
1016 |
# HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if |
|
1017 |
# tmpdir already exists. |
|
1018 |
sys.exit("error: temp dir %r already exists" % tmpdir) |
|
1019 |
||
1020 |
# Automatically removing tmpdir sounds convenient, but could |
|
1021 |
# really annoy anyone in the habit of using "--tmpdir=/tmp" |
|
1022 |
# or "--tmpdir=$HOME". |
|
1023 |
#vlog("# Removing temp dir", tmpdir) |
|
1024 |
#shutil.rmtree(tmpdir) |
|
1025 |
os.makedirs(tmpdir) |
|
1026 |
else: |
|
1027 |
tmpdir = tempfile.mkdtemp('', 'hgtests.') |
|
1028 |
HGTMP = os.environ['HGTMP'] = os.path.realpath(tmpdir) |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1029 |
DAEMON_PIDS = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1030 |
HGRCPATH = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1031 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1032 |
os.environ["HGEDITOR"] = sys.executable + ' -c "import sys; sys.exit(0)"' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1033 |
os.environ["HGMERGE"] = "internal:merge" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1034 |
os.environ["HGUSER"] = "test" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1035 |
os.environ["HGENCODING"] = "ascii" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1036 |
os.environ["HGENCODINGMODE"] = "strict" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1037 |
os.environ["HGPORT"] = str(options.port) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1038 |
os.environ["HGPORT1"] = str(options.port + 1) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1039 |
os.environ["HGPORT2"] = str(options.port + 2) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1040 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1041 |
if options.with_hg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1042 |
INST = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1043 |
BINDIR = os.path.dirname(os.path.realpath(options.with_hg)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1044 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1045 |
# This looks redundant with how Python initializes sys.path from |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1046 |
# the location of the script being executed. Needed because the |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1047 |
# "hg" specified by --with-hg is not the only Python script |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1048 |
# executed in the test suite that needs to import 'mercurial' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1049 |
# ... which means it's not really redundant at all. |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1050 |
PYTHONDIR = BINDIR |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1051 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1052 |
INST = os.path.join(HGTMP, "install") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1053 |
BINDIR = os.environ["BINDIR"] = os.path.join(INST, "bin") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1054 |
PYTHONDIR = os.path.join(INST, "lib", "python") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1055 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1056 |
os.environ["BINDIR"] = BINDIR |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1057 |
os.environ["PYTHON"] = PYTHON |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1058 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1059 |
if not options.child: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1060 |
path = [BINDIR] + os.environ["PATH"].split(os.pathsep) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1061 |
os.environ["PATH"] = os.pathsep.join(path) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1062 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1063 |
# Include TESTDIR in PYTHONPATH so that out-of-tree extensions |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1064 |
# can run .../tests/run-tests.py test-foo where test-foo |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1065 |
# adds an extension to HGRC |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1066 |
pypath = [PYTHONDIR, TESTDIR] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1067 |
# We have to augment PYTHONPATH, rather than simply replacing |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1068 |
# it, in case external libraries are only available via current |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1069 |
# PYTHONPATH. (In particular, the Subversion bindings on OS X |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1070 |
# are in /opt/subversion.) |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
1071 |
oldpypath = os.environ.get(IMPL_PATH) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1072 |
if oldpypath: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1073 |
pypath.append(oldpypath) |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
1074 |
os.environ[IMPL_PATH] = os.pathsep.join(pypath) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1075 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1076 |
COVERAGE_FILE = os.path.join(TESTDIR, ".coverage") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1077 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1078 |
vlog("# Using TESTDIR", TESTDIR) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1079 |
vlog("# Using HGTMP", HGTMP) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1080 |
vlog("# Using PATH", os.environ["PATH"]) |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
1081 |
vlog("# Using", IMPL_PATH, os.environ[IMPL_PATH]) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1082 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1083 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1084 |
if len(tests) > 1 and options.jobs > 1: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1085 |
runchildren(options, tests) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1086 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1087 |
runtests(options, tests) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1088 |
finally: |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
1089 |
time.sleep(1) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1090 |
cleanup(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1091 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1092 |
main() |