author | Matt Mackall <mpm@selenic.com> |
Fri, 24 May 2013 13:47:17 -0500 | |
branch | stable |
changeset 1231 | c6a4dd8d18a9 |
parent 1230 | 29767671c053 |
child 1232 | 8730a2885d7c |
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 |
1212
2ea362720f72
test: display used python hash seed
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1210
diff
changeset
|
55 |
import random |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
56 |
import re |
912
17e4691cc491
run-tests: add locking on results struct
Matt Mackall <mpm@selenic.com>
parents:
910
diff
changeset
|
57 |
import threading |
1126
dbcb11553a3b
run-tests: do not duplicate killdaemons() code
Patrick Mezard <patrick@mezard.eu>
parents:
1094
diff
changeset
|
58 |
import killdaemons as killmod |
1157
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
59 |
import cPickle as pickle |
1171
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
60 |
import Queue as queue |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
61 |
|
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
62 |
processlock = threading.Lock() |
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
63 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
64 |
closefds = os.name == 'posix' |
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
65 |
def Popen4(cmd, wd, timeout): |
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
66 |
processlock.acquire() |
947
23f0eeb598b5
run-tests: replace chdir() with Popen cwd option
Patrick Mezard <pmezard@gmail.com>
parents:
946
diff
changeset
|
67 |
p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=wd, |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
68 |
close_fds=closefds, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
69 |
stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
70 |
stderr=subprocess.STDOUT) |
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
71 |
processlock.release() |
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
72 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
73 |
p.fromchild = p.stdout |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
74 |
p.tochild = p.stdin |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
75 |
p.childerr = p.stderr |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
76 |
|
944
37aff8ccb33e
run-tests: ignore timeout when Popen.terminate is unavailable
Patrick Mezard <pmezard@gmail.com>
parents:
943
diff
changeset
|
77 |
p.timeout = False |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
78 |
if timeout: |
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
79 |
def t(): |
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
80 |
start = time.time() |
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
81 |
while time.time() - start < timeout and p.returncode is None: |
1059
1745fd2dd308
tests: shorten post-test sleeps
Matt Mackall <mpm@selenic.com>
parents:
1046
diff
changeset
|
82 |
time.sleep(.1) |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
83 |
p.timeout = True |
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
84 |
if p.returncode is None: |
970
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
85 |
terminate(p) |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
86 |
threading.Thread(target=t).start() |
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
87 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
88 |
return p |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
89 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
90 |
# 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
|
91 |
SKIPPED_STATUS = 80 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
92 |
SKIPPED_PREFIX = 'skipped: ' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
93 |
FAILED_PREFIX = 'hghave check failed: ' |
1016
b4ca7adb4bf1
run-tests: convert windows paths to unix
Mads Kiilerich <mads@kiilerich.com>
parents:
1015
diff
changeset
|
94 |
PYTHON = sys.executable.replace('\\', '/') |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
95 |
IMPL_PATH = 'PYTHONPATH' |
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
96 |
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
|
97 |
IMPL_PATH = 'JYTHONPATH' |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
98 |
|
1169
28f06763bfb2
run-tests: check for the correct python when starting
Bryan O'Sullivan <bryano@fb.com>
parents:
1168
diff
changeset
|
99 |
requiredtools = [os.path.basename(sys.executable), "diff", "grep", "unzip", |
28f06763bfb2
run-tests: check for the correct python when starting
Bryan O'Sullivan <bryano@fb.com>
parents:
1168
diff
changeset
|
100 |
"gunzip", "bunzip2", "sed"] |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
101 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
102 |
defaults = { |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
103 |
'jobs': ('HGTEST_JOBS', 1), |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
104 |
'timeout': ('HGTEST_TIMEOUT', 180), |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
105 |
'port': ('HGTEST_PORT', 20059), |
1045
0a2285b90e22
tests: let run-tests.py default to use 'sh' in $PATH instead of '/bin/sh'
Mads Kiilerich <mads@kiilerich.com>
parents:
1044
diff
changeset
|
106 |
'shell': ('HGTEST_SHELL', 'sh'), |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
107 |
} |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
108 |
|
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
109 |
def parselistfiles(files, listtype, warn=True): |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
110 |
entries = dict() |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
111 |
for filename in files: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
112 |
try: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
113 |
path = os.path.expanduser(os.path.expandvars(filename)) |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
114 |
f = open(path, "r") |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
115 |
except IOError, err: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
116 |
if err.errno != errno.ENOENT: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
117 |
raise |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
118 |
if warn: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
119 |
print "warning: no such %s file: %s" % (listtype, filename) |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
120 |
continue |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
121 |
|
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
122 |
for line in f.readlines(): |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
123 |
line = line.split('#', 1)[0].strip() |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
124 |
if line: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
125 |
entries[line] = filename |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
126 |
|
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
127 |
f.close() |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
128 |
return entries |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
129 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
130 |
def parseargs(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
131 |
parser = optparse.OptionParser("%prog [options] [tests]") |
740 | 132 |
|
133 |
# keep these sorted |
|
134 |
parser.add_option("--blacklist", action="append", |
|
135 |
help="skip tests listed in the specified blacklist file") |
|
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
136 |
parser.add_option("--whitelist", action="append", |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
137 |
help="always run tests listed in the specified whitelist file") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
138 |
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
|
139 |
help="output files annotated with coverage") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
140 |
parser.add_option("--child", type="int", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
141 |
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
|
142 |
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
|
143 |
help="print a test coverage report") |
740 | 144 |
parser.add_option("-d", "--debug", action="store_true", |
145 |
help="debug mode: write output of test scripts to console" |
|
146 |
" 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
|
147 |
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
|
148 |
help="exit on the first test failure") |
1039
7c2190b236cf
tests: add htmlcov option
Markus Zapke-Gr?ndemann <info@keimlink.de>
parents:
1038
diff
changeset
|
149 |
parser.add_option("-H", "--htmlcov", action="store_true", |
7c2190b236cf
tests: add htmlcov option
Markus Zapke-Gr?ndemann <info@keimlink.de>
parents:
1038
diff
changeset
|
150 |
help="create an HTML report of the coverage of the files") |
740 | 151 |
parser.add_option("--inotify", action="store_true", |
152 |
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
|
153 |
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
|
154 |
help="prompt to accept changed output") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
" (default: $%s or %d)" % defaults['jobs']) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
158 |
parser.add_option("--keep-tmpdir", action="store_true", |
670 | 159 |
help="keep temporary directory after running tests") |
740 | 160 |
parser.add_option("-k", "--keywords", |
161 |
help="run tests matching keywords") |
|
162 |
parser.add_option("-l", "--local", action="store_true", |
|
163 |
help="shortcut for --with-hg=<testdir>/../hg") |
|
164 |
parser.add_option("-n", "--nodiff", action="store_true", |
|
165 |
help="skip showing test changes") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
" (default: $%s or %d)" % defaults['port']) |
1165
b0fa589b35b0
run-tests: add a --compiler option
Bryan O'Sullivan <bryano@fb.com>
parents:
1164
diff
changeset
|
169 |
parser.add_option("--compiler", type="string", |
b0fa589b35b0
run-tests: add a --compiler option
Bryan O'Sullivan <bryano@fb.com>
parents:
1164
diff
changeset
|
170 |
help="compiler to build with") |
740 | 171 |
parser.add_option("--pure", action="store_true", |
172 |
help="use pure Python code instead of C extensions") |
|
173 |
parser.add_option("-R", "--restart", action="store_true", |
|
174 |
help="restart at last error") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
175 |
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
|
176 |
help="retest failed tests") |
670 | 177 |
parser.add_option("-S", "--noskips", action="store_true", |
178 |
help="don't report skip tests verbosely") |
|
932
eb562ea207c3
run-tests: add --shell command line flag
Martin Geisler <mg@lazybytes.net>
parents:
931
diff
changeset
|
179 |
parser.add_option("--shell", type="string", |
eb562ea207c3
run-tests: add --shell command line flag
Martin Geisler <mg@lazybytes.net>
parents:
931
diff
changeset
|
180 |
help="shell to use (default: $%s or %s)" % defaults['shell']) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
181 |
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
|
182 |
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
|
183 |
" (default: $%s or %d)" % defaults['timeout']) |
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
184 |
parser.add_option("--time", action="store_true", |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
185 |
help="time how long each test takes") |
740 | 186 |
parser.add_option("--tmpdir", type="string", |
187 |
help="run tests in the given temporary directory" |
|
188 |
" (implies --keep-tmpdir)") |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
189 |
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
|
190 |
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
|
191 |
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
|
192 |
help="external diff viewer") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
193 |
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
|
194 |
metavar="HG", |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
195 |
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
|
196 |
"temporary installation") |
670 | 197 |
parser.add_option("-3", "--py3k-warnings", action="store_true", |
198 |
help="enable Py3k warnings on Python 2.6+") |
|
926
f4903069a215
run-tests: add flag to provide extra hgrc options for test runs
Augie Fackler <durin42@gmail.com>
parents:
923
diff
changeset
|
199 |
parser.add_option('--extra-config-opt', action="append", |
f4903069a215
run-tests: add flag to provide extra hgrc options for test runs
Augie Fackler <durin42@gmail.com>
parents:
923
diff
changeset
|
200 |
help='set the given config opt in the test hgrc') |
1221
3a049b21a05b
run-tests: introduce --random for running tests in random error
Mads Kiilerich <madski@unity3d.com>
parents:
1219
diff
changeset
|
201 |
parser.add_option('--random', action="store_true", |
3a049b21a05b
run-tests: introduce --random for running tests in random error
Mads Kiilerich <madski@unity3d.com>
parents:
1219
diff
changeset
|
202 |
help='run tests in random order') |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
203 |
|
931
b56e95db7ac5
run-tests: use type of default to convert environment variable
Martin Geisler <mg@lazybytes.net>
parents:
930
diff
changeset
|
204 |
for option, (envvar, default) in defaults.items(): |
b56e95db7ac5
run-tests: use type of default to convert environment variable
Martin Geisler <mg@lazybytes.net>
parents:
930
diff
changeset
|
205 |
defaults[option] = type(default)(os.environ.get(envvar, default)) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
206 |
parser.set_defaults(**defaults) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
207 |
(options, args) = parser.parse_args() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
208 |
|
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
209 |
# 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
|
210 |
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
|
211 |
options.pure = True |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
212 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
213 |
if options.with_hg: |
1046
2890e1f3d8e4
run-tests: expand user in --with-hg
Mads Kiilerich <mads@kiilerich.com>
parents:
1045
diff
changeset
|
214 |
options.with_hg = os.path.expanduser(options.with_hg) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
215 |
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
|
216 |
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
|
217 |
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
|
218 |
if not os.path.basename(options.with_hg) == 'hg': |
951
0af8a73dfe14
run-tests: print a newline after all warnings
Thomas Arendsen Hein <thomas@intevation.de>
parents:
947
diff
changeset
|
219 |
sys.stderr.write('warning: --with-hg should specify an hg script\n') |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
220 |
if options.local: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
221 |
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
|
222 |
hgbin = os.path.join(os.path.dirname(testdir), 'hg') |
1065
c1d229864cd3
tests: don't require 'hg' without extension on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1059
diff
changeset
|
223 |
if os.name != 'nt' and not os.access(hgbin, os.X_OK): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
224 |
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
|
225 |
% hgbin) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
226 |
options.with_hg = hgbin |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
227 |
|
1039
7c2190b236cf
tests: add htmlcov option
Markus Zapke-Gr?ndemann <info@keimlink.de>
parents:
1038
diff
changeset
|
228 |
options.anycoverage = options.cover or options.annotate or options.htmlcov |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
229 |
if options.anycoverage: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
230 |
try: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
231 |
import coverage |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
232 |
covver = version.StrictVersion(coverage.__version__).version |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
233 |
if covver < (3, 3): |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
234 |
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
|
235 |
except ImportError: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
236 |
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
|
237 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
238 |
if options.anycoverage and options.local: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
239 |
# 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
|
240 |
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
|
241 |
"is specified") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
242 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
243 |
global vlog |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
244 |
if options.verbose: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
245 |
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
|
246 |
pid = "[%d]" % os.getpid() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
247 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
248 |
pid = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
249 |
def vlog(*msg): |
918
3071ec5d085c
run-tests: add iolock to vlog
Matt Mackall <mpm@selenic.com>
parents:
916
diff
changeset
|
250 |
iolock.acquire() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
251 |
if pid: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
252 |
print pid, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
253 |
for m in msg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
254 |
print m, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
255 |
print |
670 | 256 |
sys.stdout.flush() |
918
3071ec5d085c
run-tests: add iolock to vlog
Matt Mackall <mpm@selenic.com>
parents:
916
diff
changeset
|
257 |
iolock.release() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
258 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
259 |
vlog = lambda *msg: None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
260 |
|
670 | 261 |
if options.tmpdir: |
262 |
options.tmpdir = os.path.expanduser(options.tmpdir) |
|
263 |
||
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
264 |
if options.jobs < 1: |
670 | 265 |
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
|
266 |
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
|
267 |
print '(--interactive overrides --jobs)' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
268 |
options.jobs = 1 |
670 | 269 |
if options.interactive and options.debug: |
270 |
parser.error("-i/--interactive and -d/--debug are incompatible") |
|
271 |
if options.debug: |
|
272 |
if options.timeout != defaults['timeout']: |
|
273 |
sys.stderr.write( |
|
274 |
'warning: --timeout option ignored with --debug\n') |
|
275 |
options.timeout = 0 |
|
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
276 |
if options.time: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
277 |
sys.stderr.write( |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
278 |
'warning: --time option ignored with --debug\n') |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
279 |
options.time = False |
670 | 280 |
if options.py3k_warnings: |
281 |
if sys.version_info[:2] < (2, 6) or sys.version_info[:2] >= (3, 0): |
|
282 |
parser.error('--py3k-warnings can only be used on Python 2.6+') |
|
283 |
if options.blacklist: |
|
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
284 |
options.blacklist = parselistfiles(options.blacklist, 'blacklist') |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
285 |
if options.whitelist: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
286 |
options.whitelisted = parselistfiles(options.whitelist, 'whitelist', |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
287 |
warn=options.child is None) |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
288 |
else: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
289 |
options.whitelisted = {} |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
290 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
291 |
return (options, args) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
292 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
293 |
def rename(src, dst): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
294 |
"""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
|
295 |
for existing destination support. |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
296 |
""" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
297 |
shutil.copy(src, dst) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
298 |
os.remove(src) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
299 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
300 |
def parsehghaveoutput(lines): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
301 |
'''Parse hghave log lines. |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
302 |
Return tuple of lists (missing, failed): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
303 |
* the missing/unknown features |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
304 |
* 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
|
305 |
missing = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
306 |
failed = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
307 |
for line in lines: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
308 |
if line.startswith(SKIPPED_PREFIX): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
309 |
line = line.splitlines()[0] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
310 |
missing.append(line[len(SKIPPED_PREFIX):]) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
311 |
elif line.startswith(FAILED_PREFIX): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
312 |
line = line.splitlines()[0] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
313 |
failed.append(line[len(FAILED_PREFIX):]) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
314 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
315 |
return missing, failed |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
316 |
|
670 | 317 |
def showdiff(expected, output, ref, err): |
923
8212da2b01eb
run-tests: print a new line before writing the diff
Idan Kamara <idankk86@gmail.com>
parents:
921
diff
changeset
|
318 |
print |
670 | 319 |
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
|
320 |
sys.stdout.write(line) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
321 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
322 |
def findprogram(program): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
323 |
"""Search PATH for a executable program""" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
324 |
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
|
325 |
name = os.path.join(p, program) |
942
92325072c4d4
run-tests: fix python executable detection and copy on Windows
Patrick Mezard <pmezard@gmail.com>
parents:
936
diff
changeset
|
326 |
if os.name == 'nt' or os.access(name, os.X_OK): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
327 |
return name |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
328 |
return None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
329 |
|
1230
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
330 |
def createhgrc(path, options): |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
331 |
# create a fresh hgrc |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
332 |
hgrc = open(path, 'w+') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
333 |
hgrc.write('[ui]\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
334 |
hgrc.write('slash = True\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
335 |
hgrc.write('interactive = False\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
336 |
hgrc.write('[defaults]\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
337 |
hgrc.write('backout = -d "0 0"\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
338 |
hgrc.write('commit = -d "0 0"\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
339 |
hgrc.write('tag = -d "0 0"\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
340 |
if options.inotify: |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
341 |
hgrc.write('[extensions]\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
342 |
hgrc.write('inotify=\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
343 |
hgrc.write('[inotify]\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
344 |
hgrc.write('pidfile=%s\n' % DAEMON_PIDS) |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
345 |
hgrc.write('appendpid=True\n') |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
346 |
if options.extra_config_opt: |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
347 |
for opt in options.extra_config_opt: |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
348 |
section, key = opt.split('.', 1) |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
349 |
assert '=' in key, ('extra config opt %s must ' |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
350 |
'have an = for assignment' % opt) |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
351 |
hgrc.write('[%s]\n%s\n' % (section, key)) |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
352 |
hgrc.close() |
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
353 |
|
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
354 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
355 |
def checktools(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
356 |
# 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
|
357 |
# 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
|
358 |
for p in requiredtools: |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
359 |
if os.name == 'nt' and not p.endswith('.exe'): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
360 |
p += '.exe' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
361 |
found = findprogram(p) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
362 |
if found: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
363 |
vlog("# Found prerequisite", p, "at", found) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
364 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
365 |
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
|
366 |
|
970
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
367 |
def terminate(proc): |
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
368 |
"""Terminate subprocess (with fallback for Python versions < 2.6)""" |
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
369 |
vlog('# Terminating process %d' % proc.pid) |
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
370 |
try: |
977
a50ed14997fc
tests: use getattr instead of hasattr
Augie Fackler <durin42@gmail.com>
parents:
975
diff
changeset
|
371 |
getattr(proc, 'terminate', lambda : os.kill(proc.pid, signal.SIGTERM))() |
970
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
372 |
except OSError: |
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
373 |
pass |
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
374 |
|
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
375 |
def killdaemons(): |
1126
dbcb11553a3b
run-tests: do not duplicate killdaemons() code
Patrick Mezard <patrick@mezard.eu>
parents:
1094
diff
changeset
|
376 |
return killmod.killdaemons(DAEMON_PIDS, tryhard=False, remove=True, |
dbcb11553a3b
run-tests: do not duplicate killdaemons() code
Patrick Mezard <patrick@mezard.eu>
parents:
1094
diff
changeset
|
377 |
logfn=vlog) |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
378 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
379 |
def cleanup(options): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
380 |
if not options.keep_tmpdir: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
381 |
vlog("# Cleaning up HGTMP", HGTMP) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
382 |
shutil.rmtree(HGTMP, True) |
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 |
def usecorrectpython(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
385 |
# 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
|
386 |
# interpreter we use or bad things will happen. |
1186
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
387 |
pyexename = sys.platform == 'win32' and 'python.exe' or 'python' |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
388 |
if getattr(os, 'symlink', None): |
1175
62cc0851c70f
run-tests: fix whitespace nonsense
Bryan O'Sullivan <bos@serpentine.com>
parents:
1174
diff
changeset
|
389 |
vlog("# Making python executable in test path a symlink to '%s'" % |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
390 |
sys.executable) |
1186
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
391 |
mypython = os.path.join(BINDIR, pyexename) |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
392 |
try: |
1186
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
393 |
if os.readlink(mypython) == sys.executable: |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
394 |
return |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
395 |
os.unlink(mypython) |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
396 |
except OSError, err: |
1186
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
397 |
if err.errno != errno.ENOENT: |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
398 |
raise |
1186
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
399 |
if findprogram(pyexename) != sys.executable: |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
400 |
try: |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
401 |
os.symlink(sys.executable, mypython) |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
402 |
except OSError, err: |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
403 |
# child processes may race, which is harmless |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
404 |
if err.errno != errno.EEXIST: |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
405 |
raise |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
406 |
else: |
1186
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
407 |
exedir, exename = os.path.split(sys.executable) |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
408 |
vlog("# Modifying search path to find %s as %s in '%s'" % |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
409 |
(exename, pyexename, exedir)) |
1174
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
410 |
path = os.environ['PATH'].split(os.pathsep) |
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
411 |
while exedir in path: |
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
412 |
path.remove(exedir) |
193946338595
run-tests: on windows, put correct python at front of PATH
Bryan O'Sullivan <bryano@fb.com>
parents:
1173
diff
changeset
|
413 |
os.environ['PATH'] = os.pathsep.join([exedir] + path) |
1186
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
414 |
if not findprogram(pyexename): |
d821f658f7a3
run-tests.py: fix handling of symlink to the right python
Mads Kiilerich <mads@kiilerich.com>
parents:
1183
diff
changeset
|
415 |
print "WARNING: Cannot find %s in search path" % pyexename |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
416 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
417 |
def installhg(options): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
418 |
vlog("# Performing temporary installation of HG") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
419 |
installerrs = os.path.join("tests", "install.err") |
1165
b0fa589b35b0
run-tests: add a --compiler option
Bryan O'Sullivan <bryano@fb.com>
parents:
1164
diff
changeset
|
420 |
compiler = '' |
b0fa589b35b0
run-tests: add a --compiler option
Bryan O'Sullivan <bryano@fb.com>
parents:
1164
diff
changeset
|
421 |
if options.compiler: |
b0fa589b35b0
run-tests: add a --compiler option
Bryan O'Sullivan <bryano@fb.com>
parents:
1164
diff
changeset
|
422 |
compiler = '--compiler ' + options.compiler |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
423 |
pure = options.pure and "--pure" or "" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
424 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
425 |
# Run installer in hg root |
670 | 426 |
script = os.path.realpath(sys.argv[0]) |
427 |
hgroot = os.path.dirname(os.path.dirname(script)) |
|
428 |
os.chdir(hgroot) |
|
429 |
nohome = '--home=""' |
|
430 |
if os.name == 'nt': |
|
431 |
# The --home="" trick works only on OS where os.sep == '/' |
|
432 |
# because of a distutils convert_path() fast-path. Avoid it at |
|
433 |
# least on Windows for now, deal with .pydistutils.cfg bugs |
|
434 |
# when they happen. |
|
435 |
nohome = '' |
|
1164
8ed9a9f075f9
run-tests: make build command line less intimidating
Bryan O'Sullivan <bryano@fb.com>
parents:
1163
diff
changeset
|
436 |
cmd = ('%(exe)s setup.py %(pure)s clean --all' |
1165
b0fa589b35b0
run-tests: add a --compiler option
Bryan O'Sullivan <bryano@fb.com>
parents:
1164
diff
changeset
|
437 |
' build %(compiler)s --build-base="%(base)s"' |
1164
8ed9a9f075f9
run-tests: make build command line less intimidating
Bryan O'Sullivan <bryano@fb.com>
parents:
1163
diff
changeset
|
438 |
' install --force --prefix="%(prefix)s" --install-lib="%(libdir)s"' |
8ed9a9f075f9
run-tests: make build command line less intimidating
Bryan O'Sullivan <bryano@fb.com>
parents:
1163
diff
changeset
|
439 |
' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1' |
1165
b0fa589b35b0
run-tests: add a --compiler option
Bryan O'Sullivan <bryano@fb.com>
parents:
1164
diff
changeset
|
440 |
% dict(exe=sys.executable, pure=pure, compiler=compiler, |
1164
8ed9a9f075f9
run-tests: make build command line less intimidating
Bryan O'Sullivan <bryano@fb.com>
parents:
1163
diff
changeset
|
441 |
base=os.path.join(HGTMP, "build"), |
1166
d38c648869bb
run-tests: fix an unnoticed check-code violation
Bryan O'Sullivan <bryano@fb.com>
parents:
1165
diff
changeset
|
442 |
prefix=INST, libdir=PYTHONDIR, bindir=BINDIR, |
1164
8ed9a9f075f9
run-tests: make build command line less intimidating
Bryan O'Sullivan <bryano@fb.com>
parents:
1163
diff
changeset
|
443 |
nohome=nohome, logfile=installerrs)) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
444 |
vlog("# Running", cmd) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
445 |
if os.system(cmd) == 0: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
446 |
if not options.verbose: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
447 |
os.remove(installerrs) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
448 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
449 |
f = open(installerrs) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
450 |
for line in f: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
451 |
print line, |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
452 |
f.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
453 |
sys.exit(1) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
454 |
os.chdir(TESTDIR) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
455 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
456 |
usecorrectpython() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
457 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
458 |
vlog("# Installing dummy diffstat") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
459 |
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
|
460 |
f.write('#!' + sys.executable + '\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
461 |
'import sys\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
462 |
'files = 0\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
463 |
'for line in sys.stdin:\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
464 |
' if line.startswith("diff "):\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
465 |
' files += 1\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
466 |
'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
|
467 |
f.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
468 |
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
|
469 |
|
670 | 470 |
if options.py3k_warnings and not options.anycoverage: |
471 |
vlog("# Updating hg command to enable Py3k Warnings switch") |
|
472 |
f = open(os.path.join(BINDIR, 'hg'), 'r') |
|
473 |
lines = [line.rstrip() for line in f] |
|
474 |
lines[0] += ' -3' |
|
475 |
f.close() |
|
476 |
f = open(os.path.join(BINDIR, 'hg'), 'w') |
|
477 |
for line in lines: |
|
478 |
f.write(line + '\n') |
|
479 |
f.close() |
|
480 |
||
943
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
481 |
hgbat = os.path.join(BINDIR, 'hg.bat') |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
482 |
if os.path.isfile(hgbat): |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
483 |
# hg.bat expects to be put in bin/scripts while run-tests.py |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
484 |
# installation layout put it in bin/ directly. Fix it |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
485 |
f = open(hgbat, 'rb') |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
486 |
data = f.read() |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
487 |
f.close() |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
488 |
if '"%~dp0..\python" "%~dp0hg" %*' in data: |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
489 |
data = data.replace('"%~dp0..\python" "%~dp0hg" %*', |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
490 |
'"%~dp0python" "%~dp0hg" %*') |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
491 |
f = open(hgbat, 'wb') |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
492 |
f.write(data) |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
493 |
f.close() |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
494 |
else: |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
495 |
print 'WARNING: cannot fix hg.bat reference to python.exe' |
1f7fd6db1e17
run-tests: fix hg.bat python reference
Patrick Mezard <pmezard@gmail.com>
parents:
942
diff
changeset
|
496 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
497 |
if options.anycoverage: |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
498 |
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
|
499 |
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
|
500 |
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
|
501 |
shutil.copyfile(custom, target) |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
502 |
rc = os.path.join(TESTDIR, '.coveragerc') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
503 |
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
|
504 |
os.environ['COVERAGE_PROCESS_START'] = rc |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
505 |
fn = os.path.join(INST, '..', '.coverage') |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
506 |
os.environ['COVERAGE_FILE'] = fn |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
507 |
|
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
508 |
def outputtimes(options): |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
509 |
vlog('# Producing time report') |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
510 |
times.sort(key=lambda t: (t[1], t[0]), reverse=True) |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
511 |
cols = '%7.3f %s' |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
512 |
print '\n%-7s %s' % ('Time', 'Test') |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
513 |
for test, timetaken in times: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
514 |
print cols % (timetaken, test) |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
515 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
516 |
def outputcoverage(options): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
517 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
518 |
vlog('# Producing coverage report') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
519 |
os.chdir(PYTHONDIR) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
520 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
521 |
def covrun(*args): |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
522 |
cmd = 'coverage %s' % ' '.join(args) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
523 |
vlog('# Running: %s' % cmd) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
524 |
os.system(cmd) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
525 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
526 |
if options.child: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
527 |
return |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
528 |
|
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
529 |
covrun('-c') |
1038
62b7a0759ee3
run-tests: use a list comprehension instead of map
Matt Mackall <mpm@selenic.com>
parents:
1037
diff
changeset
|
530 |
omit = ','.join(os.path.join(x, '*') for x in [BINDIR, TESTDIR]) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
531 |
covrun('-i', '-r', '"--omit=%s"' % omit) # report |
1039
7c2190b236cf
tests: add htmlcov option
Markus Zapke-Gr?ndemann <info@keimlink.de>
parents:
1038
diff
changeset
|
532 |
if options.htmlcov: |
7c2190b236cf
tests: add htmlcov option
Markus Zapke-Gr?ndemann <info@keimlink.de>
parents:
1038
diff
changeset
|
533 |
htmldir = os.path.join(TESTDIR, 'htmlcov') |
7c2190b236cf
tests: add htmlcov option
Markus Zapke-Gr?ndemann <info@keimlink.de>
parents:
1038
diff
changeset
|
534 |
covrun('-i', '-b', '"--directory=%s"' % htmldir, '"--omit=%s"' % omit) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
535 |
if options.annotate: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
536 |
adir = os.path.join(TESTDIR, 'annotated') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
537 |
if not os.path.isdir(adir): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
538 |
os.mkdir(adir) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
539 |
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
|
540 |
|
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
541 |
def pytest(test, wd, options, replacements): |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
542 |
py3kswitch = options.py3k_warnings and ' -3' or '' |
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
543 |
cmd = '%s%s "%s"' % (PYTHON, py3kswitch, test) |
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
544 |
vlog("# Running", cmd) |
1151
676dce49d8e6
run-tests: handle windows crlf in .py tests again
Mads Kiilerich <mads@kiilerich.com>
parents:
1150
diff
changeset
|
545 |
if os.name == 'nt': |
676dce49d8e6
run-tests: handle windows crlf in .py tests again
Mads Kiilerich <mads@kiilerich.com>
parents:
1150
diff
changeset
|
546 |
replacements.append((r'\r\n', '\n')) |
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
547 |
return run(cmd, wd, options, replacements) |
775
16f4cb2900fe
tests: move script execution in runner helpers
Matt Mackall <mpm@selenic.com>
parents:
741
diff
changeset
|
548 |
|
858
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
549 |
needescape = re.compile(r'[\x00-\x08\x0b-\x1f\x7f-\xff]').search |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
550 |
escapesub = re.compile(r'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
551 |
escapemap = dict((chr(i), r'\x%02x' % i) for i in range(256)) |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
552 |
escapemap.update({'\\': '\\\\', '\r': r'\r'}) |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
553 |
def escapef(m): |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
554 |
return escapemap[m.group(0)] |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
555 |
def stringescape(s): |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
556 |
return escapesub(escapef, s) |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
557 |
|
1001
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
558 |
def rematch(el, l): |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
559 |
try: |
1149
a3d0e19724c3
run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1143
diff
changeset
|
560 |
# use \Z to ensure that the regex matches to the end of the string |
a3d0e19724c3
run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1143
diff
changeset
|
561 |
if os.name == 'nt': |
a3d0e19724c3
run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1143
diff
changeset
|
562 |
return re.match(el + r'\r?\n\Z', l) |
a3d0e19724c3
run-tests: alternative way of handling \r on Windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1143
diff
changeset
|
563 |
return re.match(el + r'\n\Z', l) |
1001
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
564 |
except re.error: |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
565 |
# el is an invalid regex |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
566 |
return False |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
567 |
|
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
568 |
def globmatch(el, l): |
1015
0a583943b4b4
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
1009
diff
changeset
|
569 |
# The only supported special characters are * and ? plus / which also |
0a583943b4b4
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
1009
diff
changeset
|
570 |
# matches \ on windows. Escaping of these caracters is supported. |
1215
62ff53b05730
tests: quickly check if the glob line already matches the output
Simon Heimberg <simohe@besonet.ch>
parents:
1212
diff
changeset
|
571 |
if el + '\n' == l: |
1216
192cebcd59a0
tests: inform on Windows about unnecessary glob lines
Simon Heimberg <simohe@besonet.ch>
parents:
1215
diff
changeset
|
572 |
if os.name == 'nt': |
192cebcd59a0
tests: inform on Windows about unnecessary glob lines
Simon Heimberg <simohe@besonet.ch>
parents:
1215
diff
changeset
|
573 |
# matching on "/" is not needed for this line |
192cebcd59a0
tests: inform on Windows about unnecessary glob lines
Simon Heimberg <simohe@besonet.ch>
parents:
1215
diff
changeset
|
574 |
iolock.acquire() |
192cebcd59a0
tests: inform on Windows about unnecessary glob lines
Simon Heimberg <simohe@besonet.ch>
parents:
1215
diff
changeset
|
575 |
print "\nInfo, unnecessary glob: %s (glob)" % el |
192cebcd59a0
tests: inform on Windows about unnecessary glob lines
Simon Heimberg <simohe@besonet.ch>
parents:
1215
diff
changeset
|
576 |
iolock.release() |
1215
62ff53b05730
tests: quickly check if the glob line already matches the output
Simon Heimberg <simohe@besonet.ch>
parents:
1212
diff
changeset
|
577 |
return True |
1001
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
578 |
i, n = 0, len(el) |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
579 |
res = '' |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
580 |
while i < n: |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
581 |
c = el[i] |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
582 |
i += 1 |
1015
0a583943b4b4
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
1009
diff
changeset
|
583 |
if c == '\\' and el[i] in '*?\\/': |
1001
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
584 |
res += el[i - 1:i + 1] |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
585 |
i += 1 |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
586 |
elif c == '*': |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
587 |
res += '.*' |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
588 |
elif c == '?': |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
589 |
res += '.' |
1015
0a583943b4b4
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
1009
diff
changeset
|
590 |
elif c == '/' and os.name == 'nt': |
0a583943b4b4
tests: make (glob) on windows accept \ instead of /
Mads Kiilerich <mads@kiilerich.com>
parents:
1009
diff
changeset
|
591 |
res += '[/\\\\]' |
1001
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
592 |
else: |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
593 |
res += re.escape(c) |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
594 |
return rematch(res, l) |
21b3c555b6f4
run-tests: pull out unified matching funcs
Matt Mackall <mpm@selenic.com>
parents:
1000
diff
changeset
|
595 |
|
1002
9a8202faebb3
run-tests: pull out line matching function
Matt Mackall <mpm@selenic.com>
parents:
1001
diff
changeset
|
596 |
def linematch(el, l): |
9a8202faebb3
run-tests: pull out line matching function
Matt Mackall <mpm@selenic.com>
parents:
1001
diff
changeset
|
597 |
if el == l: # perfect match (fast) |
9a8202faebb3
run-tests: pull out line matching function
Matt Mackall <mpm@selenic.com>
parents:
1001
diff
changeset
|
598 |
return True |
1150
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
599 |
if el: |
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
600 |
if el.endswith(" (esc)\n"): |
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
601 |
el = el[:-7].decode('string-escape') + '\n' |
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
602 |
if el == l or os.name == 'nt' and el[:-1] + '\r\n' == l: |
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
603 |
return True |
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
604 |
if (el.endswith(" (re)\n") and rematch(el[:-6], l) or |
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
605 |
el.endswith(" (glob)\n") and globmatch(el[:-8], l)): |
feb29f7d0066
run-tests: make it possible to combine (esc) with (glob) and (re)
Mads Kiilerich <mads@kiilerich.com>
parents:
1149
diff
changeset
|
606 |
return True |
1002
9a8202faebb3
run-tests: pull out line matching function
Matt Mackall <mpm@selenic.com>
parents:
1001
diff
changeset
|
607 |
return False |
9a8202faebb3
run-tests: pull out line matching function
Matt Mackall <mpm@selenic.com>
parents:
1001
diff
changeset
|
608 |
|
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
609 |
def tsttest(test, wd, options, replacements): |
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
610 |
# We generate a shell script which outputs unique markers to line |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
611 |
# up script results with our source. These markers include input |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
612 |
# line number and the last return code |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
613 |
salt = "SALT" + str(time.time()) |
1005
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
614 |
def addsalt(line, inpython): |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
615 |
if inpython: |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
616 |
script.append('%s %d 0\n' % (salt, line)) |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
617 |
else: |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
618 |
script.append('echo %s %s $?\n' % (salt, line)) |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
619 |
|
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
620 |
# After we run the shell script, we re-unify the script output |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
621 |
# with non-active parts of the source, with synchronization by our |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
622 |
# SALT line number markers. The after table contains the |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
623 |
# non-active components, ordered by line number |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
624 |
after = {} |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
625 |
pos = prepos = -1 |
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
626 |
|
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
627 |
# Expected shellscript output |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
628 |
expected = {} |
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
629 |
|
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
630 |
# We keep track of whether or not we're in a Python block so we |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
631 |
# can generate the surrounding doctest magic |
999
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
632 |
inpython = False |
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
633 |
|
1086
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
634 |
# True or False when in a true or false conditional section |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
635 |
skipping = None |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
636 |
|
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
637 |
def hghave(reqs): |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
638 |
# TODO: do something smarter when all other uses of hghave is gone |
1090
e7e4ca624772
tests/run-tests: avoid C:/ in arguments
Adrian Buehlmann <adrian@cadifra.com>
parents:
1088
diff
changeset
|
639 |
tdir = TESTDIR.replace('\\', '/') |
1086
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
640 |
proc = Popen4('%s -c "%s/hghave %s"' % |
1094
467eb2068e4a
tests: use the right directory for running hghave from run-tests.py
Mads Kiilerich <mads@kiilerich.com>
parents:
1093
diff
changeset
|
641 |
(options.shell, tdir, ' '.join(reqs)), wd, 0) |
1182
e553e222bd7e
tests: make hghave and run-tests exit on unknown feature requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
1175
diff
changeset
|
642 |
stdout, stderr = proc.communicate() |
1086
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
643 |
ret = proc.wait() |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
644 |
if wifexited(ret): |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
645 |
ret = os.WEXITSTATUS(ret) |
1182
e553e222bd7e
tests: make hghave and run-tests exit on unknown feature requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
1175
diff
changeset
|
646 |
if ret == 2: |
e553e222bd7e
tests: make hghave and run-tests exit on unknown feature requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
1175
diff
changeset
|
647 |
print stdout |
e553e222bd7e
tests: make hghave and run-tests exit on unknown feature requirements
Mads Kiilerich <mads@kiilerich.com>
parents:
1175
diff
changeset
|
648 |
sys.exit(1) |
1086
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
649 |
return ret == 0 |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
650 |
|
1003 | 651 |
f = open(test) |
652 |
t = f.readlines() |
|
653 |
f.close() |
|
654 |
||
655 |
script = [] |
|
1044
23c6e5d22e79
tests: add 'set -x' to the .t sh scripts in run-tests.py debug mode
Mads Kiilerich <mads@kiilerich.com>
parents:
1039
diff
changeset
|
656 |
if options.debug: |
23c6e5d22e79
tests: add 'set -x' to the .t sh scripts in run-tests.py debug mode
Mads Kiilerich <mads@kiilerich.com>
parents:
1039
diff
changeset
|
657 |
script.append('set -x\n') |
1033
8cbcb86e4fa8
tests: use an alias to make msys 'pwd' return paths with forward slashes
Mads Kiilerich <mads@kiilerich.com>
parents:
1022
diff
changeset
|
658 |
if os.getenv('MSYSTEM'): |
8cbcb86e4fa8
tests: use an alias to make msys 'pwd' return paths with forward slashes
Mads Kiilerich <mads@kiilerich.com>
parents:
1022
diff
changeset
|
659 |
script.append('alias pwd="pwd -W"\n') |
1210
02c4186c3aca
run-tests: do not fail on empty tsttest file
Simon Heimberg <simohe@besonet.ch>
parents:
1208
diff
changeset
|
660 |
n = 0 |
999
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
661 |
for n, l in enumerate(t): |
856
e1a5259b3d03
tests: handle .t files without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
852
diff
changeset
|
662 |
if not l.endswith('\n'): |
e1a5259b3d03
tests: handle .t files without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
852
diff
changeset
|
663 |
l += '\n' |
1086
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
664 |
if l.startswith('#if'): |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
665 |
if skipping is not None: |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
666 |
after.setdefault(pos, []).append(' !!! nested #if\n') |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
667 |
skipping = not hghave(l.split()[1:]) |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
668 |
after.setdefault(pos, []).append(l) |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
669 |
elif l.startswith('#else'): |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
670 |
if skipping is None: |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
671 |
after.setdefault(pos, []).append(' !!! missing #if\n') |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
672 |
skipping = not skipping |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
673 |
after.setdefault(pos, []).append(l) |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
674 |
elif l.startswith('#endif'): |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
675 |
if skipping is None: |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
676 |
after.setdefault(pos, []).append(' !!! missing #if\n') |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
677 |
skipping = None |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
678 |
after.setdefault(pos, []).append(l) |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
679 |
elif skipping: |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
680 |
after.setdefault(pos, []).append(l) |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
681 |
elif l.startswith(' >>> '): # python inlines |
1005
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
682 |
after.setdefault(pos, []).append(l) |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
683 |
prepos = pos |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
684 |
pos = n |
999
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
685 |
if not inpython: |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
686 |
# we've just entered a Python block, add the header |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
687 |
inpython = True |
1005
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
688 |
addsalt(prepos, False) # make sure we report the exit code |
999
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
689 |
script.append('%s -m heredoctest <<EOF\n' % PYTHON) |
1005
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
690 |
addsalt(n, True) |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
691 |
script.append(l[2:]) |
1085
a2e7456b162e
run-tests: don't add python lines to expected dict
Adrian Buehlmann <adrian@cadifra.com>
parents:
1084
diff
changeset
|
692 |
elif l.startswith(' ... '): # python inlines |
999
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
693 |
after.setdefault(prepos, []).append(l) |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
694 |
script.append(l[2:]) |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
695 |
elif l.startswith(' $ '): # commands |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
696 |
if inpython: |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
697 |
script.append("EOF\n") |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
698 |
inpython = False |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
699 |
after.setdefault(pos, []).append(l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
700 |
prepos = pos |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
701 |
pos = n |
1005
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
702 |
addsalt(n, False) |
1093
660262879b48
tests: make .t tests stop immediately if a cd fails
Mads Kiilerich <mads@kiilerich.com>
parents:
1090
diff
changeset
|
703 |
cmd = l[4:].split() |
660262879b48
tests: make .t tests stop immediately if a cd fails
Mads Kiilerich <mads@kiilerich.com>
parents:
1090
diff
changeset
|
704 |
if len(cmd) == 2 and cmd[0] == 'cd': |
660262879b48
tests: make .t tests stop immediately if a cd fails
Mads Kiilerich <mads@kiilerich.com>
parents:
1090
diff
changeset
|
705 |
l = ' $ cd %s || exit 1\n' % cmd[1] |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
706 |
script.append(l[4:]) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
707 |
elif l.startswith(' > '): # continuations |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
708 |
after.setdefault(prepos, []).append(l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
709 |
script.append(l[4:]) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
710 |
elif l.startswith(' '): # results |
1005
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
711 |
# queue up a list of expected results |
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
712 |
expected.setdefault(pos, []).append(l[2:]) |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
713 |
else: |
999
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
714 |
if inpython: |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
715 |
script.append("EOF\n") |
f89e9c528b38
tests: rewrite inline Python support
Matt Mackall <mpm@selenic.com>
parents:
996
diff
changeset
|
716 |
inpython = False |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
717 |
# non-command/result - queue up for merged output |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
718 |
after.setdefault(pos, []).append(l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
719 |
|
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
720 |
if inpython: |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
721 |
script.append("EOF\n") |
1086
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
722 |
if skipping is not None: |
a2e8ccb65224
tests: introduce c-style conditional sections in .t tests
Mads Kiilerich <mads@kiilerich.com>
parents:
1085
diff
changeset
|
723 |
after.setdefault(pos, []).append(' !!! missing #endif\n') |
1005
d86b26020b48
run-tests: replace inline python handling with more native scheme
Matt Mackall <mpm@selenic.com>
parents:
1003
diff
changeset
|
724 |
addsalt(n + 1, False) |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
725 |
|
1003 | 726 |
# Write out the script and execute it |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
727 |
fd, name = tempfile.mkstemp(suffix='hg-tst') |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
728 |
try: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
729 |
for l in script: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
730 |
os.write(fd, l) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
731 |
os.close(fd) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
732 |
|
1018
4d2cc32c6d97
run-tests: don't quote command names - that do apparently not work with msys
Mads Kiilerich <mads@kiilerich.com>
parents:
1017
diff
changeset
|
733 |
cmd = '%s "%s"' % (options.shell, name) |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
734 |
vlog("# Running", cmd) |
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
735 |
exitcode, output = run(cmd, wd, 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
|
736 |
# do not merge output if skipped, return hghave message instead |
862
c333552ec003
run-tests: fix --debug for .t tests
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
860
diff
changeset
|
737 |
# similarly, with --debug, output is None |
c333552ec003
run-tests: fix --debug for .t tests
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
860
diff
changeset
|
738 |
if exitcode == SKIPPED_STATUS or output is None: |
823
ab2ba4e79bed
tests: show skip reason instead of "irrelevant" with unified tests, too
Thomas Arendsen Hein <thomas@intevation.de>
parents:
822
diff
changeset
|
739 |
return exitcode, output |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
740 |
finally: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
741 |
os.remove(name) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
742 |
|
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
743 |
# Merge the script output back into a unified test |
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
744 |
|
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
745 |
pos = -1 |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
746 |
postout = [] |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
747 |
ret = 0 |
1135
7c026ccf4e1a
run-tests: drop unused enumerate
Mads Kiilerich <mads@kiilerich.com>
parents:
1131
diff
changeset
|
748 |
for l in output: |
857
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
749 |
lout, lcmd = l, None |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
750 |
if salt in l: |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
751 |
lout, lcmd = l.split(salt, 1) |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
752 |
|
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
753 |
if lout: |
1138
bb419c4bfdd9
run-tests: use more explicit criteria for detecting no-eol
Mads Kiilerich <mads@kiilerich.com>
parents:
1135
diff
changeset
|
754 |
if not lout.endswith('\n'): |
857
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
755 |
lout += ' (no-eol)\n' |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
756 |
|
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
757 |
# find the expected output at the current position |
857
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
758 |
el = None |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
759 |
if pos in expected and expected[pos]: |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
760 |
el = expected[pos].pop(0) |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
761 |
|
1002
9a8202faebb3
run-tests: pull out line matching function
Matt Mackall <mpm@selenic.com>
parents:
1001
diff
changeset
|
762 |
if linematch(el, lout): |
9a8202faebb3
run-tests: pull out line matching function
Matt Mackall <mpm@selenic.com>
parents:
1001
diff
changeset
|
763 |
postout.append(" " + el) |
857
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
764 |
else: |
858
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
765 |
if needescape(lout): |
ff1badf6ae7a
tests: use (esc) markup for string-escape
Mads Kiilerich <mads@kiilerich.com>
parents:
857
diff
changeset
|
766 |
lout = stringescape(lout.rstrip('\n')) + " (esc)\n" |
857
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
767 |
postout.append(" " + lout) # let diff deal with it |
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
768 |
|
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
769 |
if lcmd: |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
770 |
# add on last return code |
857
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
771 |
ret = int(lcmd.split()[1]) |
793
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
772 |
if ret != 0: |
9cc90e2c826f
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
777
diff
changeset
|
773 |
postout.append(" [%s]\n" % ret) |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
774 |
if pos in after: |
1000
cc9cdab213e1
tests: add some comments to the unified test code
Matt Mackall <mpm@selenic.com>
parents:
999
diff
changeset
|
775 |
# merge in non-active test bits |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
776 |
postout += after.pop(pos) |
857
7060aa668b7f
tests: (no-eol) markup for command output without trailing LF
Mads Kiilerich <mads@kiilerich.com>
parents:
856
diff
changeset
|
777 |
pos = int(lcmd.split()[0]) |
776
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
778 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
779 |
if pos in after: |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
780 |
postout += after.pop(pos) |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
781 |
|
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
782 |
return exitcode, postout |
1869efbf104d
tests: basic support for unified tests
Matt Mackall <mpm@selenic.com>
parents:
775
diff
changeset
|
783 |
|
878
e1a93489159d
run-tests: only call WIFEXITED on systems it exists
Simon Heimberg <simohe@besonet.ch>
parents:
877
diff
changeset
|
784 |
wifexited = getattr(os, "WIFEXITED", lambda x: False) |
919
1666a4a68262
run-tests: do chdir for tests under a lock for thread safety
Matt Mackall <mpm@selenic.com>
parents:
918
diff
changeset
|
785 |
def run(cmd, wd, options, replacements): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
786 |
"""Run command in a sub-process, capturing the output (stdout and stderr). |
670 | 787 |
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
|
788 |
# TODO: Use subprocess.Popen if we're running on Python 2.4 |
670 | 789 |
if options.debug: |
1203
67fb241fb0b1
run-tests.py: backout "don't use console for stdin when running in debug mode"
Mads Kiilerich <madski@unity3d.com>
parents:
1196
diff
changeset
|
790 |
proc = subprocess.Popen(cmd, shell=True, cwd=wd) |
670 | 791 |
ret = proc.wait() |
792 |
return (ret, None) |
|
793 |
||
945
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
794 |
proc = Popen4(cmd, wd, options.timeout) |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
795 |
def cleanup(): |
970
e42946273064
run-tests: fallback to SIGTERM if subprocess.Popen does not have terminate()
Thomas Arendsen Hein <thomas@intevation.de>
parents:
966
diff
changeset
|
796 |
terminate(proc) |
945
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
797 |
ret = proc.wait() |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
798 |
if ret == 0: |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
799 |
ret = signal.SIGTERM << 8 |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
800 |
killdaemons() |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
801 |
return ret |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
802 |
|
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
803 |
output = '' |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
804 |
proc.tochild.close() |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
805 |
|
945
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
806 |
try: |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
807 |
output = proc.fromchild.read() |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
808 |
except KeyboardInterrupt: |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
809 |
vlog('# Handling keyboard interrupt') |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
810 |
cleanup() |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
811 |
raise |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
812 |
|
945
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
813 |
ret = proc.wait() |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
814 |
if wifexited(ret): |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
815 |
ret = os.WEXITSTATUS(ret) |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
816 |
|
945
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
817 |
if proc.timeout: |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
818 |
ret = 'timeout' |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
819 |
|
945
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
820 |
if ret: |
83e828101e3c
run-tests: use the common test path on Windows and Java
Patrick Mezard <pmezard@gmail.com>
parents:
944
diff
changeset
|
821 |
killdaemons() |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
822 |
|
826
ac9b63e01e2a
tests: replace test tmp directory with $TESTTMP in test output
Mads Kiilerich <mads@kiilerich.com>
parents:
824
diff
changeset
|
823 |
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
|
824 |
output = re.sub(s, r, output) |
1139
cdabdd17f980
run-tests: allow test output lines to be terminated with \r in addition to \n
Mads Kiilerich <mads@kiilerich.com>
parents:
1138
diff
changeset
|
825 |
return ret, output.splitlines(True) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
826 |
|
912
17e4691cc491
run-tests: add locking on results struct
Matt Mackall <mpm@selenic.com>
parents:
910
diff
changeset
|
827 |
def runone(options, test): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
828 |
'''tristate output: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
829 |
None -> skipped |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
830 |
True -> passed |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
831 |
False -> failed''' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
832 |
|
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
833 |
global results, resultslock, iolock |
912
17e4691cc491
run-tests: add locking on results struct
Matt Mackall <mpm@selenic.com>
parents:
910
diff
changeset
|
834 |
|
903
92c48e9ca3a7
run-tests: move existence/name format check into runone
Matt Mackall <mpm@selenic.com>
parents:
902
diff
changeset
|
835 |
testpath = os.path.join(TESTDIR, test) |
92c48e9ca3a7
run-tests: move existence/name format check into runone
Matt Mackall <mpm@selenic.com>
parents:
902
diff
changeset
|
836 |
|
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
837 |
def result(l, e): |
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
838 |
resultslock.acquire() |
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
839 |
results[l].append(e) |
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
840 |
resultslock.release() |
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
841 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
842 |
def skip(msg): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
843 |
if not options.verbose: |
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
844 |
result('s', (test, msg)) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
845 |
else: |
915
5660a21567b7
run-tests: fix some missing i/o locks
Matt Mackall <mpm@selenic.com>
parents:
914
diff
changeset
|
846 |
iolock.acquire() |
670 | 847 |
print "\nSkipping %s: %s" % (testpath, msg) |
915
5660a21567b7
run-tests: fix some missing i/o locks
Matt Mackall <mpm@selenic.com>
parents:
914
diff
changeset
|
848 |
iolock.release() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
849 |
return None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
850 |
|
902
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
851 |
def fail(msg, ret): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
852 |
if not options.nodiff: |
915
5660a21567b7
run-tests: fix some missing i/o locks
Matt Mackall <mpm@selenic.com>
parents:
914
diff
changeset
|
853 |
iolock.acquire() |
670 | 854 |
print "\nERROR: %s %s" % (testpath, msg) |
915
5660a21567b7
run-tests: fix some missing i/o locks
Matt Mackall <mpm@selenic.com>
parents:
914
diff
changeset
|
855 |
iolock.release() |
910
b8ae2e290420
run-tests: fix --interactive (after 994ad067ac6e)
Patrick Mezard <pmezard@gmail.com>
parents:
909
diff
changeset
|
856 |
if (not ret and options.interactive |
b8ae2e290420
run-tests: fix --interactive (after 994ad067ac6e)
Patrick Mezard <pmezard@gmail.com>
parents:
909
diff
changeset
|
857 |
and os.path.exists(testpath + ".err")): |
915
5660a21567b7
run-tests: fix some missing i/o locks
Matt Mackall <mpm@selenic.com>
parents:
914
diff
changeset
|
858 |
iolock.acquire() |
902
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
859 |
print "Accept this change? [n] ", |
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
860 |
answer = sys.stdin.readline().strip() |
915
5660a21567b7
run-tests: fix some missing i/o locks
Matt Mackall <mpm@selenic.com>
parents:
914
diff
changeset
|
861 |
iolock.release() |
902
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
862 |
if answer.lower() in "y yes".split(): |
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
863 |
if test.endswith(".t"): |
910
b8ae2e290420
run-tests: fix --interactive (after 994ad067ac6e)
Patrick Mezard <pmezard@gmail.com>
parents:
909
diff
changeset
|
864 |
rename(testpath + ".err", testpath) |
902
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
865 |
else: |
910
b8ae2e290420
run-tests: fix --interactive (after 994ad067ac6e)
Patrick Mezard <pmezard@gmail.com>
parents:
909
diff
changeset
|
866 |
rename(testpath + ".err", testpath + ".out") |
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
867 |
result('p', test) |
902
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
868 |
return |
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
869 |
result('f', (test, msg)) |
908
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
870 |
|
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
871 |
def success(): |
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
872 |
result('p', test) |
908
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
873 |
|
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
874 |
def ignore(msg): |
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
875 |
result('i', (test, msg)) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
876 |
|
1229
e92556041140
tests: simplify handling of unknown test types
Matt Mackall <mpm@selenic.com>
parents:
1228
diff
changeset
|
877 |
if not os.path.exists(test): |
903
92c48e9ca3a7
run-tests: move existence/name format check into runone
Matt Mackall <mpm@selenic.com>
parents:
902
diff
changeset
|
878 |
skip("doesn't exist") |
92c48e9ca3a7
run-tests: move existence/name format check into runone
Matt Mackall <mpm@selenic.com>
parents:
902
diff
changeset
|
879 |
return None |
92c48e9ca3a7
run-tests: move existence/name format check into runone
Matt Mackall <mpm@selenic.com>
parents:
902
diff
changeset
|
880 |
|
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
881 |
if not (options.whitelisted and test in options.whitelisted): |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
882 |
if options.blacklist and test in options.blacklist: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
883 |
skip("blacklisted") |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
884 |
return None |
907
edf2753d3170
run-tests: move blacklist and retest filtering to runone
Matt Mackall <mpm@selenic.com>
parents:
906
diff
changeset
|
885 |
|
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
886 |
if options.retest and not os.path.exists(test + ".err"): |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
887 |
ignore("not retesting") |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
888 |
return None |
907
edf2753d3170
run-tests: move blacklist and retest filtering to runone
Matt Mackall <mpm@selenic.com>
parents:
906
diff
changeset
|
889 |
|
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
890 |
if options.keywords: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
891 |
fp = open(test) |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
892 |
t = fp.read().lower() + test.lower() |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
893 |
fp.close() |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
894 |
for k in options.keywords.lower().split(): |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
895 |
if k in t: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
896 |
break |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
897 |
else: |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
898 |
ignore("doesn't match keyword") |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
899 |
return None |
905
66b8706b3112
run-tests: move keyword checking into runone
Matt Mackall <mpm@selenic.com>
parents:
904
diff
changeset
|
900 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
901 |
vlog("# Test", test) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
902 |
|
1230
29767671c053
run-tests: pull hgrc creation out as function
Matt Mackall <mpm@selenic.com>
parents:
1229
diff
changeset
|
903 |
createhgrc(HGRCPATH, options) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
904 |
|
693
8428f3bda904
run-tests.py: skipped tests shouldn't change working directory
Mads Kiilerich <mads@kiilerich.com>
parents:
692
diff
changeset
|
905 |
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
|
906 |
if os.path.exists(err): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
907 |
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
|
908 |
lctest = test.lower() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
909 |
|
1227
afafc1812f7b
run-tests: make a table of test types
Matt Mackall <mpm@selenic.com>
parents:
1226
diff
changeset
|
910 |
for ext, func, out in testtypes: |
1229
e92556041140
tests: simplify handling of unknown test types
Matt Mackall <mpm@selenic.com>
parents:
1228
diff
changeset
|
911 |
if lctest.startswith("test-") and lctest.endswith(ext): |
1227
afafc1812f7b
run-tests: make a table of test types
Matt Mackall <mpm@selenic.com>
parents:
1226
diff
changeset
|
912 |
runner = func |
afafc1812f7b
run-tests: make a table of test types
Matt Mackall <mpm@selenic.com>
parents:
1226
diff
changeset
|
913 |
ref = os.path.join(TESTDIR, test + out) |
afafc1812f7b
run-tests: make a table of test types
Matt Mackall <mpm@selenic.com>
parents:
1226
diff
changeset
|
914 |
break |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
915 |
else: |
1152
9a4ed3acf89e
run-tests: remove dead code for supporting old test scripts
Mads Kiilerich <mads@kiilerich.com>
parents:
1151
diff
changeset
|
916 |
return skip("unknown test type") |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
917 |
|
693
8428f3bda904
run-tests.py: skipped tests shouldn't change working directory
Mads Kiilerich <mads@kiilerich.com>
parents:
692
diff
changeset
|
918 |
# Make a tmp subdirectory to work in |
895
1a9cd0b534a0
tests: set HOME to the test temp dir (issue2707)
Idan Kamara <idankk86@gmail.com>
parents:
882
diff
changeset
|
919 |
testtmp = os.environ["TESTTMP"] = os.environ["HOME"] = \ |
1090
e7e4ca624772
tests/run-tests: avoid C:/ in arguments
Adrian Buehlmann <adrian@cadifra.com>
parents:
1088
diff
changeset
|
920 |
os.path.join(HGTMP, os.path.basename(test)) |
1231
c6a4dd8d18a9
run-tests: regroup temp dir creation
Matt Mackall <mpm@selenic.com>
parents:
1230
diff
changeset
|
921 |
os.mkdir(testtmp) |
895
1a9cd0b534a0
tests: set HOME to the test temp dir (issue2707)
Idan Kamara <idankk86@gmail.com>
parents:
882
diff
changeset
|
922 |
|
1017
9cd561108da4
tests: ignore \r on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1016
diff
changeset
|
923 |
replacements = [ |
852
fb1e8925292d
run-tests: use regex when searching for $HGPORT in test output
Martin Geisler <mg@aragost.com>
parents:
844
diff
changeset
|
924 |
(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
|
925 |
(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
|
926 |
(r':%s\b' % (options.port + 2), ':$HGPORT2'), |
1017
9cd561108da4
tests: ignore \r on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1016
diff
changeset
|
927 |
] |
9cd561108da4
tests: ignore \r on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1016
diff
changeset
|
928 |
if os.name == 'nt': |
1019
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
929 |
replacements.append( |
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
930 |
(''.join(c.isalpha() and '[%s%s]' % (c.lower(), c.upper()) or |
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
931 |
c in '/\\' and r'[/\\]' or |
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
932 |
c.isdigit() and c or |
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
933 |
'\\' + c |
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
934 |
for c in testtmp), '$TESTTMP')) |
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
935 |
else: |
e7fbd63e5a98
run-tests: make $TESTTMP matching case-insensitive on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1018
diff
changeset
|
936 |
replacements.append((re.escape(testtmp), '$TESTTMP')) |
1017
9cd561108da4
tests: ignore \r on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1016
diff
changeset
|
937 |
|
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
938 |
if options.time: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
939 |
starttime = time.time() |
1017
9cd561108da4
tests: ignore \r on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
1016
diff
changeset
|
940 |
ret, out = runner(testpath, testtmp, options, replacements) |
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
941 |
if options.time: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
942 |
endtime = time.time() |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
943 |
times.append((test, endtime - starttime)) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
944 |
vlog("# Ret was:", ret) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
945 |
|
1173
d5da1c5cf1f5
tests: kill daemons early, making breaking at "Accept" prompt safe
Mads Kiilerich <madski@unity3d.com>
parents:
1172
diff
changeset
|
946 |
killdaemons() |
d5da1c5cf1f5
tests: kill daemons early, making breaking at "Accept" prompt safe
Mads Kiilerich <madski@unity3d.com>
parents:
1172
diff
changeset
|
947 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
948 |
mark = '.' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
949 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
950 |
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
|
951 |
|
670 | 952 |
# If we're not in --debug mode and reference output file exists, |
953 |
# check test output against it. |
|
954 |
if options.debug: |
|
866
d51c3fd4e34a
code style: prefer 'is' and 'is not' tests with singletons
Martin Geisler <mg@aragost.com>
parents:
862
diff
changeset
|
955 |
refout = None # to match "out is None" |
670 | 956 |
elif os.path.exists(ref): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
957 |
f = open(ref, "r") |
1139
cdabdd17f980
run-tests: allow test output lines to be terminated with \r in addition to \n
Mads Kiilerich <mads@kiilerich.com>
parents:
1138
diff
changeset
|
958 |
refout = f.read().splitlines(True) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
959 |
f.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
960 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
961 |
refout = [] |
670 | 962 |
|
741
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
963 |
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
|
964 |
# 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
|
965 |
f = open(err, "wb") |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
966 |
for line in out: |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
967 |
f.write(line) |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
968 |
f.close() |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
969 |
|
1143
38b7bb8f1c85
tests: correctly report a test killed by a signal
Bryan O'Sullivan <bryano@fb.com>
parents:
1139
diff
changeset
|
970 |
def describe(ret): |
38b7bb8f1c85
tests: correctly report a test killed by a signal
Bryan O'Sullivan <bryano@fb.com>
parents:
1139
diff
changeset
|
971 |
if ret < 0: |
38b7bb8f1c85
tests: correctly report a test killed by a signal
Bryan O'Sullivan <bryano@fb.com>
parents:
1139
diff
changeset
|
972 |
return 'killed by signal %d' % -ret |
38b7bb8f1c85
tests: correctly report a test killed by a signal
Bryan O'Sullivan <bryano@fb.com>
parents:
1139
diff
changeset
|
973 |
return 'returned error code %d' % ret |
38b7bb8f1c85
tests: correctly report a test killed by a signal
Bryan O'Sullivan <bryano@fb.com>
parents:
1139
diff
changeset
|
974 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
975 |
if skipped: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
976 |
mark = 's' |
670 | 977 |
if out is None: # debug mode: nothing to parse |
978 |
missing = ['unknown'] |
|
979 |
failed = None |
|
980 |
else: |
|
981 |
missing, failed = parsehghaveoutput(out) |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
982 |
if not missing: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
983 |
missing = ['irrelevant'] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
984 |
if failed: |
902
fb867941518c
run-tests: move interactive handling into runone
Matt Mackall <mpm@selenic.com>
parents:
899
diff
changeset
|
985 |
fail("hghave failed checking for %s" % failed[-1], ret) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
986 |
skipped = False |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
987 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
988 |
skip(missing[-1]) |
913
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
989 |
elif ret == 'timeout': |
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
990 |
mark = 't' |
ee01b53f9ac9
run-tests: switch timeout handling from alarm to helper thread
Matt Mackall <mpm@selenic.com>
parents:
912
diff
changeset
|
991 |
fail("timed out", ret) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
992 |
elif out != refout: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
993 |
mark = '!' |
916
dd5c50a018b0
run-tests: display diff before prompting with --interactive
Patrick Mezard <pmezard@gmail.com>
parents:
915
diff
changeset
|
994 |
if not options.nodiff: |
914
3c57e9963070
run-tests: add a lock for console I/O
Matt Mackall <mpm@selenic.com>
parents:
913
diff
changeset
|
995 |
iolock.acquire() |
741
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
996 |
if options.view: |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
997 |
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
|
998 |
else: |
e5bfe51eeea9
run-tests: add --view switch to use external diff viewer
Matt Mackall <mpm@selenic.com>
parents:
740
diff
changeset
|
999 |
showdiff(refout, out, ref, err) |
914
3c57e9963070
run-tests: add a lock for console I/O
Matt Mackall <mpm@selenic.com>
parents:
913
diff
changeset
|
1000 |
iolock.release() |
916
dd5c50a018b0
run-tests: display diff before prompting with --interactive
Patrick Mezard <pmezard@gmail.com>
parents:
915
diff
changeset
|
1001 |
if ret: |
1143
38b7bb8f1c85
tests: correctly report a test killed by a signal
Bryan O'Sullivan <bryano@fb.com>
parents:
1139
diff
changeset
|
1002 |
fail("output changed and " + describe(ret), ret) |
916
dd5c50a018b0
run-tests: display diff before prompting with --interactive
Patrick Mezard <pmezard@gmail.com>
parents:
915
diff
changeset
|
1003 |
else: |
dd5c50a018b0
run-tests: display diff before prompting with --interactive
Patrick Mezard <pmezard@gmail.com>
parents:
915
diff
changeset
|
1004 |
fail("output changed", ret) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1005 |
ret = 1 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1006 |
elif ret: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1007 |
mark = '!' |
1143
38b7bb8f1c85
tests: correctly report a test killed by a signal
Bryan O'Sullivan <bryano@fb.com>
parents:
1139
diff
changeset
|
1008 |
fail(describe(ret), ret) |
921
abb2a67ce631
run-tests: don't count test as succeeded if it failed
Idan Kamara <idankk86@gmail.com>
parents:
919
diff
changeset
|
1009 |
else: |
abb2a67ce631
run-tests: don't count test as succeeded if it failed
Idan Kamara <idankk86@gmail.com>
parents:
919
diff
changeset
|
1010 |
success() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1011 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1012 |
if not options.verbose: |
914
3c57e9963070
run-tests: add a lock for console I/O
Matt Mackall <mpm@selenic.com>
parents:
913
diff
changeset
|
1013 |
iolock.acquire() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1014 |
sys.stdout.write(mark) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1015 |
sys.stdout.flush() |
914
3c57e9963070
run-tests: add a lock for console I/O
Matt Mackall <mpm@selenic.com>
parents:
913
diff
changeset
|
1016 |
iolock.release() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1017 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1018 |
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
|
1019 |
shutil.rmtree(testtmp, True) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1020 |
if skipped: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1021 |
return None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1022 |
return ret == 0 |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1023 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1024 |
_hgpath = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1025 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1026 |
def _gethgpath(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1027 |
"""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
|
1028 |
the current Python interpreter.""" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1029 |
global _hgpath |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1030 |
if _hgpath is not None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1031 |
return _hgpath |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1032 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1033 |
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
|
1034 |
pipe = os.popen(cmd % PYTHON) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1035 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1036 |
_hgpath = pipe.read().strip() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1037 |
finally: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1038 |
pipe.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1039 |
return _hgpath |
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 |
def _checkhglib(verb): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1042 |
"""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
|
1043 |
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
|
1044 |
expecthg = os.path.join(PYTHONDIR, 'mercurial') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1045 |
actualhg = _gethgpath() |
934
cf241f12e977
run-tests: compare absolute paths in _checkhglib
Idan Kamara <idankk86@gmail.com>
parents:
932
diff
changeset
|
1046 |
if os.path.abspath(actualhg) != os.path.abspath(expecthg): |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1047 |
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
|
1048 |
' (expected %s)\n' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1049 |
% (verb, actualhg, expecthg)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1050 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1051 |
def runchildren(options, tests): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1052 |
if INST: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1053 |
installhg(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1054 |
_checkhglib("Testing") |
1168
96a0960a7909
run-tests: use correct python when run with --local
Bryan O'Sullivan <bryano@fb.com>
parents:
1166
diff
changeset
|
1055 |
else: |
96a0960a7909
run-tests: use correct python when run with --local
Bryan O'Sullivan <bryano@fb.com>
parents:
1166
diff
changeset
|
1056 |
usecorrectpython() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1057 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1058 |
optcopy = dict(options.__dict__) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1059 |
optcopy['jobs'] = 1 |
956
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1060 |
|
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1061 |
# Because whitelist has to override keyword matches, we have to |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1062 |
# actually load the whitelist in the children as well, so we allow |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1063 |
# the list of whitelist files to pass through and be parsed in the |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1064 |
# children, but not the dict of whitelisted tests resulting from |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1065 |
# the parse, used here to override blacklisted tests. |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1066 |
whitelist = optcopy['whitelisted'] or [] |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1067 |
del optcopy['whitelisted'] |
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1068 |
|
956
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1069 |
blacklist = optcopy['blacklist'] or [] |
725
212432db2043
Fix --blacklist when --jobs > 1 in run_tests.py.
Ry4an Brase <ry4an-hg@ry4an.org>
parents:
724
diff
changeset
|
1070 |
del optcopy['blacklist'] |
956
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1071 |
blacklisted = [] |
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1072 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1073 |
if optcopy['with_hg'] is None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1074 |
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
|
1075 |
optcopy.pop('anycoverage', None) |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
1076 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1077 |
opts = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1078 |
for opt, value in optcopy.iteritems(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1079 |
name = '--' + opt.replace('_', '-') |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1080 |
if value is True: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1081 |
opts.append(name) |
930
730303014491
run-tests.py: correctly handle list options with parallel tasks
Augie Fackler <durin42@gmail.com>
parents:
926
diff
changeset
|
1082 |
elif isinstance(value, list): |
730303014491
run-tests.py: correctly handle list options with parallel tasks
Augie Fackler <durin42@gmail.com>
parents:
926
diff
changeset
|
1083 |
for v in value: |
730303014491
run-tests.py: correctly handle list options with parallel tasks
Augie Fackler <durin42@gmail.com>
parents:
926
diff
changeset
|
1084 |
opts.append(name + '=' + str(v)) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1085 |
elif value is not None: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1086 |
opts.append(name + '=' + str(value)) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1087 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1088 |
tests.reverse() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1089 |
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
|
1090 |
while tests: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1091 |
for job in jobs: |
680
f10a5301d082
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
674
diff
changeset
|
1092 |
if not tests: |
f10a5301d082
many, many trivial check-code fixups
Matt Mackall <mpm@selenic.com>
parents:
674
diff
changeset
|
1093 |
break |
956
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1094 |
test = tests.pop() |
962
b5a4f9f5ec49
run-tests: allow whitelisting tests that should always run
Augie Fackler <durin42@gmail.com>
parents:
960
diff
changeset
|
1095 |
if test not in whitelist and test in blacklist: |
956
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1096 |
blacklisted.append(test) |
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1097 |
else: |
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1098 |
job.append(test) |
1171
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1099 |
|
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1100 |
waitq = queue.Queue() |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1101 |
|
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1102 |
# windows lacks os.wait, so we must emulate it |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1103 |
def waitfor(proc, rfd): |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1104 |
fp = os.fdopen(rfd, 'rb') |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1105 |
return lambda: waitq.put((proc.pid, proc.wait(), fp)) |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
1106 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1107 |
for j, job in enumerate(jobs): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1108 |
if not job: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1109 |
continue |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1110 |
rfd, wfd = os.pipe() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1111 |
childopts = ['--child=%d' % wfd, '--port=%d' % (options.port + j * 3)] |
670 | 1112 |
childtmp = os.path.join(HGTMP, 'child%d' % j) |
1113 |
childopts += ['--tmpdir', childtmp] |
|
1224
f3c19de4b29c
run-tests: when running in parallel, delete tmpdirs immediately
Siddharth Agarwal <sid0@fb.com>
parents:
1221
diff
changeset
|
1114 |
if options.keep_tmpdir: |
f3c19de4b29c
run-tests: when running in parallel, delete tmpdirs immediately
Siddharth Agarwal <sid0@fb.com>
parents:
1221
diff
changeset
|
1115 |
childopts.append('--keep-tmpdir') |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1116 |
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
|
1117 |
vlog(' '.join(cmdline)) |
1171
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1118 |
proc = subprocess.Popen(cmdline, executable=cmdline[0]) |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1119 |
threading.Thread(target=waitfor(proc, rfd)).start() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1120 |
os.close(wfd) |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
1121 |
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
|
1122 |
failures = 0 |
1157
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1123 |
passed, skipped, failed = 0, 0, 0 |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1124 |
skips = [] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1125 |
fails = [] |
1171
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1126 |
for job in jobs: |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1127 |
if not job: |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1128 |
continue |
5af439678b99
run-tests: support running tests in parallel on windows
Bryan O'Sullivan <bryano@fb.com>
parents:
1170
diff
changeset
|
1129 |
pid, status, fp = waitq.get() |
682
1c7056415039
run-tests: kill daemons on ^C with -j.
Brendan Cully <brendan@kublai.com>
parents:
681
diff
changeset
|
1130 |
try: |
1157
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1131 |
childresults = pickle.load(fp) |
1195
abba08b9f8e0
run-tests: exit cleanly if parallel run is interrupted
Bryan O'Sullivan <bryano@fb.com>
parents:
1186
diff
changeset
|
1132 |
except (pickle.UnpicklingError, EOFError): |
abba08b9f8e0
run-tests: exit cleanly if parallel run is interrupted
Bryan O'Sullivan <bryano@fb.com>
parents:
1186
diff
changeset
|
1133 |
sys.exit(255) |
1157
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1134 |
else: |
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1135 |
passed += len(childresults['p']) |
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1136 |
skipped += len(childresults['s']) |
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1137 |
failed += len(childresults['f']) |
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1138 |
skips.extend(childresults['s']) |
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1139 |
fails.extend(childresults['f']) |
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1140 |
if options.time: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1141 |
childtimes = pickle.load(fp) |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1142 |
times.extend(childtimes) |
1157
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1143 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1144 |
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
|
1145 |
failures |= status |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1146 |
print |
956
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1147 |
skipped += len(blacklisted) |
670 | 1148 |
if not options.noskips: |
1149 |
for s in skips: |
|
1150 |
print "Skipped %s: %s" % (s[0], s[1]) |
|
956
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1151 |
for s in blacklisted: |
e39ab51937a2
run-tests: fix --blacklist with jobs > 1
Idan Kamara <idankk86@gmail.com>
parents:
955
diff
changeset
|
1152 |
print "Skipped %s: blacklisted" % s |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1153 |
for s in fails: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1154 |
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
|
1155 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1156 |
_checkhglib("Tested") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1157 |
print "# Ran %d tests, %d skipped, %d failed." % ( |
1157
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1158 |
passed + failed, skipped, failed) |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
1159 |
|
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1160 |
if options.time: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1161 |
outputtimes(options) |
718
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
1162 |
if options.anycoverage: |
88d7be7899ac
tests: use external coverage, mandate newer version
Dirkjan Ochtman <djc.ochtman@kentyde.com>
parents:
693
diff
changeset
|
1163 |
outputcoverage(options) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1164 |
sys.exit(failures != 0) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1165 |
|
912
17e4691cc491
run-tests: add locking on results struct
Matt Mackall <mpm@selenic.com>
parents:
910
diff
changeset
|
1166 |
results = dict(p=[], f=[], s=[], i=[]) |
1163
d5d13134793a
run-tests: backout 4a4173519b63
Matt Mackall <mpm@selenic.com>
parents:
1161
diff
changeset
|
1167 |
resultslock = threading.Lock() |
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1168 |
times = [] |
914
3c57e9963070
run-tests: add a lock for console I/O
Matt Mackall <mpm@selenic.com>
parents:
913
diff
changeset
|
1169 |
iolock = threading.Lock() |
912
17e4691cc491
run-tests: add locking on results struct
Matt Mackall <mpm@selenic.com>
parents:
910
diff
changeset
|
1170 |
|
1161
ce884838a955
run-tests.py: remove runqueue's results parameter since it is now a global
Siddharth Agarwal <sid0@fb.com>
parents:
1160
diff
changeset
|
1171 |
def runqueue(options, tests): |
909
5ec26580cbb2
run-tests: move test loop into a helper function
Matt Mackall <mpm@selenic.com>
parents:
908
diff
changeset
|
1172 |
for test in tests: |
912
17e4691cc491
run-tests: add locking on results struct
Matt Mackall <mpm@selenic.com>
parents:
910
diff
changeset
|
1173 |
ret = runone(options, test) |
909
5ec26580cbb2
run-tests: move test loop into a helper function
Matt Mackall <mpm@selenic.com>
parents:
908
diff
changeset
|
1174 |
if options.first and ret is not None and not ret: |
5ec26580cbb2
run-tests: move test loop into a helper function
Matt Mackall <mpm@selenic.com>
parents:
908
diff
changeset
|
1175 |
break |
5ec26580cbb2
run-tests: move test loop into a helper function
Matt Mackall <mpm@selenic.com>
parents:
908
diff
changeset
|
1176 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1177 |
def runtests(options, tests): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1178 |
global DAEMON_PIDS, HGRCPATH |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1179 |
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
|
1180 |
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
|
1181 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1182 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1183 |
if INST: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1184 |
installhg(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1185 |
_checkhglib("Testing") |
1168
96a0960a7909
run-tests: use correct python when run with --local
Bryan O'Sullivan <bryano@fb.com>
parents:
1166
diff
changeset
|
1186 |
else: |
96a0960a7909
run-tests: use correct python when run with --local
Bryan O'Sullivan <bryano@fb.com>
parents:
1166
diff
changeset
|
1187 |
usecorrectpython() |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1188 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1189 |
if options.restart: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1190 |
orig = list(tests) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1191 |
while tests: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1192 |
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
|
1193 |
break |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1194 |
tests.pop(0) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1195 |
if not tests: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1196 |
print "running all tests" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1197 |
tests = orig |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1198 |
|
1161
ce884838a955
run-tests.py: remove runqueue's results parameter since it is now a global
Siddharth Agarwal <sid0@fb.com>
parents:
1160
diff
changeset
|
1199 |
runqueue(options, tests) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1200 |
|
908
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1201 |
failed = len(results['f']) |
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1202 |
tested = len(results['p']) + failed |
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1203 |
skipped = len(results['s']) |
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1204 |
ignored = len(results['i']) |
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1205 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1206 |
if options.child: |
1160
5a89f5217625
run-tests: open child-parent pipes in binary mode
Siddharth Agarwal <sid0@fb.com>
parents:
1159
diff
changeset
|
1207 |
fp = os.fdopen(options.child, 'wb') |
1157
06d4b5a1c4e8
run-tests: use pickle to send results from children to parent
Siddharth Agarwal <sid0@fb.com>
parents:
1155
diff
changeset
|
1208 |
pickle.dump(results, fp, pickle.HIGHEST_PROTOCOL) |
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1209 |
if options.time: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1210 |
pickle.dump(times, fp, pickle.HIGHEST_PROTOCOL) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1211 |
fp.close() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1212 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1213 |
print |
908
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1214 |
for s in results['s']: |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1215 |
print "Skipped %s: %s" % s |
908
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1216 |
for s in results['f']: |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1217 |
print "Failed %s: %s" % s |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1218 |
_checkhglib("Tested") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1219 |
print "# Ran %d tests, %d skipped, %d failed." % ( |
908
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1220 |
tested, skipped + ignored, failed) |
1159
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1221 |
if options.time: |
b2bd669641d3
run-tests: add --time option to log times for each test
Siddharth Agarwal <sid0@fb.com>
parents:
1158
diff
changeset
|
1222 |
outputtimes(options) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1223 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1224 |
if options.anycoverage: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1225 |
outputcoverage(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1226 |
except KeyboardInterrupt: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1227 |
failed = True |
1195
abba08b9f8e0
run-tests: exit cleanly if parallel run is interrupted
Bryan O'Sullivan <bryano@fb.com>
parents:
1186
diff
changeset
|
1228 |
if not options.child: |
abba08b9f8e0
run-tests: exit cleanly if parallel run is interrupted
Bryan O'Sullivan <bryano@fb.com>
parents:
1186
diff
changeset
|
1229 |
print "\ninterrupted!" |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1230 |
|
908
78f81dc655ca
run-tests: use a results dict
Matt Mackall <mpm@selenic.com>
parents:
907
diff
changeset
|
1231 |
if failed: |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1232 |
sys.exit(1) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1233 |
|
1227
afafc1812f7b
run-tests: make a table of test types
Matt Mackall <mpm@selenic.com>
parents:
1226
diff
changeset
|
1234 |
testtypes = [('.py', pytest, '.out'), |
afafc1812f7b
run-tests: make a table of test types
Matt Mackall <mpm@selenic.com>
parents:
1226
diff
changeset
|
1235 |
('.t', tsttest, '')] |
afafc1812f7b
run-tests: make a table of test types
Matt Mackall <mpm@selenic.com>
parents:
1226
diff
changeset
|
1236 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1237 |
def main(): |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1238 |
(options, args) = parseargs() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1239 |
if not options.child: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1240 |
os.umask(022) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1241 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1242 |
checktools() |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1243 |
|
1155
380eea1f5add
run-tests: skip unnecessary operations on the args in the child proces
Simon Heimberg <simohe@besonet.ch>
parents:
1152
diff
changeset
|
1244 |
if len(args) == 0: |
1228
db145eefc724
run-tests: filter out non-tests from default list
Matt Mackall <mpm@selenic.com>
parents:
1227
diff
changeset
|
1245 |
args = sorted(t for t in os.listdir(".") |
db145eefc724
run-tests: filter out non-tests from default list
Matt Mackall <mpm@selenic.com>
parents:
1227
diff
changeset
|
1246 |
if t.startswith("test-") |
db145eefc724
run-tests: filter out non-tests from default list
Matt Mackall <mpm@selenic.com>
parents:
1227
diff
changeset
|
1247 |
and (t.endswith(".py") or t.endswith(".t"))) |
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
|
1248 |
|
903
92c48e9ca3a7
run-tests: move existence/name format check into runone
Matt Mackall <mpm@selenic.com>
parents:
902
diff
changeset
|
1249 |
tests = args |
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
|
1250 |
|
1221
3a049b21a05b
run-tests: introduce --random for running tests in random error
Mads Kiilerich <madski@unity3d.com>
parents:
1219
diff
changeset
|
1251 |
if options.random: |
3a049b21a05b
run-tests: introduce --random for running tests in random error
Mads Kiilerich <madski@unity3d.com>
parents:
1219
diff
changeset
|
1252 |
random.shuffle(tests) |
3a049b21a05b
run-tests: introduce --random for running tests in random error
Mads Kiilerich <madski@unity3d.com>
parents:
1219
diff
changeset
|
1253 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1254 |
# 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
|
1255 |
# the tests produce repeatable output. |
670 | 1256 |
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
|
1257 |
os.environ['TZ'] = 'GMT' |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1258 |
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
|
1259 |
os.environ['CDPATH'] = '' |
670 | 1260 |
os.environ['COLUMNS'] = '80' |
719
ad3048630bd8
run-tests: make sure GREP_OPTIONS isn't set
Brodie Rao <brodie@bitheap.org>
parents:
718
diff
changeset
|
1261 |
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
|
1262 |
os.environ['http_proxy'] = '' |
996
dadecc4f3341
run-tests: make sure no_proxy/NO_PROXY are empty to fix test-http-proxy.t
Thomas Arendsen Hein <thomas@intevation.de>
parents:
989
diff
changeset
|
1263 |
os.environ['no_proxy'] = '' |
dadecc4f3341
run-tests: make sure no_proxy/NO_PROXY are empty to fix test-http-proxy.t
Thomas Arendsen Hein <thomas@intevation.de>
parents:
989
diff
changeset
|
1264 |
os.environ['NO_PROXY'] = '' |
1068
459c0537273b
tests: set a standard terminal type
Matt Mackall <mpm@selenic.com>
parents:
1065
diff
changeset
|
1265 |
os.environ['TERM'] = 'xterm' |
1212
2ea362720f72
test: display used python hash seed
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1210
diff
changeset
|
1266 |
if 'PYTHONHASHSEED' not in os.environ: |
2ea362720f72
test: display used python hash seed
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1210
diff
changeset
|
1267 |
# use a random python hash seed all the time |
2ea362720f72
test: display used python hash seed
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1210
diff
changeset
|
1268 |
# we do the randomness ourself to know what seed is used |
2ea362720f72
test: display used python hash seed
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1210
diff
changeset
|
1269 |
os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
2ea362720f72
test: display used python hash seed
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1210
diff
changeset
|
1270 |
print 'python hash seed:', os.environ['PYTHONHASHSEED'] |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1271 |
|
724
211fa4b9803d
run-tests.py: reset env variables set by hooks
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
722
diff
changeset
|
1272 |
# 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
|
1273 |
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
|
1274 |
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
|
1275 |
# 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
|
1276 |
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
|
1277 |
del os.environ[k] |
1131
1938c2ebf517
tests: unset variable HG if it is set
Simon Heimberg <simohe@besonet.ch>
parents:
1126
diff
changeset
|
1278 |
if 'HG' in os.environ: |
1938c2ebf517
tests: unset variable HG if it is set
Simon Heimberg <simohe@besonet.ch>
parents:
1126
diff
changeset
|
1279 |
# can't remove on solaris |
1938c2ebf517
tests: unset variable HG if it is set
Simon Heimberg <simohe@besonet.ch>
parents:
1126
diff
changeset
|
1280 |
os.environ['HG'] = '' |
1938c2ebf517
tests: unset variable HG if it is set
Simon Heimberg <simohe@besonet.ch>
parents:
1126
diff
changeset
|
1281 |
del os.environ['HG'] |
1218
d29df508e187
tests: fix test-profile to not depend on HGPROF environment variable
Durham Goode <durham@fb.com>
parents:
1216
diff
changeset
|
1282 |
if 'HGPROF' in os.environ: |
d29df508e187
tests: fix test-profile to not depend on HGPROF environment variable
Durham Goode <durham@fb.com>
parents:
1216
diff
changeset
|
1283 |
os.environ['HGPROF'] = '' |
d29df508e187
tests: fix test-profile to not depend on HGPROF environment variable
Durham Goode <durham@fb.com>
parents:
1216
diff
changeset
|
1284 |
del os.environ['HGPROF'] |
724
211fa4b9803d
run-tests.py: reset env variables set by hooks
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
722
diff
changeset
|
1285 |
|
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1286 |
global TESTDIR, HGTMP, INST, BINDIR, PYTHONDIR, COVERAGE_FILE |
1090
e7e4ca624772
tests/run-tests: avoid C:/ in arguments
Adrian Buehlmann <adrian@cadifra.com>
parents:
1088
diff
changeset
|
1287 |
TESTDIR = os.environ["TESTDIR"] = os.getcwd() |
670 | 1288 |
if options.tmpdir: |
1224
f3c19de4b29c
run-tests: when running in parallel, delete tmpdirs immediately
Siddharth Agarwal <sid0@fb.com>
parents:
1221
diff
changeset
|
1289 |
if not options.child: |
f3c19de4b29c
run-tests: when running in parallel, delete tmpdirs immediately
Siddharth Agarwal <sid0@fb.com>
parents:
1221
diff
changeset
|
1290 |
options.keep_tmpdir = True |
670 | 1291 |
tmpdir = options.tmpdir |
1292 |
if os.path.exists(tmpdir): |
|
1293 |
# Meaning of tmpdir has changed since 1.3: we used to create |
|
1294 |
# HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if |
|
1295 |
# tmpdir already exists. |
|
1296 |
sys.exit("error: temp dir %r already exists" % tmpdir) |
|
1297 |
||
1298 |
# Automatically removing tmpdir sounds convenient, but could |
|
1299 |
# really annoy anyone in the habit of using "--tmpdir=/tmp" |
|
1300 |
# or "--tmpdir=$HOME". |
|
1301 |
#vlog("# Removing temp dir", tmpdir) |
|
1302 |
#shutil.rmtree(tmpdir) |
|
1303 |
os.makedirs(tmpdir) |
|
1304 |
else: |
|
1088
e2d5315a6e38
tests/run-tests: use $TMP on Windows (issue3490)
Adrian Buehlmann <adrian@cadifra.com>
parents:
1086
diff
changeset
|
1305 |
d = None |
e2d5315a6e38
tests/run-tests: use $TMP on Windows (issue3490)
Adrian Buehlmann <adrian@cadifra.com>
parents:
1086
diff
changeset
|
1306 |
if os.name == 'nt': |
e2d5315a6e38
tests/run-tests: use $TMP on Windows (issue3490)
Adrian Buehlmann <adrian@cadifra.com>
parents:
1086
diff
changeset
|
1307 |
# without this, we get the default temp dir location, but |
e2d5315a6e38
tests/run-tests: use $TMP on Windows (issue3490)
Adrian Buehlmann <adrian@cadifra.com>
parents:
1086
diff
changeset
|
1308 |
# in all lowercase, which causes troubles with paths (issue3490) |
e2d5315a6e38
tests/run-tests: use $TMP on Windows (issue3490)
Adrian Buehlmann <adrian@cadifra.com>
parents:
1086
diff
changeset
|
1309 |
d = os.getenv('TMP') |
e2d5315a6e38
tests/run-tests: use $TMP on Windows (issue3490)
Adrian Buehlmann <adrian@cadifra.com>
parents:
1086
diff
changeset
|
1310 |
tmpdir = tempfile.mkdtemp('', 'hgtests.', d) |
670 | 1311 |
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
|
1312 |
DAEMON_PIDS = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1313 |
HGRCPATH = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1314 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1315 |
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
|
1316 |
os.environ["HGMERGE"] = "internal:merge" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1317 |
os.environ["HGUSER"] = "test" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1318 |
os.environ["HGENCODING"] = "ascii" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1319 |
os.environ["HGENCODINGMODE"] = "strict" |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1320 |
os.environ["HGPORT"] = str(options.port) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1321 |
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
|
1322 |
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
|
1323 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1324 |
if options.with_hg: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1325 |
INST = None |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1326 |
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
|
1327 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1328 |
# 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
|
1329 |
# 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
|
1330 |
# "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
|
1331 |
# 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
|
1332 |
# ... 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
|
1333 |
PYTHONDIR = BINDIR |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1334 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1335 |
INST = os.path.join(HGTMP, "install") |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1336 |
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
|
1337 |
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
|
1338 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1339 |
os.environ["BINDIR"] = BINDIR |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1340 |
os.environ["PYTHON"] = PYTHON |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1341 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1342 |
if not options.child: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1343 |
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
|
1344 |
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
|
1345 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1346 |
# 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
|
1347 |
# 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
|
1348 |
# adds an extension to HGRC |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1349 |
pypath = [PYTHONDIR, TESTDIR] |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1350 |
# 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
|
1351 |
# 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
|
1352 |
# 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
|
1353 |
# 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
|
1354 |
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
|
1355 |
if oldpypath: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1356 |
pypath.append(oldpypath) |
720
8008f7627b2f
tests: adapt the test runner to work with jython
Ronny Pfannschmidt <Ronny.Pfannschmidt@gmx.de>
parents:
719
diff
changeset
|
1357 |
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
|
1358 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1359 |
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
|
1360 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1361 |
vlog("# Using TESTDIR", TESTDIR) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1362 |
vlog("# Using HGTMP", HGTMP) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1363 |
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
|
1364 |
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
|
1365 |
|
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1366 |
try: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1367 |
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
|
1368 |
runchildren(options, tests) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1369 |
else: |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1370 |
runtests(options, tests) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1371 |
finally: |
1059
1745fd2dd308
tests: shorten post-test sleeps
Matt Mackall <mpm@selenic.com>
parents:
1046
diff
changeset
|
1372 |
time.sleep(.1) |
562
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1373 |
cleanup(options) |
b1aa7b64890b
Add run-tests.py from main and update README
Christian Ebert <blacktrash@gmx.net>
parents:
diff
changeset
|
1374 |
|
877
c2ca6e172fd8
run-tests: loadable as module
Simon Heimberg <simohe@besonet.ch>
parents:
866
diff
changeset
|
1375 |
if __name__ == '__main__': |
c2ca6e172fd8
run-tests: loadable as module
Simon Heimberg <simohe@besonet.ch>
parents:
866
diff
changeset
|
1376 |
main() |