Show More
@@ -1,3016 +1,3016 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | # |
|
2 | # | |
3 | # run-tests.py - Run a set of tests on Mercurial |
|
3 | # run-tests.py - Run a set of tests on Mercurial | |
4 | # |
|
4 | # | |
5 | # Copyright 2006 Matt Mackall <mpm@selenic.com> |
|
5 | # Copyright 2006 Matt Mackall <mpm@selenic.com> | |
6 | # |
|
6 | # | |
7 | # This software may be used and distributed according to the terms of the |
|
7 | # This software may be used and distributed according to the terms of the | |
8 | # GNU General Public License version 2 or any later version. |
|
8 | # GNU General Public License version 2 or any later version. | |
9 |
|
9 | |||
10 | # Modifying this script is tricky because it has many modes: |
|
10 | # Modifying this script is tricky because it has many modes: | |
11 | # - serial (default) vs parallel (-jN, N > 1) |
|
11 | # - serial (default) vs parallel (-jN, N > 1) | |
12 | # - no coverage (default) vs coverage (-c, -C, -s) |
|
12 | # - no coverage (default) vs coverage (-c, -C, -s) | |
13 | # - temp install (default) vs specific hg script (--with-hg, --local) |
|
13 | # - temp install (default) vs specific hg script (--with-hg, --local) | |
14 | # - tests are a mix of shell scripts and Python scripts |
|
14 | # - tests are a mix of shell scripts and Python scripts | |
15 | # |
|
15 | # | |
16 | # If you change this script, it is recommended that you ensure you |
|
16 | # If you change this script, it is recommended that you ensure you | |
17 | # haven't broken it by running it in various modes with a representative |
|
17 | # haven't broken it by running it in various modes with a representative | |
18 | # sample of test scripts. For example: |
|
18 | # sample of test scripts. For example: | |
19 | # |
|
19 | # | |
20 | # 1) serial, no coverage, temp install: |
|
20 | # 1) serial, no coverage, temp install: | |
21 | # ./run-tests.py test-s* |
|
21 | # ./run-tests.py test-s* | |
22 | # 2) serial, no coverage, local hg: |
|
22 | # 2) serial, no coverage, local hg: | |
23 | # ./run-tests.py --local test-s* |
|
23 | # ./run-tests.py --local test-s* | |
24 | # 3) serial, coverage, temp install: |
|
24 | # 3) serial, coverage, temp install: | |
25 | # ./run-tests.py -c test-s* |
|
25 | # ./run-tests.py -c test-s* | |
26 | # 4) serial, coverage, local hg: |
|
26 | # 4) serial, coverage, local hg: | |
27 | # ./run-tests.py -c --local test-s* # unsupported |
|
27 | # ./run-tests.py -c --local test-s* # unsupported | |
28 | # 5) parallel, no coverage, temp install: |
|
28 | # 5) parallel, no coverage, temp install: | |
29 | # ./run-tests.py -j2 test-s* |
|
29 | # ./run-tests.py -j2 test-s* | |
30 | # 6) parallel, no coverage, local hg: |
|
30 | # 6) parallel, no coverage, local hg: | |
31 | # ./run-tests.py -j2 --local test-s* |
|
31 | # ./run-tests.py -j2 --local test-s* | |
32 | # 7) parallel, coverage, temp install: |
|
32 | # 7) parallel, coverage, temp install: | |
33 | # ./run-tests.py -j2 -c test-s* # currently broken |
|
33 | # ./run-tests.py -j2 -c test-s* # currently broken | |
34 | # 8) parallel, coverage, local install: |
|
34 | # 8) parallel, coverage, local install: | |
35 | # ./run-tests.py -j2 -c --local test-s* # unsupported (and broken) |
|
35 | # ./run-tests.py -j2 -c --local test-s* # unsupported (and broken) | |
36 | # 9) parallel, custom tmp dir: |
|
36 | # 9) parallel, custom tmp dir: | |
37 | # ./run-tests.py -j2 --tmpdir /tmp/myhgtests |
|
37 | # ./run-tests.py -j2 --tmpdir /tmp/myhgtests | |
38 | # 10) parallel, pure, tests that call run-tests: |
|
38 | # 10) parallel, pure, tests that call run-tests: | |
39 | # ./run-tests.py --pure `grep -l run-tests.py *.t` |
|
39 | # ./run-tests.py --pure `grep -l run-tests.py *.t` | |
40 | # |
|
40 | # | |
41 | # (You could use any subset of the tests: test-s* happens to match |
|
41 | # (You could use any subset of the tests: test-s* happens to match | |
42 | # enough that it's worth doing parallel runs, few enough that it |
|
42 | # enough that it's worth doing parallel runs, few enough that it | |
43 | # completes fairly quickly, includes both shell and Python scripts, and |
|
43 | # completes fairly quickly, includes both shell and Python scripts, and | |
44 | # includes some scripts that run daemon processes.) |
|
44 | # includes some scripts that run daemon processes.) | |
45 |
|
45 | |||
46 | from __future__ import absolute_import, print_function |
|
46 | from __future__ import absolute_import, print_function | |
47 |
|
47 | |||
48 | import argparse |
|
48 | import argparse | |
49 | import collections |
|
49 | import collections | |
50 | import difflib |
|
50 | import difflib | |
51 | import distutils.version as version |
|
51 | import distutils.version as version | |
52 | import errno |
|
52 | import errno | |
53 | import json |
|
53 | import json | |
54 | import os |
|
54 | import os | |
55 | import random |
|
55 | import random | |
56 | import re |
|
56 | import re | |
57 | import shutil |
|
57 | import shutil | |
58 | import signal |
|
58 | import signal | |
59 | import socket |
|
59 | import socket | |
60 | import subprocess |
|
60 | import subprocess | |
61 | import sys |
|
61 | import sys | |
62 | import sysconfig |
|
62 | import sysconfig | |
63 | import tempfile |
|
63 | import tempfile | |
64 | import threading |
|
64 | import threading | |
65 | import time |
|
65 | import time | |
66 | import unittest |
|
66 | import unittest | |
67 | import xml.dom.minidom as minidom |
|
67 | import xml.dom.minidom as minidom | |
68 |
|
68 | |||
69 | try: |
|
69 | try: | |
70 | import Queue as queue |
|
70 | import Queue as queue | |
71 | except ImportError: |
|
71 | except ImportError: | |
72 | import queue |
|
72 | import queue | |
73 |
|
73 | |||
74 | try: |
|
74 | try: | |
75 | import shlex |
|
75 | import shlex | |
76 | shellquote = shlex.quote |
|
76 | shellquote = shlex.quote | |
77 | except (ImportError, AttributeError): |
|
77 | except (ImportError, AttributeError): | |
78 | import pipes |
|
78 | import pipes | |
79 | shellquote = pipes.quote |
|
79 | shellquote = pipes.quote | |
80 |
|
80 | |||
81 | if os.environ.get('RTUNICODEPEDANTRY', False): |
|
81 | if os.environ.get('RTUNICODEPEDANTRY', False): | |
82 | try: |
|
82 | try: | |
83 | reload(sys) |
|
83 | reload(sys) | |
84 | sys.setdefaultencoding("undefined") |
|
84 | sys.setdefaultencoding("undefined") | |
85 | except NameError: |
|
85 | except NameError: | |
86 | pass |
|
86 | pass | |
87 |
|
87 | |||
88 | origenviron = os.environ.copy() |
|
88 | origenviron = os.environ.copy() | |
89 | osenvironb = getattr(os, 'environb', os.environ) |
|
89 | osenvironb = getattr(os, 'environb', os.environ) | |
90 | processlock = threading.Lock() |
|
90 | processlock = threading.Lock() | |
91 |
|
91 | |||
92 | pygmentspresent = False |
|
92 | pygmentspresent = False | |
93 | # ANSI color is unsupported prior to Windows 10 |
|
93 | # ANSI color is unsupported prior to Windows 10 | |
94 | if os.name != 'nt': |
|
94 | if os.name != 'nt': | |
95 | try: # is pygments installed |
|
95 | try: # is pygments installed | |
96 | import pygments |
|
96 | import pygments | |
97 | import pygments.lexers as lexers |
|
97 | import pygments.lexers as lexers | |
98 | import pygments.lexer as lexer |
|
98 | import pygments.lexer as lexer | |
99 | import pygments.formatters as formatters |
|
99 | import pygments.formatters as formatters | |
100 | import pygments.token as token |
|
100 | import pygments.token as token | |
101 | import pygments.style as style |
|
101 | import pygments.style as style | |
102 | pygmentspresent = True |
|
102 | pygmentspresent = True | |
103 | difflexer = lexers.DiffLexer() |
|
103 | difflexer = lexers.DiffLexer() | |
104 | terminal256formatter = formatters.Terminal256Formatter() |
|
104 | terminal256formatter = formatters.Terminal256Formatter() | |
105 | except ImportError: |
|
105 | except ImportError: | |
106 | pass |
|
106 | pass | |
107 |
|
107 | |||
108 | if pygmentspresent: |
|
108 | if pygmentspresent: | |
109 | class TestRunnerStyle(style.Style): |
|
109 | class TestRunnerStyle(style.Style): | |
110 | default_style = "" |
|
110 | default_style = "" | |
111 | skipped = token.string_to_tokentype("Token.Generic.Skipped") |
|
111 | skipped = token.string_to_tokentype("Token.Generic.Skipped") | |
112 | failed = token.string_to_tokentype("Token.Generic.Failed") |
|
112 | failed = token.string_to_tokentype("Token.Generic.Failed") | |
113 | skippedname = token.string_to_tokentype("Token.Generic.SName") |
|
113 | skippedname = token.string_to_tokentype("Token.Generic.SName") | |
114 | failedname = token.string_to_tokentype("Token.Generic.FName") |
|
114 | failedname = token.string_to_tokentype("Token.Generic.FName") | |
115 | styles = { |
|
115 | styles = { | |
116 | skipped: '#e5e5e5', |
|
116 | skipped: '#e5e5e5', | |
117 | skippedname: '#00ffff', |
|
117 | skippedname: '#00ffff', | |
118 | failed: '#7f0000', |
|
118 | failed: '#7f0000', | |
119 | failedname: '#ff0000', |
|
119 | failedname: '#ff0000', | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 | class TestRunnerLexer(lexer.RegexLexer): |
|
122 | class TestRunnerLexer(lexer.RegexLexer): | |
123 | tokens = { |
|
123 | tokens = { | |
124 | 'root': [ |
|
124 | 'root': [ | |
125 | (r'^Skipped', token.Generic.Skipped, 'skipped'), |
|
125 | (r'^Skipped', token.Generic.Skipped, 'skipped'), | |
126 | (r'^Failed ', token.Generic.Failed, 'failed'), |
|
126 | (r'^Failed ', token.Generic.Failed, 'failed'), | |
127 | (r'^ERROR: ', token.Generic.Failed, 'failed'), |
|
127 | (r'^ERROR: ', token.Generic.Failed, 'failed'), | |
128 | ], |
|
128 | ], | |
129 | 'skipped': [ |
|
129 | 'skipped': [ | |
130 | (r'[\w-]+\.(t|py)', token.Generic.SName), |
|
130 | (r'[\w-]+\.(t|py)', token.Generic.SName), | |
131 | (r':.*', token.Generic.Skipped), |
|
131 | (r':.*', token.Generic.Skipped), | |
132 | ], |
|
132 | ], | |
133 | 'failed': [ |
|
133 | 'failed': [ | |
134 | (r'[\w-]+\.(t|py)', token.Generic.FName), |
|
134 | (r'[\w-]+\.(t|py)', token.Generic.FName), | |
135 | (r'(:| ).*', token.Generic.Failed), |
|
135 | (r'(:| ).*', token.Generic.Failed), | |
136 | ] |
|
136 | ] | |
137 | } |
|
137 | } | |
138 |
|
138 | |||
139 | runnerformatter = formatters.Terminal256Formatter(style=TestRunnerStyle) |
|
139 | runnerformatter = formatters.Terminal256Formatter(style=TestRunnerStyle) | |
140 | runnerlexer = TestRunnerLexer() |
|
140 | runnerlexer = TestRunnerLexer() | |
141 |
|
141 | |||
142 | if sys.version_info > (3, 5, 0): |
|
142 | if sys.version_info > (3, 5, 0): | |
143 | PYTHON3 = True |
|
143 | PYTHON3 = True | |
144 | xrange = range # we use xrange in one place, and we'd rather not use range |
|
144 | xrange = range # we use xrange in one place, and we'd rather not use range | |
145 | def _bytespath(p): |
|
145 | def _bytespath(p): | |
146 | if p is None: |
|
146 | if p is None: | |
147 | return p |
|
147 | return p | |
148 | return p.encode('utf-8') |
|
148 | return p.encode('utf-8') | |
149 |
|
149 | |||
150 | def _strpath(p): |
|
150 | def _strpath(p): | |
151 | if p is None: |
|
151 | if p is None: | |
152 | return p |
|
152 | return p | |
153 | return p.decode('utf-8') |
|
153 | return p.decode('utf-8') | |
154 |
|
154 | |||
155 | elif sys.version_info >= (3, 0, 0): |
|
155 | elif sys.version_info >= (3, 0, 0): | |
156 | print('%s is only supported on Python 3.5+ and 2.7, not %s' % |
|
156 | print('%s is only supported on Python 3.5+ and 2.7, not %s' % | |
157 | (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3]))) |
|
157 | (sys.argv[0], '.'.join(str(v) for v in sys.version_info[:3]))) | |
158 | sys.exit(70) # EX_SOFTWARE from `man 3 sysexit` |
|
158 | sys.exit(70) # EX_SOFTWARE from `man 3 sysexit` | |
159 | else: |
|
159 | else: | |
160 | PYTHON3 = False |
|
160 | PYTHON3 = False | |
161 |
|
161 | |||
162 | # In python 2.x, path operations are generally done using |
|
162 | # In python 2.x, path operations are generally done using | |
163 | # bytestrings by default, so we don't have to do any extra |
|
163 | # bytestrings by default, so we don't have to do any extra | |
164 | # fiddling there. We define the wrapper functions anyway just to |
|
164 | # fiddling there. We define the wrapper functions anyway just to | |
165 | # help keep code consistent between platforms. |
|
165 | # help keep code consistent between platforms. | |
166 | def _bytespath(p): |
|
166 | def _bytespath(p): | |
167 | return p |
|
167 | return p | |
168 |
|
168 | |||
169 | _strpath = _bytespath |
|
169 | _strpath = _bytespath | |
170 |
|
170 | |||
171 | # For Windows support |
|
171 | # For Windows support | |
172 | wifexited = getattr(os, "WIFEXITED", lambda x: False) |
|
172 | wifexited = getattr(os, "WIFEXITED", lambda x: False) | |
173 |
|
173 | |||
174 | # Whether to use IPv6 |
|
174 | # Whether to use IPv6 | |
175 | def checksocketfamily(name, port=20058): |
|
175 | def checksocketfamily(name, port=20058): | |
176 | """return true if we can listen on localhost using family=name |
|
176 | """return true if we can listen on localhost using family=name | |
177 |
|
177 | |||
178 | name should be either 'AF_INET', or 'AF_INET6'. |
|
178 | name should be either 'AF_INET', or 'AF_INET6'. | |
179 | port being used is okay - EADDRINUSE is considered as successful. |
|
179 | port being used is okay - EADDRINUSE is considered as successful. | |
180 | """ |
|
180 | """ | |
181 | family = getattr(socket, name, None) |
|
181 | family = getattr(socket, name, None) | |
182 | if family is None: |
|
182 | if family is None: | |
183 | return False |
|
183 | return False | |
184 | try: |
|
184 | try: | |
185 | s = socket.socket(family, socket.SOCK_STREAM) |
|
185 | s = socket.socket(family, socket.SOCK_STREAM) | |
186 | s.bind(('localhost', port)) |
|
186 | s.bind(('localhost', port)) | |
187 | s.close() |
|
187 | s.close() | |
188 | return True |
|
188 | return True | |
189 | except socket.error as exc: |
|
189 | except socket.error as exc: | |
190 | if exc.errno == errno.EADDRINUSE: |
|
190 | if exc.errno == errno.EADDRINUSE: | |
191 | return True |
|
191 | return True | |
192 | elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT): |
|
192 | elif exc.errno in (errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT): | |
193 | return False |
|
193 | return False | |
194 | else: |
|
194 | else: | |
195 | raise |
|
195 | raise | |
196 | else: |
|
196 | else: | |
197 | return False |
|
197 | return False | |
198 |
|
198 | |||
199 | # useipv6 will be set by parseargs |
|
199 | # useipv6 will be set by parseargs | |
200 | useipv6 = None |
|
200 | useipv6 = None | |
201 |
|
201 | |||
202 | def checkportisavailable(port): |
|
202 | def checkportisavailable(port): | |
203 | """return true if a port seems free to bind on localhost""" |
|
203 | """return true if a port seems free to bind on localhost""" | |
204 | if useipv6: |
|
204 | if useipv6: | |
205 | family = socket.AF_INET6 |
|
205 | family = socket.AF_INET6 | |
206 | else: |
|
206 | else: | |
207 | family = socket.AF_INET |
|
207 | family = socket.AF_INET | |
208 | try: |
|
208 | try: | |
209 | s = socket.socket(family, socket.SOCK_STREAM) |
|
209 | s = socket.socket(family, socket.SOCK_STREAM) | |
210 | s.bind(('localhost', port)) |
|
210 | s.bind(('localhost', port)) | |
211 | s.close() |
|
211 | s.close() | |
212 | return True |
|
212 | return True | |
213 | except socket.error as exc: |
|
213 | except socket.error as exc: | |
214 | if exc.errno not in (errno.EADDRINUSE, errno.EADDRNOTAVAIL, |
|
214 | if exc.errno not in (errno.EADDRINUSE, errno.EADDRNOTAVAIL, | |
215 | errno.EPROTONOSUPPORT): |
|
215 | errno.EPROTONOSUPPORT): | |
216 | raise |
|
216 | raise | |
217 | return False |
|
217 | return False | |
218 |
|
218 | |||
219 | closefds = os.name == 'posix' |
|
219 | closefds = os.name == 'posix' | |
220 | def Popen4(cmd, wd, timeout, env=None): |
|
220 | def Popen4(cmd, wd, timeout, env=None): | |
221 | processlock.acquire() |
|
221 | processlock.acquire() | |
222 | p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=wd, env=env, |
|
222 | p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=wd, env=env, | |
223 | close_fds=closefds, |
|
223 | close_fds=closefds, | |
224 | stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
|
224 | stdin=subprocess.PIPE, stdout=subprocess.PIPE, | |
225 | stderr=subprocess.STDOUT) |
|
225 | stderr=subprocess.STDOUT) | |
226 | processlock.release() |
|
226 | processlock.release() | |
227 |
|
227 | |||
228 | p.fromchild = p.stdout |
|
228 | p.fromchild = p.stdout | |
229 | p.tochild = p.stdin |
|
229 | p.tochild = p.stdin | |
230 | p.childerr = p.stderr |
|
230 | p.childerr = p.stderr | |
231 |
|
231 | |||
232 | p.timeout = False |
|
232 | p.timeout = False | |
233 | if timeout: |
|
233 | if timeout: | |
234 | def t(): |
|
234 | def t(): | |
235 | start = time.time() |
|
235 | start = time.time() | |
236 | while time.time() - start < timeout and p.returncode is None: |
|
236 | while time.time() - start < timeout and p.returncode is None: | |
237 | time.sleep(.1) |
|
237 | time.sleep(.1) | |
238 | p.timeout = True |
|
238 | p.timeout = True | |
239 | if p.returncode is None: |
|
239 | if p.returncode is None: | |
240 | terminate(p) |
|
240 | terminate(p) | |
241 | threading.Thread(target=t).start() |
|
241 | threading.Thread(target=t).start() | |
242 |
|
242 | |||
243 | return p |
|
243 | return p | |
244 |
|
244 | |||
245 | PYTHON = _bytespath(sys.executable.replace('\\', '/')) |
|
245 | PYTHON = _bytespath(sys.executable.replace('\\', '/')) | |
246 | IMPL_PATH = b'PYTHONPATH' |
|
246 | IMPL_PATH = b'PYTHONPATH' | |
247 | if 'java' in sys.platform: |
|
247 | if 'java' in sys.platform: | |
248 | IMPL_PATH = b'JYTHONPATH' |
|
248 | IMPL_PATH = b'JYTHONPATH' | |
249 |
|
249 | |||
250 | defaults = { |
|
250 | defaults = { | |
251 | 'jobs': ('HGTEST_JOBS', 1), |
|
251 | 'jobs': ('HGTEST_JOBS', 1), | |
252 | 'timeout': ('HGTEST_TIMEOUT', 180), |
|
252 | 'timeout': ('HGTEST_TIMEOUT', 180), | |
253 | 'slowtimeout': ('HGTEST_SLOWTIMEOUT', 500), |
|
253 | 'slowtimeout': ('HGTEST_SLOWTIMEOUT', 500), | |
254 | 'port': ('HGTEST_PORT', 20059), |
|
254 | 'port': ('HGTEST_PORT', 20059), | |
255 | 'shell': ('HGTEST_SHELL', 'sh'), |
|
255 | 'shell': ('HGTEST_SHELL', 'sh'), | |
256 | } |
|
256 | } | |
257 |
|
257 | |||
258 | def canonpath(path): |
|
258 | def canonpath(path): | |
259 | return os.path.realpath(os.path.expanduser(path)) |
|
259 | return os.path.realpath(os.path.expanduser(path)) | |
260 |
|
260 | |||
261 | def parselistfiles(files, listtype, warn=True): |
|
261 | def parselistfiles(files, listtype, warn=True): | |
262 | entries = dict() |
|
262 | entries = dict() | |
263 | for filename in files: |
|
263 | for filename in files: | |
264 | try: |
|
264 | try: | |
265 | path = os.path.expanduser(os.path.expandvars(filename)) |
|
265 | path = os.path.expanduser(os.path.expandvars(filename)) | |
266 | f = open(path, "rb") |
|
266 | f = open(path, "rb") | |
267 | except IOError as err: |
|
267 | except IOError as err: | |
268 | if err.errno != errno.ENOENT: |
|
268 | if err.errno != errno.ENOENT: | |
269 | raise |
|
269 | raise | |
270 | if warn: |
|
270 | if warn: | |
271 | print("warning: no such %s file: %s" % (listtype, filename)) |
|
271 | print("warning: no such %s file: %s" % (listtype, filename)) | |
272 | continue |
|
272 | continue | |
273 |
|
273 | |||
274 | for line in f.readlines(): |
|
274 | for line in f.readlines(): | |
275 | line = line.split(b'#', 1)[0].strip() |
|
275 | line = line.split(b'#', 1)[0].strip() | |
276 | if line: |
|
276 | if line: | |
277 | entries[line] = filename |
|
277 | entries[line] = filename | |
278 |
|
278 | |||
279 | f.close() |
|
279 | f.close() | |
280 | return entries |
|
280 | return entries | |
281 |
|
281 | |||
282 | def parsettestcases(path): |
|
282 | def parsettestcases(path): | |
283 | """read a .t test file, return a set of test case names |
|
283 | """read a .t test file, return a set of test case names | |
284 |
|
284 | |||
285 | If path does not exist, return an empty set. |
|
285 | If path does not exist, return an empty set. | |
286 | """ |
|
286 | """ | |
287 | cases = set() |
|
287 | cases = set() | |
288 | try: |
|
288 | try: | |
289 | with open(path, 'rb') as f: |
|
289 | with open(path, 'rb') as f: | |
290 | for l in f: |
|
290 | for l in f: | |
291 | if l.startswith(b'#testcases '): |
|
291 | if l.startswith(b'#testcases '): | |
292 | cases.update(l[11:].split()) |
|
292 | cases.update(l[11:].split()) | |
293 | except IOError as ex: |
|
293 | except IOError as ex: | |
294 | if ex.errno != errno.ENOENT: |
|
294 | if ex.errno != errno.ENOENT: | |
295 | raise |
|
295 | raise | |
296 | return cases |
|
296 | return cases | |
297 |
|
297 | |||
298 | def getparser(): |
|
298 | def getparser(): | |
299 | """Obtain the OptionParser used by the CLI.""" |
|
299 | """Obtain the OptionParser used by the CLI.""" | |
300 | parser = argparse.ArgumentParser(usage='%(prog)s [options] [tests]') |
|
300 | parser = argparse.ArgumentParser(usage='%(prog)s [options] [tests]') | |
301 |
|
301 | |||
302 | selection = parser.add_argument_group('Test Selection') |
|
302 | selection = parser.add_argument_group('Test Selection') | |
303 | selection.add_argument('--allow-slow-tests', action='store_true', |
|
303 | selection.add_argument('--allow-slow-tests', action='store_true', | |
304 | help='allow extremely slow tests') |
|
304 | help='allow extremely slow tests') | |
305 | selection.add_argument("--blacklist", action="append", |
|
305 | selection.add_argument("--blacklist", action="append", | |
306 | help="skip tests listed in the specified blacklist file") |
|
306 | help="skip tests listed in the specified blacklist file") | |
307 | selection.add_argument("--changed", |
|
307 | selection.add_argument("--changed", | |
308 | help="run tests that are changed in parent rev or working directory") |
|
308 | help="run tests that are changed in parent rev or working directory") | |
309 | selection.add_argument("-k", "--keywords", |
|
309 | selection.add_argument("-k", "--keywords", | |
310 | help="run tests matching keywords") |
|
310 | help="run tests matching keywords") | |
311 | selection.add_argument("-r", "--retest", action="store_true", |
|
311 | selection.add_argument("-r", "--retest", action="store_true", | |
312 | help = "retest failed tests") |
|
312 | help = "retest failed tests") | |
313 | selection.add_argument("--test-list", action="append", |
|
313 | selection.add_argument("--test-list", action="append", | |
314 | help="read tests to run from the specified file") |
|
314 | help="read tests to run from the specified file") | |
315 | selection.add_argument("--whitelist", action="append", |
|
315 | selection.add_argument("--whitelist", action="append", | |
316 | help="always run tests listed in the specified whitelist file") |
|
316 | help="always run tests listed in the specified whitelist file") | |
317 | selection.add_argument('tests', metavar='TESTS', nargs='*', |
|
317 | selection.add_argument('tests', metavar='TESTS', nargs='*', | |
318 | help='Tests to run') |
|
318 | help='Tests to run') | |
319 |
|
319 | |||
320 | harness = parser.add_argument_group('Test Harness Behavior') |
|
320 | harness = parser.add_argument_group('Test Harness Behavior') | |
321 | harness.add_argument('--bisect-repo', |
|
321 | harness.add_argument('--bisect-repo', | |
322 | metavar='bisect_repo', |
|
322 | metavar='bisect_repo', | |
323 | help=("Path of a repo to bisect. Use together with " |
|
323 | help=("Path of a repo to bisect. Use together with " | |
324 | "--known-good-rev")) |
|
324 | "--known-good-rev")) | |
325 | harness.add_argument("-d", "--debug", action="store_true", |
|
325 | harness.add_argument("-d", "--debug", action="store_true", | |
326 | help="debug mode: write output of test scripts to console" |
|
326 | help="debug mode: write output of test scripts to console" | |
327 | " rather than capturing and diffing it (disables timeout)") |
|
327 | " rather than capturing and diffing it (disables timeout)") | |
328 | harness.add_argument("-f", "--first", action="store_true", |
|
328 | harness.add_argument("-f", "--first", action="store_true", | |
329 | help="exit on the first test failure") |
|
329 | help="exit on the first test failure") | |
330 | harness.add_argument("-i", "--interactive", action="store_true", |
|
330 | harness.add_argument("-i", "--interactive", action="store_true", | |
331 | help="prompt to accept changed output") |
|
331 | help="prompt to accept changed output") | |
332 | harness.add_argument("-j", "--jobs", type=int, |
|
332 | harness.add_argument("-j", "--jobs", type=int, | |
333 | help="number of jobs to run in parallel" |
|
333 | help="number of jobs to run in parallel" | |
334 | " (default: $%s or %d)" % defaults['jobs']) |
|
334 | " (default: $%s or %d)" % defaults['jobs']) | |
335 | harness.add_argument("--keep-tmpdir", action="store_true", |
|
335 | harness.add_argument("--keep-tmpdir", action="store_true", | |
336 | help="keep temporary directory after running tests") |
|
336 | help="keep temporary directory after running tests") | |
337 | harness.add_argument('--known-good-rev', |
|
337 | harness.add_argument('--known-good-rev', | |
338 | metavar="known_good_rev", |
|
338 | metavar="known_good_rev", | |
339 | help=("Automatically bisect any failures using this " |
|
339 | help=("Automatically bisect any failures using this " | |
340 | "revision as a known-good revision.")) |
|
340 | "revision as a known-good revision.")) | |
341 | harness.add_argument("--list-tests", action="store_true", |
|
341 | harness.add_argument("--list-tests", action="store_true", | |
342 | help="list tests instead of running them") |
|
342 | help="list tests instead of running them") | |
343 | harness.add_argument("--loop", action="store_true", |
|
343 | harness.add_argument("--loop", action="store_true", | |
344 | help="loop tests repeatedly") |
|
344 | help="loop tests repeatedly") | |
345 | harness.add_argument('--random', action="store_true", |
|
345 | harness.add_argument('--random', action="store_true", | |
346 | help='run tests in random order') |
|
346 | help='run tests in random order') | |
347 | harness.add_argument("-p", "--port", type=int, |
|
347 | harness.add_argument("-p", "--port", type=int, | |
348 | help="port on which servers should listen" |
|
348 | help="port on which servers should listen" | |
349 | " (default: $%s or %d)" % defaults['port']) |
|
349 | " (default: $%s or %d)" % defaults['port']) | |
350 | harness.add_argument('--profile-runner', action='store_true', |
|
350 | harness.add_argument('--profile-runner', action='store_true', | |
351 | help='run statprof on run-tests') |
|
351 | help='run statprof on run-tests') | |
352 | harness.add_argument("-R", "--restart", action="store_true", |
|
352 | harness.add_argument("-R", "--restart", action="store_true", | |
353 | help="restart at last error") |
|
353 | help="restart at last error") | |
354 | harness.add_argument("--runs-per-test", type=int, dest="runs_per_test", |
|
354 | harness.add_argument("--runs-per-test", type=int, dest="runs_per_test", | |
355 | help="run each test N times (default=1)", default=1) |
|
355 | help="run each test N times (default=1)", default=1) | |
356 | harness.add_argument("--shell", |
|
356 | harness.add_argument("--shell", | |
357 | help="shell to use (default: $%s or %s)" % defaults['shell']) |
|
357 | help="shell to use (default: $%s or %s)" % defaults['shell']) | |
358 | harness.add_argument('--showchannels', action='store_true', |
|
358 | harness.add_argument('--showchannels', action='store_true', | |
359 | help='show scheduling channels') |
|
359 | help='show scheduling channels') | |
360 | harness.add_argument("--slowtimeout", type=int, |
|
360 | harness.add_argument("--slowtimeout", type=int, | |
361 | help="kill errant slow tests after SLOWTIMEOUT seconds" |
|
361 | help="kill errant slow tests after SLOWTIMEOUT seconds" | |
362 | " (default: $%s or %d)" % defaults['slowtimeout']) |
|
362 | " (default: $%s or %d)" % defaults['slowtimeout']) | |
363 | harness.add_argument("-t", "--timeout", type=int, |
|
363 | harness.add_argument("-t", "--timeout", type=int, | |
364 | help="kill errant tests after TIMEOUT seconds" |
|
364 | help="kill errant tests after TIMEOUT seconds" | |
365 | " (default: $%s or %d)" % defaults['timeout']) |
|
365 | " (default: $%s or %d)" % defaults['timeout']) | |
366 | harness.add_argument("--tmpdir", |
|
366 | harness.add_argument("--tmpdir", | |
367 | help="run tests in the given temporary directory" |
|
367 | help="run tests in the given temporary directory" | |
368 | " (implies --keep-tmpdir)") |
|
368 | " (implies --keep-tmpdir)") | |
369 | harness.add_argument("-v", "--verbose", action="store_true", |
|
369 | harness.add_argument("-v", "--verbose", action="store_true", | |
370 | help="output verbose messages") |
|
370 | help="output verbose messages") | |
371 |
|
371 | |||
372 | hgconf = parser.add_argument_group('Mercurial Configuration') |
|
372 | hgconf = parser.add_argument_group('Mercurial Configuration') | |
373 | hgconf.add_argument("--chg", action="store_true", |
|
373 | hgconf.add_argument("--chg", action="store_true", | |
374 | help="install and use chg wrapper in place of hg") |
|
374 | help="install and use chg wrapper in place of hg") | |
375 | hgconf.add_argument("--compiler", |
|
375 | hgconf.add_argument("--compiler", | |
376 | help="compiler to build with") |
|
376 | help="compiler to build with") | |
377 | hgconf.add_argument('--extra-config-opt', action="append", default=[], |
|
377 | hgconf.add_argument('--extra-config-opt', action="append", default=[], | |
378 | help='set the given config opt in the test hgrc') |
|
378 | help='set the given config opt in the test hgrc') | |
379 | hgconf.add_argument("-l", "--local", action="store_true", |
|
379 | hgconf.add_argument("-l", "--local", action="store_true", | |
380 | help="shortcut for --with-hg=<testdir>/../hg, " |
|
380 | help="shortcut for --with-hg=<testdir>/../hg, " | |
381 | "and --with-chg=<testdir>/../contrib/chg/chg if --chg is set") |
|
381 | "and --with-chg=<testdir>/../contrib/chg/chg if --chg is set") | |
382 | hgconf.add_argument("--ipv6", action="store_true", |
|
382 | hgconf.add_argument("--ipv6", action="store_true", | |
383 | help="prefer IPv6 to IPv4 for network related tests") |
|
383 | help="prefer IPv6 to IPv4 for network related tests") | |
384 | hgconf.add_argument("--pure", action="store_true", |
|
384 | hgconf.add_argument("--pure", action="store_true", | |
385 | help="use pure Python code instead of C extensions") |
|
385 | help="use pure Python code instead of C extensions") | |
386 | hgconf.add_argument("-3", "--py3k-warnings", action="store_true", |
|
386 | hgconf.add_argument("-3", "--py3k-warnings", action="store_true", | |
387 | help="enable Py3k warnings on Python 2.7+") |
|
387 | help="enable Py3k warnings on Python 2.7+") | |
388 | hgconf.add_argument("--with-chg", metavar="CHG", |
|
388 | hgconf.add_argument("--with-chg", metavar="CHG", | |
389 | help="use specified chg wrapper in place of hg") |
|
389 | help="use specified chg wrapper in place of hg") | |
390 | hgconf.add_argument("--with-hg", |
|
390 | hgconf.add_argument("--with-hg", | |
391 | metavar="HG", |
|
391 | metavar="HG", | |
392 | help="test using specified hg script rather than a " |
|
392 | help="test using specified hg script rather than a " | |
393 | "temporary installation") |
|
393 | "temporary installation") | |
394 | # This option should be deleted once test-check-py3-compat.t and other |
|
394 | # This option should be deleted once test-check-py3-compat.t and other | |
395 | # Python 3 tests run with Python 3. |
|
395 | # Python 3 tests run with Python 3. | |
396 | hgconf.add_argument("--with-python3", metavar="PYTHON3", |
|
396 | hgconf.add_argument("--with-python3", metavar="PYTHON3", | |
397 | help="Python 3 interpreter (if running under Python 2)" |
|
397 | help="Python 3 interpreter (if running under Python 2)" | |
398 | " (TEMPORARY)") |
|
398 | " (TEMPORARY)") | |
399 |
|
399 | |||
400 | reporting = parser.add_argument_group('Results Reporting') |
|
400 | reporting = parser.add_argument_group('Results Reporting') | |
401 | reporting.add_argument("-C", "--annotate", action="store_true", |
|
401 | reporting.add_argument("-C", "--annotate", action="store_true", | |
402 | help="output files annotated with coverage") |
|
402 | help="output files annotated with coverage") | |
403 | reporting.add_argument("--color", choices=["always", "auto", "never"], |
|
403 | reporting.add_argument("--color", choices=["always", "auto", "never"], | |
404 | default=os.environ.get('HGRUNTESTSCOLOR', 'auto'), |
|
404 | default=os.environ.get('HGRUNTESTSCOLOR', 'auto'), | |
405 | help="colorisation: always|auto|never (default: auto)") |
|
405 | help="colorisation: always|auto|never (default: auto)") | |
406 | reporting.add_argument("-c", "--cover", action="store_true", |
|
406 | reporting.add_argument("-c", "--cover", action="store_true", | |
407 | help="print a test coverage report") |
|
407 | help="print a test coverage report") | |
408 | reporting.add_argument('--exceptions', action='store_true', |
|
408 | reporting.add_argument('--exceptions', action='store_true', | |
409 | help='log all exceptions and generate an exception report') |
|
409 | help='log all exceptions and generate an exception report') | |
410 | reporting.add_argument("-H", "--htmlcov", action="store_true", |
|
410 | reporting.add_argument("-H", "--htmlcov", action="store_true", | |
411 | help="create an HTML report of the coverage of the files") |
|
411 | help="create an HTML report of the coverage of the files") | |
412 | reporting.add_argument("--json", action="store_true", |
|
412 | reporting.add_argument("--json", action="store_true", | |
413 | help="store test result data in 'report.json' file") |
|
413 | help="store test result data in 'report.json' file") | |
414 | reporting.add_argument("--outputdir", |
|
414 | reporting.add_argument("--outputdir", | |
415 | help="directory to write error logs to (default=test directory)") |
|
415 | help="directory to write error logs to (default=test directory)") | |
416 | reporting.add_argument("-n", "--nodiff", action="store_true", |
|
416 | reporting.add_argument("-n", "--nodiff", action="store_true", | |
417 | help="skip showing test changes") |
|
417 | help="skip showing test changes") | |
418 | reporting.add_argument("-S", "--noskips", action="store_true", |
|
418 | reporting.add_argument("-S", "--noskips", action="store_true", | |
419 | help="don't report skip tests verbosely") |
|
419 | help="don't report skip tests verbosely") | |
420 | reporting.add_argument("--time", action="store_true", |
|
420 | reporting.add_argument("--time", action="store_true", | |
421 | help="time how long each test takes") |
|
421 | help="time how long each test takes") | |
422 | reporting.add_argument("--view", |
|
422 | reporting.add_argument("--view", | |
423 | help="external diff viewer") |
|
423 | help="external diff viewer") | |
424 | reporting.add_argument("--xunit", |
|
424 | reporting.add_argument("--xunit", | |
425 | help="record xunit results at specified path") |
|
425 | help="record xunit results at specified path") | |
426 |
|
426 | |||
427 | for option, (envvar, default) in defaults.items(): |
|
427 | for option, (envvar, default) in defaults.items(): | |
428 | defaults[option] = type(default)(os.environ.get(envvar, default)) |
|
428 | defaults[option] = type(default)(os.environ.get(envvar, default)) | |
429 | parser.set_defaults(**defaults) |
|
429 | parser.set_defaults(**defaults) | |
430 |
|
430 | |||
431 | return parser |
|
431 | return parser | |
432 |
|
432 | |||
433 | def parseargs(args, parser): |
|
433 | def parseargs(args, parser): | |
434 | """Parse arguments with our OptionParser and validate results.""" |
|
434 | """Parse arguments with our OptionParser and validate results.""" | |
435 | options = parser.parse_args(args) |
|
435 | options = parser.parse_args(args) | |
436 |
|
436 | |||
437 | # jython is always pure |
|
437 | # jython is always pure | |
438 | if 'java' in sys.platform or '__pypy__' in sys.modules: |
|
438 | if 'java' in sys.platform or '__pypy__' in sys.modules: | |
439 | options.pure = True |
|
439 | options.pure = True | |
440 |
|
440 | |||
441 | if options.with_hg: |
|
441 | if options.with_hg: | |
442 | options.with_hg = canonpath(_bytespath(options.with_hg)) |
|
442 | options.with_hg = canonpath(_bytespath(options.with_hg)) | |
443 | if not (os.path.isfile(options.with_hg) and |
|
443 | if not (os.path.isfile(options.with_hg) and | |
444 | os.access(options.with_hg, os.X_OK)): |
|
444 | os.access(options.with_hg, os.X_OK)): | |
445 | parser.error('--with-hg must specify an executable hg script') |
|
445 | parser.error('--with-hg must specify an executable hg script') | |
446 | if os.path.basename(options.with_hg) not in [b'hg', b'hg.exe']: |
|
446 | if os.path.basename(options.with_hg) not in [b'hg', b'hg.exe']: | |
447 | sys.stderr.write('warning: --with-hg should specify an hg script\n') |
|
447 | sys.stderr.write('warning: --with-hg should specify an hg script\n') | |
448 | if options.local: |
|
448 | if options.local: | |
449 | testdir = os.path.dirname(_bytespath(canonpath(sys.argv[0]))) |
|
449 | testdir = os.path.dirname(_bytespath(canonpath(sys.argv[0]))) | |
450 | reporootdir = os.path.dirname(testdir) |
|
450 | reporootdir = os.path.dirname(testdir) | |
451 | pathandattrs = [(b'hg', 'with_hg')] |
|
451 | pathandattrs = [(b'hg', 'with_hg')] | |
452 | if options.chg: |
|
452 | if options.chg: | |
453 | pathandattrs.append((b'contrib/chg/chg', 'with_chg')) |
|
453 | pathandattrs.append((b'contrib/chg/chg', 'with_chg')) | |
454 | for relpath, attr in pathandattrs: |
|
454 | for relpath, attr in pathandattrs: | |
455 | binpath = os.path.join(reporootdir, relpath) |
|
455 | binpath = os.path.join(reporootdir, relpath) | |
456 | if os.name != 'nt' and not os.access(binpath, os.X_OK): |
|
456 | if os.name != 'nt' and not os.access(binpath, os.X_OK): | |
457 | parser.error('--local specified, but %r not found or ' |
|
457 | parser.error('--local specified, but %r not found or ' | |
458 | 'not executable' % binpath) |
|
458 | 'not executable' % binpath) | |
459 | setattr(options, attr, binpath) |
|
459 | setattr(options, attr, binpath) | |
460 |
|
460 | |||
461 | if (options.chg or options.with_chg) and os.name == 'nt': |
|
461 | if (options.chg or options.with_chg) and os.name == 'nt': | |
462 | parser.error('chg does not work on %s' % os.name) |
|
462 | parser.error('chg does not work on %s' % os.name) | |
463 | if options.with_chg: |
|
463 | if options.with_chg: | |
464 | options.chg = False # no installation to temporary location |
|
464 | options.chg = False # no installation to temporary location | |
465 | options.with_chg = canonpath(_bytespath(options.with_chg)) |
|
465 | options.with_chg = canonpath(_bytespath(options.with_chg)) | |
466 | if not (os.path.isfile(options.with_chg) and |
|
466 | if not (os.path.isfile(options.with_chg) and | |
467 | os.access(options.with_chg, os.X_OK)): |
|
467 | os.access(options.with_chg, os.X_OK)): | |
468 | parser.error('--with-chg must specify a chg executable') |
|
468 | parser.error('--with-chg must specify a chg executable') | |
469 | if options.chg and options.with_hg: |
|
469 | if options.chg and options.with_hg: | |
470 | # chg shares installation location with hg |
|
470 | # chg shares installation location with hg | |
471 | parser.error('--chg does not work when --with-hg is specified ' |
|
471 | parser.error('--chg does not work when --with-hg is specified ' | |
472 | '(use --with-chg instead)') |
|
472 | '(use --with-chg instead)') | |
473 |
|
473 | |||
474 | if options.color == 'always' and not pygmentspresent: |
|
474 | if options.color == 'always' and not pygmentspresent: | |
475 | sys.stderr.write('warning: --color=always ignored because ' |
|
475 | sys.stderr.write('warning: --color=always ignored because ' | |
476 | 'pygments is not installed\n') |
|
476 | 'pygments is not installed\n') | |
477 |
|
477 | |||
478 | if options.bisect_repo and not options.known_good_rev: |
|
478 | if options.bisect_repo and not options.known_good_rev: | |
479 | parser.error("--bisect-repo cannot be used without --known-good-rev") |
|
479 | parser.error("--bisect-repo cannot be used without --known-good-rev") | |
480 |
|
480 | |||
481 | global useipv6 |
|
481 | global useipv6 | |
482 | if options.ipv6: |
|
482 | if options.ipv6: | |
483 | useipv6 = checksocketfamily('AF_INET6') |
|
483 | useipv6 = checksocketfamily('AF_INET6') | |
484 | else: |
|
484 | else: | |
485 | # only use IPv6 if IPv4 is unavailable and IPv6 is available |
|
485 | # only use IPv6 if IPv4 is unavailable and IPv6 is available | |
486 | useipv6 = ((not checksocketfamily('AF_INET')) |
|
486 | useipv6 = ((not checksocketfamily('AF_INET')) | |
487 | and checksocketfamily('AF_INET6')) |
|
487 | and checksocketfamily('AF_INET6')) | |
488 |
|
488 | |||
489 | options.anycoverage = options.cover or options.annotate or options.htmlcov |
|
489 | options.anycoverage = options.cover or options.annotate or options.htmlcov | |
490 | if options.anycoverage: |
|
490 | if options.anycoverage: | |
491 | try: |
|
491 | try: | |
492 | import coverage |
|
492 | import coverage | |
493 | covver = version.StrictVersion(coverage.__version__).version |
|
493 | covver = version.StrictVersion(coverage.__version__).version | |
494 | if covver < (3, 3): |
|
494 | if covver < (3, 3): | |
495 | parser.error('coverage options require coverage 3.3 or later') |
|
495 | parser.error('coverage options require coverage 3.3 or later') | |
496 | except ImportError: |
|
496 | except ImportError: | |
497 | parser.error('coverage options now require the coverage package') |
|
497 | parser.error('coverage options now require the coverage package') | |
498 |
|
498 | |||
499 | if options.anycoverage and options.local: |
|
499 | if options.anycoverage and options.local: | |
500 | # this needs some path mangling somewhere, I guess |
|
500 | # this needs some path mangling somewhere, I guess | |
501 | parser.error("sorry, coverage options do not work when --local " |
|
501 | parser.error("sorry, coverage options do not work when --local " | |
502 | "is specified") |
|
502 | "is specified") | |
503 |
|
503 | |||
504 | if options.anycoverage and options.with_hg: |
|
504 | if options.anycoverage and options.with_hg: | |
505 | parser.error("sorry, coverage options do not work when --with-hg " |
|
505 | parser.error("sorry, coverage options do not work when --with-hg " | |
506 | "is specified") |
|
506 | "is specified") | |
507 |
|
507 | |||
508 | global verbose |
|
508 | global verbose | |
509 | if options.verbose: |
|
509 | if options.verbose: | |
510 | verbose = '' |
|
510 | verbose = '' | |
511 |
|
511 | |||
512 | if options.tmpdir: |
|
512 | if options.tmpdir: | |
513 | options.tmpdir = canonpath(options.tmpdir) |
|
513 | options.tmpdir = canonpath(options.tmpdir) | |
514 |
|
514 | |||
515 | if options.jobs < 1: |
|
515 | if options.jobs < 1: | |
516 | parser.error('--jobs must be positive') |
|
516 | parser.error('--jobs must be positive') | |
517 | if options.interactive and options.debug: |
|
517 | if options.interactive and options.debug: | |
518 | parser.error("-i/--interactive and -d/--debug are incompatible") |
|
518 | parser.error("-i/--interactive and -d/--debug are incompatible") | |
519 | if options.debug: |
|
519 | if options.debug: | |
520 | if options.timeout != defaults['timeout']: |
|
520 | if options.timeout != defaults['timeout']: | |
521 | sys.stderr.write( |
|
521 | sys.stderr.write( | |
522 | 'warning: --timeout option ignored with --debug\n') |
|
522 | 'warning: --timeout option ignored with --debug\n') | |
523 | if options.slowtimeout != defaults['slowtimeout']: |
|
523 | if options.slowtimeout != defaults['slowtimeout']: | |
524 | sys.stderr.write( |
|
524 | sys.stderr.write( | |
525 | 'warning: --slowtimeout option ignored with --debug\n') |
|
525 | 'warning: --slowtimeout option ignored with --debug\n') | |
526 | options.timeout = 0 |
|
526 | options.timeout = 0 | |
527 | options.slowtimeout = 0 |
|
527 | options.slowtimeout = 0 | |
528 | if options.py3k_warnings: |
|
528 | if options.py3k_warnings: | |
529 | if PYTHON3: |
|
529 | if PYTHON3: | |
530 | parser.error( |
|
530 | parser.error( | |
531 | '--py3k-warnings can only be used on Python 2.7') |
|
531 | '--py3k-warnings can only be used on Python 2.7') | |
532 | if options.with_python3: |
|
532 | if options.with_python3: | |
533 | if PYTHON3: |
|
533 | if PYTHON3: | |
534 | parser.error('--with-python3 cannot be used when executing with ' |
|
534 | parser.error('--with-python3 cannot be used when executing with ' | |
535 | 'Python 3') |
|
535 | 'Python 3') | |
536 |
|
536 | |||
537 | options.with_python3 = canonpath(options.with_python3) |
|
537 | options.with_python3 = canonpath(options.with_python3) | |
538 | # Verify Python3 executable is acceptable. |
|
538 | # Verify Python3 executable is acceptable. | |
539 | proc = subprocess.Popen([options.with_python3, b'--version'], |
|
539 | proc = subprocess.Popen([options.with_python3, b'--version'], | |
540 | stdout=subprocess.PIPE, |
|
540 | stdout=subprocess.PIPE, | |
541 | stderr=subprocess.STDOUT) |
|
541 | stderr=subprocess.STDOUT) | |
542 | out, _err = proc.communicate() |
|
542 | out, _err = proc.communicate() | |
543 | ret = proc.wait() |
|
543 | ret = proc.wait() | |
544 | if ret != 0: |
|
544 | if ret != 0: | |
545 | parser.error('could not determine version of python 3') |
|
545 | parser.error('could not determine version of python 3') | |
546 | if not out.startswith('Python '): |
|
546 | if not out.startswith('Python '): | |
547 | parser.error('unexpected output from python3 --version: %s' % |
|
547 | parser.error('unexpected output from python3 --version: %s' % | |
548 | out) |
|
548 | out) | |
549 | vers = version.LooseVersion(out[len('Python '):]) |
|
549 | vers = version.LooseVersion(out[len('Python '):]) | |
550 | if vers < version.LooseVersion('3.5.0'): |
|
550 | if vers < version.LooseVersion('3.5.0'): | |
551 | parser.error('--with-python3 version must be 3.5.0 or greater; ' |
|
551 | parser.error('--with-python3 version must be 3.5.0 or greater; ' | |
552 | 'got %s' % out) |
|
552 | 'got %s' % out) | |
553 |
|
553 | |||
554 | if options.blacklist: |
|
554 | if options.blacklist: | |
555 | options.blacklist = parselistfiles(options.blacklist, 'blacklist') |
|
555 | options.blacklist = parselistfiles(options.blacklist, 'blacklist') | |
556 | if options.whitelist: |
|
556 | if options.whitelist: | |
557 | options.whitelisted = parselistfiles(options.whitelist, 'whitelist') |
|
557 | options.whitelisted = parselistfiles(options.whitelist, 'whitelist') | |
558 | else: |
|
558 | else: | |
559 | options.whitelisted = {} |
|
559 | options.whitelisted = {} | |
560 |
|
560 | |||
561 | if options.showchannels: |
|
561 | if options.showchannels: | |
562 | options.nodiff = True |
|
562 | options.nodiff = True | |
563 |
|
563 | |||
564 | return options |
|
564 | return options | |
565 |
|
565 | |||
566 | def rename(src, dst): |
|
566 | def rename(src, dst): | |
567 | """Like os.rename(), trade atomicity and opened files friendliness |
|
567 | """Like os.rename(), trade atomicity and opened files friendliness | |
568 | for existing destination support. |
|
568 | for existing destination support. | |
569 | """ |
|
569 | """ | |
570 | shutil.copy(src, dst) |
|
570 | shutil.copy(src, dst) | |
571 | os.remove(src) |
|
571 | os.remove(src) | |
572 |
|
572 | |||
573 | _unified_diff = difflib.unified_diff |
|
573 | _unified_diff = difflib.unified_diff | |
574 | if PYTHON3: |
|
574 | if PYTHON3: | |
575 | import functools |
|
575 | import functools | |
576 | _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) |
|
576 | _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) | |
577 |
|
577 | |||
578 | def getdiff(expected, output, ref, err): |
|
578 | def getdiff(expected, output, ref, err): | |
579 | servefail = False |
|
579 | servefail = False | |
580 | lines = [] |
|
580 | lines = [] | |
581 | for line in _unified_diff(expected, output, ref, err): |
|
581 | for line in _unified_diff(expected, output, ref, err): | |
582 | if line.startswith(b'+++') or line.startswith(b'---'): |
|
582 | if line.startswith(b'+++') or line.startswith(b'---'): | |
583 | line = line.replace(b'\\', b'/') |
|
583 | line = line.replace(b'\\', b'/') | |
584 | if line.endswith(b' \n'): |
|
584 | if line.endswith(b' \n'): | |
585 | line = line[:-2] + b'\n' |
|
585 | line = line[:-2] + b'\n' | |
586 | lines.append(line) |
|
586 | lines.append(line) | |
587 | if not servefail and line.startswith( |
|
587 | if not servefail and line.startswith( | |
588 | b'+ abort: child process failed to start'): |
|
588 | b'+ abort: child process failed to start'): | |
589 | servefail = True |
|
589 | servefail = True | |
590 |
|
590 | |||
591 | return servefail, lines |
|
591 | return servefail, lines | |
592 |
|
592 | |||
593 | verbose = False |
|
593 | verbose = False | |
594 | def vlog(*msg): |
|
594 | def vlog(*msg): | |
595 | """Log only when in verbose mode.""" |
|
595 | """Log only when in verbose mode.""" | |
596 | if verbose is False: |
|
596 | if verbose is False: | |
597 | return |
|
597 | return | |
598 |
|
598 | |||
599 | return log(*msg) |
|
599 | return log(*msg) | |
600 |
|
600 | |||
601 | # Bytes that break XML even in a CDATA block: control characters 0-31 |
|
601 | # Bytes that break XML even in a CDATA block: control characters 0-31 | |
602 | # sans \t, \n and \r |
|
602 | # sans \t, \n and \r | |
603 | CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]") |
|
603 | CDATA_EVIL = re.compile(br"[\000-\010\013\014\016-\037]") | |
604 |
|
604 | |||
605 | # Match feature conditionalized output lines in the form, capturing the feature |
|
605 | # Match feature conditionalized output lines in the form, capturing the feature | |
606 | # list in group 2, and the preceeding line output in group 1: |
|
606 | # list in group 2, and the preceeding line output in group 1: | |
607 | # |
|
607 | # | |
608 | # output..output (feature !)\n |
|
608 | # output..output (feature !)\n | |
609 | optline = re.compile(b'(.*) \((.+?) !\)\n$') |
|
609 | optline = re.compile(b'(.*) \((.+?) !\)\n$') | |
610 |
|
610 | |||
611 | def cdatasafe(data): |
|
611 | def cdatasafe(data): | |
612 | """Make a string safe to include in a CDATA block. |
|
612 | """Make a string safe to include in a CDATA block. | |
613 |
|
613 | |||
614 | Certain control characters are illegal in a CDATA block, and |
|
614 | Certain control characters are illegal in a CDATA block, and | |
615 | there's no way to include a ]]> in a CDATA either. This function |
|
615 | there's no way to include a ]]> in a CDATA either. This function | |
616 | replaces illegal bytes with ? and adds a space between the ]] so |
|
616 | replaces illegal bytes with ? and adds a space between the ]] so | |
617 | that it won't break the CDATA block. |
|
617 | that it won't break the CDATA block. | |
618 | """ |
|
618 | """ | |
619 | return CDATA_EVIL.sub(b'?', data).replace(b']]>', b'] ]>') |
|
619 | return CDATA_EVIL.sub(b'?', data).replace(b']]>', b'] ]>') | |
620 |
|
620 | |||
621 | def log(*msg): |
|
621 | def log(*msg): | |
622 | """Log something to stdout. |
|
622 | """Log something to stdout. | |
623 |
|
623 | |||
624 | Arguments are strings to print. |
|
624 | Arguments are strings to print. | |
625 | """ |
|
625 | """ | |
626 | with iolock: |
|
626 | with iolock: | |
627 | if verbose: |
|
627 | if verbose: | |
628 | print(verbose, end=' ') |
|
628 | print(verbose, end=' ') | |
629 | for m in msg: |
|
629 | for m in msg: | |
630 | print(m, end=' ') |
|
630 | print(m, end=' ') | |
631 | print() |
|
631 | print() | |
632 | sys.stdout.flush() |
|
632 | sys.stdout.flush() | |
633 |
|
633 | |||
634 | def highlightdiff(line, color): |
|
634 | def highlightdiff(line, color): | |
635 | if not color: |
|
635 | if not color: | |
636 | return line |
|
636 | return line | |
637 | assert pygmentspresent |
|
637 | assert pygmentspresent | |
638 | return pygments.highlight(line.decode('latin1'), difflexer, |
|
638 | return pygments.highlight(line.decode('latin1'), difflexer, | |
639 | terminal256formatter).encode('latin1') |
|
639 | terminal256formatter).encode('latin1') | |
640 |
|
640 | |||
641 | def highlightmsg(msg, color): |
|
641 | def highlightmsg(msg, color): | |
642 | if not color: |
|
642 | if not color: | |
643 | return msg |
|
643 | return msg | |
644 | assert pygmentspresent |
|
644 | assert pygmentspresent | |
645 | return pygments.highlight(msg, runnerlexer, runnerformatter) |
|
645 | return pygments.highlight(msg, runnerlexer, runnerformatter) | |
646 |
|
646 | |||
647 | def terminate(proc): |
|
647 | def terminate(proc): | |
648 | """Terminate subprocess""" |
|
648 | """Terminate subprocess""" | |
649 | vlog('# Terminating process %d' % proc.pid) |
|
649 | vlog('# Terminating process %d' % proc.pid) | |
650 | try: |
|
650 | try: | |
651 | proc.terminate() |
|
651 | proc.terminate() | |
652 | except OSError: |
|
652 | except OSError: | |
653 | pass |
|
653 | pass | |
654 |
|
654 | |||
655 | def killdaemons(pidfile): |
|
655 | def killdaemons(pidfile): | |
656 | import killdaemons as killmod |
|
656 | import killdaemons as killmod | |
657 | return killmod.killdaemons(pidfile, tryhard=False, remove=True, |
|
657 | return killmod.killdaemons(pidfile, tryhard=False, remove=True, | |
658 | logfn=vlog) |
|
658 | logfn=vlog) | |
659 |
|
659 | |||
660 | class Test(unittest.TestCase): |
|
660 | class Test(unittest.TestCase): | |
661 | """Encapsulates a single, runnable test. |
|
661 | """Encapsulates a single, runnable test. | |
662 |
|
662 | |||
663 | While this class conforms to the unittest.TestCase API, it differs in that |
|
663 | While this class conforms to the unittest.TestCase API, it differs in that | |
664 | instances need to be instantiated manually. (Typically, unittest.TestCase |
|
664 | instances need to be instantiated manually. (Typically, unittest.TestCase | |
665 | classes are instantiated automatically by scanning modules.) |
|
665 | classes are instantiated automatically by scanning modules.) | |
666 | """ |
|
666 | """ | |
667 |
|
667 | |||
668 | # Status code reserved for skipped tests (used by hghave). |
|
668 | # Status code reserved for skipped tests (used by hghave). | |
669 | SKIPPED_STATUS = 80 |
|
669 | SKIPPED_STATUS = 80 | |
670 |
|
670 | |||
671 | def __init__(self, path, outputdir, tmpdir, keeptmpdir=False, |
|
671 | def __init__(self, path, outputdir, tmpdir, keeptmpdir=False, | |
672 | debug=False, |
|
672 | debug=False, | |
673 | timeout=None, |
|
673 | timeout=None, | |
674 | startport=None, extraconfigopts=None, |
|
674 | startport=None, extraconfigopts=None, | |
675 | py3kwarnings=False, shell=None, hgcommand=None, |
|
675 | py3kwarnings=False, shell=None, hgcommand=None, | |
676 | slowtimeout=None, usechg=False, |
|
676 | slowtimeout=None, usechg=False, | |
677 | useipv6=False): |
|
677 | useipv6=False): | |
678 | """Create a test from parameters. |
|
678 | """Create a test from parameters. | |
679 |
|
679 | |||
680 | path is the full path to the file defining the test. |
|
680 | path is the full path to the file defining the test. | |
681 |
|
681 | |||
682 | tmpdir is the main temporary directory to use for this test. |
|
682 | tmpdir is the main temporary directory to use for this test. | |
683 |
|
683 | |||
684 | keeptmpdir determines whether to keep the test's temporary directory |
|
684 | keeptmpdir determines whether to keep the test's temporary directory | |
685 | after execution. It defaults to removal (False). |
|
685 | after execution. It defaults to removal (False). | |
686 |
|
686 | |||
687 | debug mode will make the test execute verbosely, with unfiltered |
|
687 | debug mode will make the test execute verbosely, with unfiltered | |
688 | output. |
|
688 | output. | |
689 |
|
689 | |||
690 | timeout controls the maximum run time of the test. It is ignored when |
|
690 | timeout controls the maximum run time of the test. It is ignored when | |
691 | debug is True. See slowtimeout for tests with #require slow. |
|
691 | debug is True. See slowtimeout for tests with #require slow. | |
692 |
|
692 | |||
693 | slowtimeout overrides timeout if the test has #require slow. |
|
693 | slowtimeout overrides timeout if the test has #require slow. | |
694 |
|
694 | |||
695 | startport controls the starting port number to use for this test. Each |
|
695 | startport controls the starting port number to use for this test. Each | |
696 | test will reserve 3 port numbers for execution. It is the caller's |
|
696 | test will reserve 3 port numbers for execution. It is the caller's | |
697 | responsibility to allocate a non-overlapping port range to Test |
|
697 | responsibility to allocate a non-overlapping port range to Test | |
698 | instances. |
|
698 | instances. | |
699 |
|
699 | |||
700 | extraconfigopts is an iterable of extra hgrc config options. Values |
|
700 | extraconfigopts is an iterable of extra hgrc config options. Values | |
701 | must have the form "key=value" (something understood by hgrc). Values |
|
701 | must have the form "key=value" (something understood by hgrc). Values | |
702 | of the form "foo.key=value" will result in "[foo] key=value". |
|
702 | of the form "foo.key=value" will result in "[foo] key=value". | |
703 |
|
703 | |||
704 | py3kwarnings enables Py3k warnings. |
|
704 | py3kwarnings enables Py3k warnings. | |
705 |
|
705 | |||
706 | shell is the shell to execute tests in. |
|
706 | shell is the shell to execute tests in. | |
707 | """ |
|
707 | """ | |
708 | if timeout is None: |
|
708 | if timeout is None: | |
709 | timeout = defaults['timeout'] |
|
709 | timeout = defaults['timeout'] | |
710 | if startport is None: |
|
710 | if startport is None: | |
711 | startport = defaults['port'] |
|
711 | startport = defaults['port'] | |
712 | if slowtimeout is None: |
|
712 | if slowtimeout is None: | |
713 | slowtimeout = defaults['slowtimeout'] |
|
713 | slowtimeout = defaults['slowtimeout'] | |
714 | self.path = path |
|
714 | self.path = path | |
715 | self.bname = os.path.basename(path) |
|
715 | self.bname = os.path.basename(path) | |
716 | self.name = _strpath(self.bname) |
|
716 | self.name = _strpath(self.bname) | |
717 | self._testdir = os.path.dirname(path) |
|
717 | self._testdir = os.path.dirname(path) | |
718 | self._outputdir = outputdir |
|
718 | self._outputdir = outputdir | |
719 | self._tmpname = os.path.basename(path) |
|
719 | self._tmpname = os.path.basename(path) | |
720 | self.errpath = os.path.join(self._outputdir, b'%s.err' % self.bname) |
|
720 | self.errpath = os.path.join(self._outputdir, b'%s.err' % self.bname) | |
721 |
|
721 | |||
722 | self._threadtmp = tmpdir |
|
722 | self._threadtmp = tmpdir | |
723 | self._keeptmpdir = keeptmpdir |
|
723 | self._keeptmpdir = keeptmpdir | |
724 | self._debug = debug |
|
724 | self._debug = debug | |
725 | self._timeout = timeout |
|
725 | self._timeout = timeout | |
726 | self._slowtimeout = slowtimeout |
|
726 | self._slowtimeout = slowtimeout | |
727 | self._startport = startport |
|
727 | self._startport = startport | |
728 | self._extraconfigopts = extraconfigopts or [] |
|
728 | self._extraconfigopts = extraconfigopts or [] | |
729 | self._py3kwarnings = py3kwarnings |
|
729 | self._py3kwarnings = py3kwarnings | |
730 | self._shell = _bytespath(shell) |
|
730 | self._shell = _bytespath(shell) | |
731 | self._hgcommand = hgcommand or b'hg' |
|
731 | self._hgcommand = hgcommand or b'hg' | |
732 | self._usechg = usechg |
|
732 | self._usechg = usechg | |
733 | self._useipv6 = useipv6 |
|
733 | self._useipv6 = useipv6 | |
734 |
|
734 | |||
735 | self._aborted = False |
|
735 | self._aborted = False | |
736 | self._daemonpids = [] |
|
736 | self._daemonpids = [] | |
737 | self._finished = None |
|
737 | self._finished = None | |
738 | self._ret = None |
|
738 | self._ret = None | |
739 | self._out = None |
|
739 | self._out = None | |
740 | self._skipped = None |
|
740 | self._skipped = None | |
741 | self._testtmp = None |
|
741 | self._testtmp = None | |
742 | self._chgsockdir = None |
|
742 | self._chgsockdir = None | |
743 |
|
743 | |||
744 | self._refout = self.readrefout() |
|
744 | self._refout = self.readrefout() | |
745 |
|
745 | |||
746 | def readrefout(self): |
|
746 | def readrefout(self): | |
747 | """read reference output""" |
|
747 | """read reference output""" | |
748 | # If we're not in --debug mode and reference output file exists, |
|
748 | # If we're not in --debug mode and reference output file exists, | |
749 | # check test output against it. |
|
749 | # check test output against it. | |
750 | if self._debug: |
|
750 | if self._debug: | |
751 | return None # to match "out is None" |
|
751 | return None # to match "out is None" | |
752 | elif os.path.exists(self.refpath): |
|
752 | elif os.path.exists(self.refpath): | |
753 | with open(self.refpath, 'rb') as f: |
|
753 | with open(self.refpath, 'rb') as f: | |
754 | return f.read().splitlines(True) |
|
754 | return f.read().splitlines(True) | |
755 | else: |
|
755 | else: | |
756 | return [] |
|
756 | return [] | |
757 |
|
757 | |||
758 | # needed to get base class __repr__ running |
|
758 | # needed to get base class __repr__ running | |
759 | @property |
|
759 | @property | |
760 | def _testMethodName(self): |
|
760 | def _testMethodName(self): | |
761 | return self.name |
|
761 | return self.name | |
762 |
|
762 | |||
763 | def __str__(self): |
|
763 | def __str__(self): | |
764 | return self.name |
|
764 | return self.name | |
765 |
|
765 | |||
766 | def shortDescription(self): |
|
766 | def shortDescription(self): | |
767 | return self.name |
|
767 | return self.name | |
768 |
|
768 | |||
769 | def setUp(self): |
|
769 | def setUp(self): | |
770 | """Tasks to perform before run().""" |
|
770 | """Tasks to perform before run().""" | |
771 | self._finished = False |
|
771 | self._finished = False | |
772 | self._ret = None |
|
772 | self._ret = None | |
773 | self._out = None |
|
773 | self._out = None | |
774 | self._skipped = None |
|
774 | self._skipped = None | |
775 |
|
775 | |||
776 | try: |
|
776 | try: | |
777 | os.mkdir(self._threadtmp) |
|
777 | os.mkdir(self._threadtmp) | |
778 | except OSError as e: |
|
778 | except OSError as e: | |
779 | if e.errno != errno.EEXIST: |
|
779 | if e.errno != errno.EEXIST: | |
780 | raise |
|
780 | raise | |
781 |
|
781 | |||
782 | name = self._tmpname |
|
782 | name = self._tmpname | |
783 | self._testtmp = os.path.join(self._threadtmp, name) |
|
783 | self._testtmp = os.path.join(self._threadtmp, name) | |
784 | os.mkdir(self._testtmp) |
|
784 | os.mkdir(self._testtmp) | |
785 |
|
785 | |||
786 | # Remove any previous output files. |
|
786 | # Remove any previous output files. | |
787 | if os.path.exists(self.errpath): |
|
787 | if os.path.exists(self.errpath): | |
788 | try: |
|
788 | try: | |
789 | os.remove(self.errpath) |
|
789 | os.remove(self.errpath) | |
790 | except OSError as e: |
|
790 | except OSError as e: | |
791 | # We might have raced another test to clean up a .err |
|
791 | # We might have raced another test to clean up a .err | |
792 | # file, so ignore ENOENT when removing a previous .err |
|
792 | # file, so ignore ENOENT when removing a previous .err | |
793 | # file. |
|
793 | # file. | |
794 | if e.errno != errno.ENOENT: |
|
794 | if e.errno != errno.ENOENT: | |
795 | raise |
|
795 | raise | |
796 |
|
796 | |||
797 | if self._usechg: |
|
797 | if self._usechg: | |
798 | self._chgsockdir = os.path.join(self._threadtmp, |
|
798 | self._chgsockdir = os.path.join(self._threadtmp, | |
799 | b'%s.chgsock' % name) |
|
799 | b'%s.chgsock' % name) | |
800 | os.mkdir(self._chgsockdir) |
|
800 | os.mkdir(self._chgsockdir) | |
801 |
|
801 | |||
802 | def run(self, result): |
|
802 | def run(self, result): | |
803 | """Run this test and report results against a TestResult instance.""" |
|
803 | """Run this test and report results against a TestResult instance.""" | |
804 | # This function is extremely similar to unittest.TestCase.run(). Once |
|
804 | # This function is extremely similar to unittest.TestCase.run(). Once | |
805 | # we require Python 2.7 (or at least its version of unittest), this |
|
805 | # we require Python 2.7 (or at least its version of unittest), this | |
806 | # function can largely go away. |
|
806 | # function can largely go away. | |
807 | self._result = result |
|
807 | self._result = result | |
808 | result.startTest(self) |
|
808 | result.startTest(self) | |
809 | try: |
|
809 | try: | |
810 | try: |
|
810 | try: | |
811 | self.setUp() |
|
811 | self.setUp() | |
812 | except (KeyboardInterrupt, SystemExit): |
|
812 | except (KeyboardInterrupt, SystemExit): | |
813 | self._aborted = True |
|
813 | self._aborted = True | |
814 | raise |
|
814 | raise | |
815 | except Exception: |
|
815 | except Exception: | |
816 | result.addError(self, sys.exc_info()) |
|
816 | result.addError(self, sys.exc_info()) | |
817 | return |
|
817 | return | |
818 |
|
818 | |||
819 | success = False |
|
819 | success = False | |
820 | try: |
|
820 | try: | |
821 | self.runTest() |
|
821 | self.runTest() | |
822 | except KeyboardInterrupt: |
|
822 | except KeyboardInterrupt: | |
823 | self._aborted = True |
|
823 | self._aborted = True | |
824 | raise |
|
824 | raise | |
825 | except unittest.SkipTest as e: |
|
825 | except unittest.SkipTest as e: | |
826 | result.addSkip(self, str(e)) |
|
826 | result.addSkip(self, str(e)) | |
827 | # The base class will have already counted this as a |
|
827 | # The base class will have already counted this as a | |
828 | # test we "ran", but we want to exclude skipped tests |
|
828 | # test we "ran", but we want to exclude skipped tests | |
829 | # from those we count towards those run. |
|
829 | # from those we count towards those run. | |
830 | result.testsRun -= 1 |
|
830 | result.testsRun -= 1 | |
831 | except self.failureException as e: |
|
831 | except self.failureException as e: | |
832 | # This differs from unittest in that we don't capture |
|
832 | # This differs from unittest in that we don't capture | |
833 | # the stack trace. This is for historical reasons and |
|
833 | # the stack trace. This is for historical reasons and | |
834 | # this decision could be revisited in the future, |
|
834 | # this decision could be revisited in the future, | |
835 | # especially for PythonTest instances. |
|
835 | # especially for PythonTest instances. | |
836 | if result.addFailure(self, str(e)): |
|
836 | if result.addFailure(self, str(e)): | |
837 | success = True |
|
837 | success = True | |
838 | except Exception: |
|
838 | except Exception: | |
839 | result.addError(self, sys.exc_info()) |
|
839 | result.addError(self, sys.exc_info()) | |
840 | else: |
|
840 | else: | |
841 | success = True |
|
841 | success = True | |
842 |
|
842 | |||
843 | try: |
|
843 | try: | |
844 | self.tearDown() |
|
844 | self.tearDown() | |
845 | except (KeyboardInterrupt, SystemExit): |
|
845 | except (KeyboardInterrupt, SystemExit): | |
846 | self._aborted = True |
|
846 | self._aborted = True | |
847 | raise |
|
847 | raise | |
848 | except Exception: |
|
848 | except Exception: | |
849 | result.addError(self, sys.exc_info()) |
|
849 | result.addError(self, sys.exc_info()) | |
850 | success = False |
|
850 | success = False | |
851 |
|
851 | |||
852 | if success: |
|
852 | if success: | |
853 | result.addSuccess(self) |
|
853 | result.addSuccess(self) | |
854 | finally: |
|
854 | finally: | |
855 | result.stopTest(self, interrupted=self._aborted) |
|
855 | result.stopTest(self, interrupted=self._aborted) | |
856 |
|
856 | |||
857 | def runTest(self): |
|
857 | def runTest(self): | |
858 | """Run this test instance. |
|
858 | """Run this test instance. | |
859 |
|
859 | |||
860 | This will return a tuple describing the result of the test. |
|
860 | This will return a tuple describing the result of the test. | |
861 | """ |
|
861 | """ | |
862 | env = self._getenv() |
|
862 | env = self._getenv() | |
863 | self._genrestoreenv(env) |
|
863 | self._genrestoreenv(env) | |
864 | self._daemonpids.append(env['DAEMON_PIDS']) |
|
864 | self._daemonpids.append(env['DAEMON_PIDS']) | |
865 | self._createhgrc(env['HGRCPATH']) |
|
865 | self._createhgrc(env['HGRCPATH']) | |
866 |
|
866 | |||
867 | vlog('# Test', self.name) |
|
867 | vlog('# Test', self.name) | |
868 |
|
868 | |||
869 | ret, out = self._run(env) |
|
869 | ret, out = self._run(env) | |
870 | self._finished = True |
|
870 | self._finished = True | |
871 | self._ret = ret |
|
871 | self._ret = ret | |
872 | self._out = out |
|
872 | self._out = out | |
873 |
|
873 | |||
874 | def describe(ret): |
|
874 | def describe(ret): | |
875 | if ret < 0: |
|
875 | if ret < 0: | |
876 | return 'killed by signal: %d' % -ret |
|
876 | return 'killed by signal: %d' % -ret | |
877 | return 'returned error code %d' % ret |
|
877 | return 'returned error code %d' % ret | |
878 |
|
878 | |||
879 | self._skipped = False |
|
879 | self._skipped = False | |
880 |
|
880 | |||
881 | if ret == self.SKIPPED_STATUS: |
|
881 | if ret == self.SKIPPED_STATUS: | |
882 | if out is None: # Debug mode, nothing to parse. |
|
882 | if out is None: # Debug mode, nothing to parse. | |
883 | missing = ['unknown'] |
|
883 | missing = ['unknown'] | |
884 | failed = None |
|
884 | failed = None | |
885 | else: |
|
885 | else: | |
886 | missing, failed = TTest.parsehghaveoutput(out) |
|
886 | missing, failed = TTest.parsehghaveoutput(out) | |
887 |
|
887 | |||
888 | if not missing: |
|
888 | if not missing: | |
889 | missing = ['skipped'] |
|
889 | missing = ['skipped'] | |
890 |
|
890 | |||
891 | if failed: |
|
891 | if failed: | |
892 | self.fail('hg have failed checking for %s' % failed[-1]) |
|
892 | self.fail('hg have failed checking for %s' % failed[-1]) | |
893 | else: |
|
893 | else: | |
894 | self._skipped = True |
|
894 | self._skipped = True | |
895 | raise unittest.SkipTest(missing[-1]) |
|
895 | raise unittest.SkipTest(missing[-1]) | |
896 | elif ret == 'timeout': |
|
896 | elif ret == 'timeout': | |
897 | self.fail('timed out') |
|
897 | self.fail('timed out') | |
898 | elif ret is False: |
|
898 | elif ret is False: | |
899 | self.fail('no result code from test') |
|
899 | self.fail('no result code from test') | |
900 | elif out != self._refout: |
|
900 | elif out != self._refout: | |
901 | # Diff generation may rely on written .err file. |
|
901 | # Diff generation may rely on written .err file. | |
902 | if (ret != 0 or out != self._refout) and not self._skipped \ |
|
902 | if (ret != 0 or out != self._refout) and not self._skipped \ | |
903 | and not self._debug: |
|
903 | and not self._debug: | |
904 | f = open(self.errpath, 'wb') |
|
904 | f = open(self.errpath, 'wb') | |
905 | for line in out: |
|
905 | for line in out: | |
906 | f.write(line) |
|
906 | f.write(line) | |
907 | f.close() |
|
907 | f.close() | |
908 |
|
908 | |||
909 | # The result object handles diff calculation for us. |
|
909 | # The result object handles diff calculation for us. | |
910 | if self._result.addOutputMismatch(self, ret, out, self._refout): |
|
910 | if self._result.addOutputMismatch(self, ret, out, self._refout): | |
911 | # change was accepted, skip failing |
|
911 | # change was accepted, skip failing | |
912 | return |
|
912 | return | |
913 |
|
913 | |||
914 | if ret: |
|
914 | if ret: | |
915 | msg = 'output changed and ' + describe(ret) |
|
915 | msg = 'output changed and ' + describe(ret) | |
916 | else: |
|
916 | else: | |
917 | msg = 'output changed' |
|
917 | msg = 'output changed' | |
918 |
|
918 | |||
919 | self.fail(msg) |
|
919 | self.fail(msg) | |
920 | elif ret: |
|
920 | elif ret: | |
921 | self.fail(describe(ret)) |
|
921 | self.fail(describe(ret)) | |
922 |
|
922 | |||
923 | def tearDown(self): |
|
923 | def tearDown(self): | |
924 | """Tasks to perform after run().""" |
|
924 | """Tasks to perform after run().""" | |
925 | for entry in self._daemonpids: |
|
925 | for entry in self._daemonpids: | |
926 | killdaemons(entry) |
|
926 | killdaemons(entry) | |
927 | self._daemonpids = [] |
|
927 | self._daemonpids = [] | |
928 |
|
928 | |||
929 | if self._keeptmpdir: |
|
929 | if self._keeptmpdir: | |
930 | log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' % |
|
930 | log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' % | |
931 | (self._testtmp.decode('utf-8'), |
|
931 | (self._testtmp.decode('utf-8'), | |
932 | self._threadtmp.decode('utf-8'))) |
|
932 | self._threadtmp.decode('utf-8'))) | |
933 | else: |
|
933 | else: | |
934 | shutil.rmtree(self._testtmp, True) |
|
934 | shutil.rmtree(self._testtmp, True) | |
935 | shutil.rmtree(self._threadtmp, True) |
|
935 | shutil.rmtree(self._threadtmp, True) | |
936 |
|
936 | |||
937 | if self._usechg: |
|
937 | if self._usechg: | |
938 | # chgservers will stop automatically after they find the socket |
|
938 | # chgservers will stop automatically after they find the socket | |
939 | # files are deleted |
|
939 | # files are deleted | |
940 | shutil.rmtree(self._chgsockdir, True) |
|
940 | shutil.rmtree(self._chgsockdir, True) | |
941 |
|
941 | |||
942 | if (self._ret != 0 or self._out != self._refout) and not self._skipped \ |
|
942 | if (self._ret != 0 or self._out != self._refout) and not self._skipped \ | |
943 | and not self._debug and self._out: |
|
943 | and not self._debug and self._out: | |
944 | f = open(self.errpath, 'wb') |
|
944 | f = open(self.errpath, 'wb') | |
945 | for line in self._out: |
|
945 | for line in self._out: | |
946 | f.write(line) |
|
946 | f.write(line) | |
947 | f.close() |
|
947 | f.close() | |
948 |
|
948 | |||
949 | vlog("# Ret was:", self._ret, '(%s)' % self.name) |
|
949 | vlog("# Ret was:", self._ret, '(%s)' % self.name) | |
950 |
|
950 | |||
951 | def _run(self, env): |
|
951 | def _run(self, env): | |
952 | # This should be implemented in child classes to run tests. |
|
952 | # This should be implemented in child classes to run tests. | |
953 | raise unittest.SkipTest('unknown test type') |
|
953 | raise unittest.SkipTest('unknown test type') | |
954 |
|
954 | |||
955 | def abort(self): |
|
955 | def abort(self): | |
956 | """Terminate execution of this test.""" |
|
956 | """Terminate execution of this test.""" | |
957 | self._aborted = True |
|
957 | self._aborted = True | |
958 |
|
958 | |||
959 | def _portmap(self, i): |
|
959 | def _portmap(self, i): | |
960 | offset = b'' if i == 0 else b'%d' % i |
|
960 | offset = b'' if i == 0 else b'%d' % i | |
961 | return (br':%d\b' % (self._startport + i), b':$HGPORT%s' % offset) |
|
961 | return (br':%d\b' % (self._startport + i), b':$HGPORT%s' % offset) | |
962 |
|
962 | |||
963 | def _getreplacements(self): |
|
963 | def _getreplacements(self): | |
964 | """Obtain a mapping of text replacements to apply to test output. |
|
964 | """Obtain a mapping of text replacements to apply to test output. | |
965 |
|
965 | |||
966 | Test output needs to be normalized so it can be compared to expected |
|
966 | Test output needs to be normalized so it can be compared to expected | |
967 | output. This function defines how some of that normalization will |
|
967 | output. This function defines how some of that normalization will | |
968 | occur. |
|
968 | occur. | |
969 | """ |
|
969 | """ | |
970 | r = [ |
|
970 | r = [ | |
971 | # This list should be parallel to defineport in _getenv |
|
971 | # This list should be parallel to defineport in _getenv | |
972 | self._portmap(0), |
|
972 | self._portmap(0), | |
973 | self._portmap(1), |
|
973 | self._portmap(1), | |
974 | self._portmap(2), |
|
974 | self._portmap(2), | |
975 | (br'(?m)^(saved backup bundle to .*\.hg)( \(glob\))?$', |
|
975 | (br'(?m)^(saved backup bundle to .*\.hg)( \(glob\))?$', | |
976 |
br'\1 |
|
976 | br'\1'.replace(br'\\', br'/')), | |
977 | (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'), |
|
977 | (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'), | |
978 | (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'), |
|
978 | (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'), | |
979 | ] |
|
979 | ] | |
980 | r.append((self._escapepath(self._testtmp), b'$TESTTMP')) |
|
980 | r.append((self._escapepath(self._testtmp), b'$TESTTMP')) | |
981 |
|
981 | |||
982 | replacementfile = os.path.join(self._testdir, b'common-pattern.py') |
|
982 | replacementfile = os.path.join(self._testdir, b'common-pattern.py') | |
983 |
|
983 | |||
984 | if os.path.exists(replacementfile): |
|
984 | if os.path.exists(replacementfile): | |
985 | data = {} |
|
985 | data = {} | |
986 | with open(replacementfile, mode='rb') as source: |
|
986 | with open(replacementfile, mode='rb') as source: | |
987 | # the intermediate 'compile' step help with debugging |
|
987 | # the intermediate 'compile' step help with debugging | |
988 | code = compile(source.read(), replacementfile, 'exec') |
|
988 | code = compile(source.read(), replacementfile, 'exec') | |
989 | exec(code, data) |
|
989 | exec(code, data) | |
990 | r.extend(data.get('substitutions', ())) |
|
990 | r.extend(data.get('substitutions', ())) | |
991 | return r |
|
991 | return r | |
992 |
|
992 | |||
993 | def _escapepath(self, p): |
|
993 | def _escapepath(self, p): | |
994 | if os.name == 'nt': |
|
994 | if os.name == 'nt': | |
995 | return ( |
|
995 | return ( | |
996 | (b''.join(c.isalpha() and b'[%s%s]' % (c.lower(), c.upper()) or |
|
996 | (b''.join(c.isalpha() and b'[%s%s]' % (c.lower(), c.upper()) or | |
997 | c in b'/\\' and br'[/\\]' or c.isdigit() and c or b'\\' + c |
|
997 | c in b'/\\' and br'[/\\]' or c.isdigit() and c or b'\\' + c | |
998 | for c in p)) |
|
998 | for c in p)) | |
999 | ) |
|
999 | ) | |
1000 | else: |
|
1000 | else: | |
1001 | return re.escape(p) |
|
1001 | return re.escape(p) | |
1002 |
|
1002 | |||
1003 | def _localip(self): |
|
1003 | def _localip(self): | |
1004 | if self._useipv6: |
|
1004 | if self._useipv6: | |
1005 | return b'::1' |
|
1005 | return b'::1' | |
1006 | else: |
|
1006 | else: | |
1007 | return b'127.0.0.1' |
|
1007 | return b'127.0.0.1' | |
1008 |
|
1008 | |||
1009 | def _genrestoreenv(self, testenv): |
|
1009 | def _genrestoreenv(self, testenv): | |
1010 | """Generate a script that can be used by tests to restore the original |
|
1010 | """Generate a script that can be used by tests to restore the original | |
1011 | environment.""" |
|
1011 | environment.""" | |
1012 | # Put the restoreenv script inside self._threadtmp |
|
1012 | # Put the restoreenv script inside self._threadtmp | |
1013 | scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh') |
|
1013 | scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh') | |
1014 | testenv['HGTEST_RESTOREENV'] = scriptpath |
|
1014 | testenv['HGTEST_RESTOREENV'] = scriptpath | |
1015 |
|
1015 | |||
1016 | # Only restore environment variable names that the shell allows |
|
1016 | # Only restore environment variable names that the shell allows | |
1017 | # us to export. |
|
1017 | # us to export. | |
1018 | name_regex = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$') |
|
1018 | name_regex = re.compile('^[a-zA-Z][a-zA-Z0-9_]*$') | |
1019 |
|
1019 | |||
1020 | # Do not restore these variables; otherwise tests would fail. |
|
1020 | # Do not restore these variables; otherwise tests would fail. | |
1021 | reqnames = {'PYTHON', 'TESTDIR', 'TESTTMP'} |
|
1021 | reqnames = {'PYTHON', 'TESTDIR', 'TESTTMP'} | |
1022 |
|
1022 | |||
1023 | with open(scriptpath, 'w') as envf: |
|
1023 | with open(scriptpath, 'w') as envf: | |
1024 | for name, value in origenviron.items(): |
|
1024 | for name, value in origenviron.items(): | |
1025 | if not name_regex.match(name): |
|
1025 | if not name_regex.match(name): | |
1026 | # Skip environment variables with unusual names not |
|
1026 | # Skip environment variables with unusual names not | |
1027 | # allowed by most shells. |
|
1027 | # allowed by most shells. | |
1028 | continue |
|
1028 | continue | |
1029 | if name in reqnames: |
|
1029 | if name in reqnames: | |
1030 | continue |
|
1030 | continue | |
1031 | envf.write('%s=%s\n' % (name, shellquote(value))) |
|
1031 | envf.write('%s=%s\n' % (name, shellquote(value))) | |
1032 |
|
1032 | |||
1033 | for name in testenv: |
|
1033 | for name in testenv: | |
1034 | if name in origenviron or name in reqnames: |
|
1034 | if name in origenviron or name in reqnames: | |
1035 | continue |
|
1035 | continue | |
1036 | envf.write('unset %s\n' % (name,)) |
|
1036 | envf.write('unset %s\n' % (name,)) | |
1037 |
|
1037 | |||
1038 | def _getenv(self): |
|
1038 | def _getenv(self): | |
1039 | """Obtain environment variables to use during test execution.""" |
|
1039 | """Obtain environment variables to use during test execution.""" | |
1040 | def defineport(i): |
|
1040 | def defineport(i): | |
1041 | offset = '' if i == 0 else '%s' % i |
|
1041 | offset = '' if i == 0 else '%s' % i | |
1042 | env["HGPORT%s" % offset] = '%s' % (self._startport + i) |
|
1042 | env["HGPORT%s" % offset] = '%s' % (self._startport + i) | |
1043 | env = os.environ.copy() |
|
1043 | env = os.environ.copy() | |
1044 | env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') |
|
1044 | env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') | |
1045 | env['HGEMITWARNINGS'] = '1' |
|
1045 | env['HGEMITWARNINGS'] = '1' | |
1046 | env['TESTTMP'] = self._testtmp |
|
1046 | env['TESTTMP'] = self._testtmp | |
1047 | env['HOME'] = self._testtmp |
|
1047 | env['HOME'] = self._testtmp | |
1048 | # This number should match portneeded in _getport |
|
1048 | # This number should match portneeded in _getport | |
1049 | for port in xrange(3): |
|
1049 | for port in xrange(3): | |
1050 | # This list should be parallel to _portmap in _getreplacements |
|
1050 | # This list should be parallel to _portmap in _getreplacements | |
1051 | defineport(port) |
|
1051 | defineport(port) | |
1052 | env["HGRCPATH"] = os.path.join(self._threadtmp, b'.hgrc') |
|
1052 | env["HGRCPATH"] = os.path.join(self._threadtmp, b'.hgrc') | |
1053 | env["DAEMON_PIDS"] = os.path.join(self._threadtmp, b'daemon.pids') |
|
1053 | env["DAEMON_PIDS"] = os.path.join(self._threadtmp, b'daemon.pids') | |
1054 | env["HGEDITOR"] = ('"' + sys.executable + '"' |
|
1054 | env["HGEDITOR"] = ('"' + sys.executable + '"' | |
1055 | + ' -c "import sys; sys.exit(0)"') |
|
1055 | + ' -c "import sys; sys.exit(0)"') | |
1056 | env["HGMERGE"] = "internal:merge" |
|
1056 | env["HGMERGE"] = "internal:merge" | |
1057 | env["HGUSER"] = "test" |
|
1057 | env["HGUSER"] = "test" | |
1058 | env["HGENCODING"] = "ascii" |
|
1058 | env["HGENCODING"] = "ascii" | |
1059 | env["HGENCODINGMODE"] = "strict" |
|
1059 | env["HGENCODINGMODE"] = "strict" | |
1060 | env['HGIPV6'] = str(int(self._useipv6)) |
|
1060 | env['HGIPV6'] = str(int(self._useipv6)) | |
1061 |
|
1061 | |||
1062 | # LOCALIP could be ::1 or 127.0.0.1. Useful for tests that require raw |
|
1062 | # LOCALIP could be ::1 or 127.0.0.1. Useful for tests that require raw | |
1063 | # IP addresses. |
|
1063 | # IP addresses. | |
1064 | env['LOCALIP'] = self._localip() |
|
1064 | env['LOCALIP'] = self._localip() | |
1065 |
|
1065 | |||
1066 | # Reset some environment variables to well-known values so that |
|
1066 | # Reset some environment variables to well-known values so that | |
1067 | # the tests produce repeatable output. |
|
1067 | # the tests produce repeatable output. | |
1068 | env['LANG'] = env['LC_ALL'] = env['LANGUAGE'] = 'C' |
|
1068 | env['LANG'] = env['LC_ALL'] = env['LANGUAGE'] = 'C' | |
1069 | env['TZ'] = 'GMT' |
|
1069 | env['TZ'] = 'GMT' | |
1070 | env["EMAIL"] = "Foo Bar <foo.bar@example.com>" |
|
1070 | env["EMAIL"] = "Foo Bar <foo.bar@example.com>" | |
1071 | env['COLUMNS'] = '80' |
|
1071 | env['COLUMNS'] = '80' | |
1072 | env['TERM'] = 'xterm' |
|
1072 | env['TERM'] = 'xterm' | |
1073 |
|
1073 | |||
1074 | for k in ('HG HGPROF CDPATH GREP_OPTIONS http_proxy no_proxy ' + |
|
1074 | for k in ('HG HGPROF CDPATH GREP_OPTIONS http_proxy no_proxy ' + | |
1075 | 'HGPLAIN HGPLAINEXCEPT EDITOR VISUAL PAGER ' + |
|
1075 | 'HGPLAIN HGPLAINEXCEPT EDITOR VISUAL PAGER ' + | |
1076 | 'NO_PROXY CHGDEBUG').split(): |
|
1076 | 'NO_PROXY CHGDEBUG').split(): | |
1077 | if k in env: |
|
1077 | if k in env: | |
1078 | del env[k] |
|
1078 | del env[k] | |
1079 |
|
1079 | |||
1080 | # unset env related to hooks |
|
1080 | # unset env related to hooks | |
1081 | for k in env.keys(): |
|
1081 | for k in env.keys(): | |
1082 | if k.startswith('HG_'): |
|
1082 | if k.startswith('HG_'): | |
1083 | del env[k] |
|
1083 | del env[k] | |
1084 |
|
1084 | |||
1085 | if self._usechg: |
|
1085 | if self._usechg: | |
1086 | env['CHGSOCKNAME'] = os.path.join(self._chgsockdir, b'server') |
|
1086 | env['CHGSOCKNAME'] = os.path.join(self._chgsockdir, b'server') | |
1087 |
|
1087 | |||
1088 | return env |
|
1088 | return env | |
1089 |
|
1089 | |||
1090 | def _createhgrc(self, path): |
|
1090 | def _createhgrc(self, path): | |
1091 | """Create an hgrc file for this test.""" |
|
1091 | """Create an hgrc file for this test.""" | |
1092 | hgrc = open(path, 'wb') |
|
1092 | hgrc = open(path, 'wb') | |
1093 | hgrc.write(b'[ui]\n') |
|
1093 | hgrc.write(b'[ui]\n') | |
1094 | hgrc.write(b'slash = True\n') |
|
1094 | hgrc.write(b'slash = True\n') | |
1095 | hgrc.write(b'interactive = False\n') |
|
1095 | hgrc.write(b'interactive = False\n') | |
1096 | hgrc.write(b'mergemarkers = detailed\n') |
|
1096 | hgrc.write(b'mergemarkers = detailed\n') | |
1097 | hgrc.write(b'promptecho = True\n') |
|
1097 | hgrc.write(b'promptecho = True\n') | |
1098 | hgrc.write(b'[defaults]\n') |
|
1098 | hgrc.write(b'[defaults]\n') | |
1099 | hgrc.write(b'[devel]\n') |
|
1099 | hgrc.write(b'[devel]\n') | |
1100 | hgrc.write(b'all-warnings = true\n') |
|
1100 | hgrc.write(b'all-warnings = true\n') | |
1101 | hgrc.write(b'default-date = 0 0\n') |
|
1101 | hgrc.write(b'default-date = 0 0\n') | |
1102 | hgrc.write(b'[largefiles]\n') |
|
1102 | hgrc.write(b'[largefiles]\n') | |
1103 | hgrc.write(b'usercache = %s\n' % |
|
1103 | hgrc.write(b'usercache = %s\n' % | |
1104 | (os.path.join(self._testtmp, b'.cache/largefiles'))) |
|
1104 | (os.path.join(self._testtmp, b'.cache/largefiles'))) | |
1105 | hgrc.write(b'[lfs]\n') |
|
1105 | hgrc.write(b'[lfs]\n') | |
1106 | hgrc.write(b'usercache = %s\n' % |
|
1106 | hgrc.write(b'usercache = %s\n' % | |
1107 | (os.path.join(self._testtmp, b'.cache/lfs'))) |
|
1107 | (os.path.join(self._testtmp, b'.cache/lfs'))) | |
1108 | hgrc.write(b'[web]\n') |
|
1108 | hgrc.write(b'[web]\n') | |
1109 | hgrc.write(b'address = localhost\n') |
|
1109 | hgrc.write(b'address = localhost\n') | |
1110 | hgrc.write(b'ipv6 = %s\n' % str(self._useipv6).encode('ascii')) |
|
1110 | hgrc.write(b'ipv6 = %s\n' % str(self._useipv6).encode('ascii')) | |
1111 |
|
1111 | |||
1112 | for opt in self._extraconfigopts: |
|
1112 | for opt in self._extraconfigopts: | |
1113 | section, key = opt.encode('utf-8').split(b'.', 1) |
|
1113 | section, key = opt.encode('utf-8').split(b'.', 1) | |
1114 | assert b'=' in key, ('extra config opt %s must ' |
|
1114 | assert b'=' in key, ('extra config opt %s must ' | |
1115 | 'have an = for assignment' % opt) |
|
1115 | 'have an = for assignment' % opt) | |
1116 | hgrc.write(b'[%s]\n%s\n' % (section, key)) |
|
1116 | hgrc.write(b'[%s]\n%s\n' % (section, key)) | |
1117 | hgrc.close() |
|
1117 | hgrc.close() | |
1118 |
|
1118 | |||
1119 | def fail(self, msg): |
|
1119 | def fail(self, msg): | |
1120 | # unittest differentiates between errored and failed. |
|
1120 | # unittest differentiates between errored and failed. | |
1121 | # Failed is denoted by AssertionError (by default at least). |
|
1121 | # Failed is denoted by AssertionError (by default at least). | |
1122 | raise AssertionError(msg) |
|
1122 | raise AssertionError(msg) | |
1123 |
|
1123 | |||
1124 | def _runcommand(self, cmd, env, normalizenewlines=False): |
|
1124 | def _runcommand(self, cmd, env, normalizenewlines=False): | |
1125 | """Run command in a sub-process, capturing the output (stdout and |
|
1125 | """Run command in a sub-process, capturing the output (stdout and | |
1126 | stderr). |
|
1126 | stderr). | |
1127 |
|
1127 | |||
1128 | Return a tuple (exitcode, output). output is None in debug mode. |
|
1128 | Return a tuple (exitcode, output). output is None in debug mode. | |
1129 | """ |
|
1129 | """ | |
1130 | if self._debug: |
|
1130 | if self._debug: | |
1131 | proc = subprocess.Popen(cmd, shell=True, cwd=self._testtmp, |
|
1131 | proc = subprocess.Popen(cmd, shell=True, cwd=self._testtmp, | |
1132 | env=env) |
|
1132 | env=env) | |
1133 | ret = proc.wait() |
|
1133 | ret = proc.wait() | |
1134 | return (ret, None) |
|
1134 | return (ret, None) | |
1135 |
|
1135 | |||
1136 | proc = Popen4(cmd, self._testtmp, self._timeout, env) |
|
1136 | proc = Popen4(cmd, self._testtmp, self._timeout, env) | |
1137 | def cleanup(): |
|
1137 | def cleanup(): | |
1138 | terminate(proc) |
|
1138 | terminate(proc) | |
1139 | ret = proc.wait() |
|
1139 | ret = proc.wait() | |
1140 | if ret == 0: |
|
1140 | if ret == 0: | |
1141 | ret = signal.SIGTERM << 8 |
|
1141 | ret = signal.SIGTERM << 8 | |
1142 | killdaemons(env['DAEMON_PIDS']) |
|
1142 | killdaemons(env['DAEMON_PIDS']) | |
1143 | return ret |
|
1143 | return ret | |
1144 |
|
1144 | |||
1145 | output = '' |
|
1145 | output = '' | |
1146 | proc.tochild.close() |
|
1146 | proc.tochild.close() | |
1147 |
|
1147 | |||
1148 | try: |
|
1148 | try: | |
1149 | output = proc.fromchild.read() |
|
1149 | output = proc.fromchild.read() | |
1150 | except KeyboardInterrupt: |
|
1150 | except KeyboardInterrupt: | |
1151 | vlog('# Handling keyboard interrupt') |
|
1151 | vlog('# Handling keyboard interrupt') | |
1152 | cleanup() |
|
1152 | cleanup() | |
1153 | raise |
|
1153 | raise | |
1154 |
|
1154 | |||
1155 | ret = proc.wait() |
|
1155 | ret = proc.wait() | |
1156 | if wifexited(ret): |
|
1156 | if wifexited(ret): | |
1157 | ret = os.WEXITSTATUS(ret) |
|
1157 | ret = os.WEXITSTATUS(ret) | |
1158 |
|
1158 | |||
1159 | if proc.timeout: |
|
1159 | if proc.timeout: | |
1160 | ret = 'timeout' |
|
1160 | ret = 'timeout' | |
1161 |
|
1161 | |||
1162 | if ret: |
|
1162 | if ret: | |
1163 | killdaemons(env['DAEMON_PIDS']) |
|
1163 | killdaemons(env['DAEMON_PIDS']) | |
1164 |
|
1164 | |||
1165 | for s, r in self._getreplacements(): |
|
1165 | for s, r in self._getreplacements(): | |
1166 | output = re.sub(s, r, output) |
|
1166 | output = re.sub(s, r, output) | |
1167 |
|
1167 | |||
1168 | if normalizenewlines: |
|
1168 | if normalizenewlines: | |
1169 | output = output.replace('\r\n', '\n') |
|
1169 | output = output.replace('\r\n', '\n') | |
1170 |
|
1170 | |||
1171 | return ret, output.splitlines(True) |
|
1171 | return ret, output.splitlines(True) | |
1172 |
|
1172 | |||
1173 | class PythonTest(Test): |
|
1173 | class PythonTest(Test): | |
1174 | """A Python-based test.""" |
|
1174 | """A Python-based test.""" | |
1175 |
|
1175 | |||
1176 | @property |
|
1176 | @property | |
1177 | def refpath(self): |
|
1177 | def refpath(self): | |
1178 | return os.path.join(self._testdir, b'%s.out' % self.bname) |
|
1178 | return os.path.join(self._testdir, b'%s.out' % self.bname) | |
1179 |
|
1179 | |||
1180 | def _run(self, env): |
|
1180 | def _run(self, env): | |
1181 | py3kswitch = self._py3kwarnings and b' -3' or b'' |
|
1181 | py3kswitch = self._py3kwarnings and b' -3' or b'' | |
1182 | cmd = b'%s%s "%s"' % (PYTHON, py3kswitch, self.path) |
|
1182 | cmd = b'%s%s "%s"' % (PYTHON, py3kswitch, self.path) | |
1183 | vlog("# Running", cmd) |
|
1183 | vlog("# Running", cmd) | |
1184 | normalizenewlines = os.name == 'nt' |
|
1184 | normalizenewlines = os.name == 'nt' | |
1185 | result = self._runcommand(cmd, env, |
|
1185 | result = self._runcommand(cmd, env, | |
1186 | normalizenewlines=normalizenewlines) |
|
1186 | normalizenewlines=normalizenewlines) | |
1187 | if self._aborted: |
|
1187 | if self._aborted: | |
1188 | raise KeyboardInterrupt() |
|
1188 | raise KeyboardInterrupt() | |
1189 |
|
1189 | |||
1190 | return result |
|
1190 | return result | |
1191 |
|
1191 | |||
1192 | # Some glob patterns apply only in some circumstances, so the script |
|
1192 | # Some glob patterns apply only in some circumstances, so the script | |
1193 | # might want to remove (glob) annotations that otherwise should be |
|
1193 | # might want to remove (glob) annotations that otherwise should be | |
1194 | # retained. |
|
1194 | # retained. | |
1195 | checkcodeglobpats = [ |
|
1195 | checkcodeglobpats = [ | |
1196 | # On Windows it looks like \ doesn't require a (glob), but we know |
|
1196 | # On Windows it looks like \ doesn't require a (glob), but we know | |
1197 | # better. |
|
1197 | # better. | |
1198 | re.compile(br'^pushing to \$TESTTMP/.*[^)]$'), |
|
1198 | re.compile(br'^pushing to \$TESTTMP/.*[^)]$'), | |
1199 | re.compile(br'^moving \S+/.*[^)]$'), |
|
1199 | re.compile(br'^moving \S+/.*[^)]$'), | |
1200 | re.compile(br'^pulling from \$TESTTMP/.*[^)]$'), |
|
1200 | re.compile(br'^pulling from \$TESTTMP/.*[^)]$'), | |
1201 | # Not all platforms have 127.0.0.1 as loopback (though most do), |
|
1201 | # Not all platforms have 127.0.0.1 as loopback (though most do), | |
1202 | # so we always glob that too. |
|
1202 | # so we always glob that too. | |
1203 | re.compile(br'.*\$LOCALIP.*$'), |
|
1203 | re.compile(br'.*\$LOCALIP.*$'), | |
1204 | ] |
|
1204 | ] | |
1205 |
|
1205 | |||
1206 | bchr = chr |
|
1206 | bchr = chr | |
1207 | if PYTHON3: |
|
1207 | if PYTHON3: | |
1208 | bchr = lambda x: bytes([x]) |
|
1208 | bchr = lambda x: bytes([x]) | |
1209 |
|
1209 | |||
1210 | class TTest(Test): |
|
1210 | class TTest(Test): | |
1211 | """A "t test" is a test backed by a .t file.""" |
|
1211 | """A "t test" is a test backed by a .t file.""" | |
1212 |
|
1212 | |||
1213 | SKIPPED_PREFIX = b'skipped: ' |
|
1213 | SKIPPED_PREFIX = b'skipped: ' | |
1214 | FAILED_PREFIX = b'hghave check failed: ' |
|
1214 | FAILED_PREFIX = b'hghave check failed: ' | |
1215 | NEEDESCAPE = re.compile(br'[\x00-\x08\x0b-\x1f\x7f-\xff]').search |
|
1215 | NEEDESCAPE = re.compile(br'[\x00-\x08\x0b-\x1f\x7f-\xff]').search | |
1216 |
|
1216 | |||
1217 | ESCAPESUB = re.compile(br'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub |
|
1217 | ESCAPESUB = re.compile(br'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub | |
1218 | ESCAPEMAP = dict((bchr(i), br'\x%02x' % i) for i in range(256)) |
|
1218 | ESCAPEMAP = dict((bchr(i), br'\x%02x' % i) for i in range(256)) | |
1219 | ESCAPEMAP.update({b'\\': b'\\\\', b'\r': br'\r'}) |
|
1219 | ESCAPEMAP.update({b'\\': b'\\\\', b'\r': br'\r'}) | |
1220 |
|
1220 | |||
1221 | def __init__(self, path, *args, **kwds): |
|
1221 | def __init__(self, path, *args, **kwds): | |
1222 | # accept an extra "case" parameter |
|
1222 | # accept an extra "case" parameter | |
1223 | case = kwds.pop('case', None) |
|
1223 | case = kwds.pop('case', None) | |
1224 | self._case = case |
|
1224 | self._case = case | |
1225 | self._allcases = parsettestcases(path) |
|
1225 | self._allcases = parsettestcases(path) | |
1226 | super(TTest, self).__init__(path, *args, **kwds) |
|
1226 | super(TTest, self).__init__(path, *args, **kwds) | |
1227 | if case: |
|
1227 | if case: | |
1228 | self.name = '%s (case %s)' % (self.name, _strpath(case)) |
|
1228 | self.name = '%s (case %s)' % (self.name, _strpath(case)) | |
1229 | self.errpath = b'%s.%s.err' % (self.errpath[:-4], case) |
|
1229 | self.errpath = b'%s.%s.err' % (self.errpath[:-4], case) | |
1230 | self._tmpname += b'-%s' % case |
|
1230 | self._tmpname += b'-%s' % case | |
1231 |
|
1231 | |||
1232 | @property |
|
1232 | @property | |
1233 | def refpath(self): |
|
1233 | def refpath(self): | |
1234 | return os.path.join(self._testdir, self.bname) |
|
1234 | return os.path.join(self._testdir, self.bname) | |
1235 |
|
1235 | |||
1236 | def _run(self, env): |
|
1236 | def _run(self, env): | |
1237 | f = open(self.path, 'rb') |
|
1237 | f = open(self.path, 'rb') | |
1238 | lines = f.readlines() |
|
1238 | lines = f.readlines() | |
1239 | f.close() |
|
1239 | f.close() | |
1240 |
|
1240 | |||
1241 | # .t file is both reference output and the test input, keep reference |
|
1241 | # .t file is both reference output and the test input, keep reference | |
1242 | # output updated with the the test input. This avoids some race |
|
1242 | # output updated with the the test input. This avoids some race | |
1243 | # conditions where the reference output does not match the actual test. |
|
1243 | # conditions where the reference output does not match the actual test. | |
1244 | if self._refout is not None: |
|
1244 | if self._refout is not None: | |
1245 | self._refout = lines |
|
1245 | self._refout = lines | |
1246 |
|
1246 | |||
1247 | salt, script, after, expected = self._parsetest(lines) |
|
1247 | salt, script, after, expected = self._parsetest(lines) | |
1248 |
|
1248 | |||
1249 | # Write out the generated script. |
|
1249 | # Write out the generated script. | |
1250 | fname = b'%s.sh' % self._testtmp |
|
1250 | fname = b'%s.sh' % self._testtmp | |
1251 | f = open(fname, 'wb') |
|
1251 | f = open(fname, 'wb') | |
1252 | for l in script: |
|
1252 | for l in script: | |
1253 | f.write(l) |
|
1253 | f.write(l) | |
1254 | f.close() |
|
1254 | f.close() | |
1255 |
|
1255 | |||
1256 | cmd = b'%s "%s"' % (self._shell, fname) |
|
1256 | cmd = b'%s "%s"' % (self._shell, fname) | |
1257 | vlog("# Running", cmd) |
|
1257 | vlog("# Running", cmd) | |
1258 |
|
1258 | |||
1259 | exitcode, output = self._runcommand(cmd, env) |
|
1259 | exitcode, output = self._runcommand(cmd, env) | |
1260 |
|
1260 | |||
1261 | if self._aborted: |
|
1261 | if self._aborted: | |
1262 | raise KeyboardInterrupt() |
|
1262 | raise KeyboardInterrupt() | |
1263 |
|
1263 | |||
1264 | # Do not merge output if skipped. Return hghave message instead. |
|
1264 | # Do not merge output if skipped. Return hghave message instead. | |
1265 | # Similarly, with --debug, output is None. |
|
1265 | # Similarly, with --debug, output is None. | |
1266 | if exitcode == self.SKIPPED_STATUS or output is None: |
|
1266 | if exitcode == self.SKIPPED_STATUS or output is None: | |
1267 | return exitcode, output |
|
1267 | return exitcode, output | |
1268 |
|
1268 | |||
1269 | return self._processoutput(exitcode, output, salt, after, expected) |
|
1269 | return self._processoutput(exitcode, output, salt, after, expected) | |
1270 |
|
1270 | |||
1271 | def _hghave(self, reqs): |
|
1271 | def _hghave(self, reqs): | |
1272 | # TODO do something smarter when all other uses of hghave are gone. |
|
1272 | # TODO do something smarter when all other uses of hghave are gone. | |
1273 | runtestdir = os.path.abspath(os.path.dirname(_bytespath(__file__))) |
|
1273 | runtestdir = os.path.abspath(os.path.dirname(_bytespath(__file__))) | |
1274 | tdir = runtestdir.replace(b'\\', b'/') |
|
1274 | tdir = runtestdir.replace(b'\\', b'/') | |
1275 | proc = Popen4(b'%s -c "%s/hghave %s"' % |
|
1275 | proc = Popen4(b'%s -c "%s/hghave %s"' % | |
1276 | (self._shell, tdir, b' '.join(reqs)), |
|
1276 | (self._shell, tdir, b' '.join(reqs)), | |
1277 | self._testtmp, 0, self._getenv()) |
|
1277 | self._testtmp, 0, self._getenv()) | |
1278 | stdout, stderr = proc.communicate() |
|
1278 | stdout, stderr = proc.communicate() | |
1279 | ret = proc.wait() |
|
1279 | ret = proc.wait() | |
1280 | if wifexited(ret): |
|
1280 | if wifexited(ret): | |
1281 | ret = os.WEXITSTATUS(ret) |
|
1281 | ret = os.WEXITSTATUS(ret) | |
1282 | if ret == 2: |
|
1282 | if ret == 2: | |
1283 | print(stdout.decode('utf-8')) |
|
1283 | print(stdout.decode('utf-8')) | |
1284 | sys.exit(1) |
|
1284 | sys.exit(1) | |
1285 |
|
1285 | |||
1286 | if ret != 0: |
|
1286 | if ret != 0: | |
1287 | return False, stdout |
|
1287 | return False, stdout | |
1288 |
|
1288 | |||
1289 | if b'slow' in reqs: |
|
1289 | if b'slow' in reqs: | |
1290 | self._timeout = self._slowtimeout |
|
1290 | self._timeout = self._slowtimeout | |
1291 | return True, None |
|
1291 | return True, None | |
1292 |
|
1292 | |||
1293 | def _iftest(self, args): |
|
1293 | def _iftest(self, args): | |
1294 | # implements "#if" |
|
1294 | # implements "#if" | |
1295 | reqs = [] |
|
1295 | reqs = [] | |
1296 | for arg in args: |
|
1296 | for arg in args: | |
1297 | if arg.startswith(b'no-') and arg[3:] in self._allcases: |
|
1297 | if arg.startswith(b'no-') and arg[3:] in self._allcases: | |
1298 | if arg[3:] == self._case: |
|
1298 | if arg[3:] == self._case: | |
1299 | return False |
|
1299 | return False | |
1300 | elif arg in self._allcases: |
|
1300 | elif arg in self._allcases: | |
1301 | if arg != self._case: |
|
1301 | if arg != self._case: | |
1302 | return False |
|
1302 | return False | |
1303 | else: |
|
1303 | else: | |
1304 | reqs.append(arg) |
|
1304 | reqs.append(arg) | |
1305 | return self._hghave(reqs)[0] |
|
1305 | return self._hghave(reqs)[0] | |
1306 |
|
1306 | |||
1307 | def _parsetest(self, lines): |
|
1307 | def _parsetest(self, lines): | |
1308 | # We generate a shell script which outputs unique markers to line |
|
1308 | # We generate a shell script which outputs unique markers to line | |
1309 | # up script results with our source. These markers include input |
|
1309 | # up script results with our source. These markers include input | |
1310 | # line number and the last return code. |
|
1310 | # line number and the last return code. | |
1311 | salt = b"SALT%d" % time.time() |
|
1311 | salt = b"SALT%d" % time.time() | |
1312 | def addsalt(line, inpython): |
|
1312 | def addsalt(line, inpython): | |
1313 | if inpython: |
|
1313 | if inpython: | |
1314 | script.append(b'%s %d 0\n' % (salt, line)) |
|
1314 | script.append(b'%s %d 0\n' % (salt, line)) | |
1315 | else: |
|
1315 | else: | |
1316 | script.append(b'echo %s %d $?\n' % (salt, line)) |
|
1316 | script.append(b'echo %s %d $?\n' % (salt, line)) | |
1317 |
|
1317 | |||
1318 | script = [] |
|
1318 | script = [] | |
1319 |
|
1319 | |||
1320 | # After we run the shell script, we re-unify the script output |
|
1320 | # After we run the shell script, we re-unify the script output | |
1321 | # with non-active parts of the source, with synchronization by our |
|
1321 | # with non-active parts of the source, with synchronization by our | |
1322 | # SALT line number markers. The after table contains the non-active |
|
1322 | # SALT line number markers. The after table contains the non-active | |
1323 | # components, ordered by line number. |
|
1323 | # components, ordered by line number. | |
1324 | after = {} |
|
1324 | after = {} | |
1325 |
|
1325 | |||
1326 | # Expected shell script output. |
|
1326 | # Expected shell script output. | |
1327 | expected = {} |
|
1327 | expected = {} | |
1328 |
|
1328 | |||
1329 | pos = prepos = -1 |
|
1329 | pos = prepos = -1 | |
1330 |
|
1330 | |||
1331 | # True or False when in a true or false conditional section |
|
1331 | # True or False when in a true or false conditional section | |
1332 | skipping = None |
|
1332 | skipping = None | |
1333 |
|
1333 | |||
1334 | # We keep track of whether or not we're in a Python block so we |
|
1334 | # We keep track of whether or not we're in a Python block so we | |
1335 | # can generate the surrounding doctest magic. |
|
1335 | # can generate the surrounding doctest magic. | |
1336 | inpython = False |
|
1336 | inpython = False | |
1337 |
|
1337 | |||
1338 | if self._debug: |
|
1338 | if self._debug: | |
1339 | script.append(b'set -x\n') |
|
1339 | script.append(b'set -x\n') | |
1340 | if self._hgcommand != b'hg': |
|
1340 | if self._hgcommand != b'hg': | |
1341 | script.append(b'alias hg="%s"\n' % self._hgcommand) |
|
1341 | script.append(b'alias hg="%s"\n' % self._hgcommand) | |
1342 | if os.getenv('MSYSTEM'): |
|
1342 | if os.getenv('MSYSTEM'): | |
1343 | script.append(b'alias pwd="pwd -W"\n') |
|
1343 | script.append(b'alias pwd="pwd -W"\n') | |
1344 |
|
1344 | |||
1345 | n = 0 |
|
1345 | n = 0 | |
1346 | for n, l in enumerate(lines): |
|
1346 | for n, l in enumerate(lines): | |
1347 | if not l.endswith(b'\n'): |
|
1347 | if not l.endswith(b'\n'): | |
1348 | l += b'\n' |
|
1348 | l += b'\n' | |
1349 | if l.startswith(b'#require'): |
|
1349 | if l.startswith(b'#require'): | |
1350 | lsplit = l.split() |
|
1350 | lsplit = l.split() | |
1351 | if len(lsplit) < 2 or lsplit[0] != b'#require': |
|
1351 | if len(lsplit) < 2 or lsplit[0] != b'#require': | |
1352 | after.setdefault(pos, []).append(' !!! invalid #require\n') |
|
1352 | after.setdefault(pos, []).append(' !!! invalid #require\n') | |
1353 | haveresult, message = self._hghave(lsplit[1:]) |
|
1353 | haveresult, message = self._hghave(lsplit[1:]) | |
1354 | if not haveresult: |
|
1354 | if not haveresult: | |
1355 | script = [b'echo "%s"\nexit 80\n' % message] |
|
1355 | script = [b'echo "%s"\nexit 80\n' % message] | |
1356 | break |
|
1356 | break | |
1357 | after.setdefault(pos, []).append(l) |
|
1357 | after.setdefault(pos, []).append(l) | |
1358 | elif l.startswith(b'#if'): |
|
1358 | elif l.startswith(b'#if'): | |
1359 | lsplit = l.split() |
|
1359 | lsplit = l.split() | |
1360 | if len(lsplit) < 2 or lsplit[0] != b'#if': |
|
1360 | if len(lsplit) < 2 or lsplit[0] != b'#if': | |
1361 | after.setdefault(pos, []).append(' !!! invalid #if\n') |
|
1361 | after.setdefault(pos, []).append(' !!! invalid #if\n') | |
1362 | if skipping is not None: |
|
1362 | if skipping is not None: | |
1363 | after.setdefault(pos, []).append(' !!! nested #if\n') |
|
1363 | after.setdefault(pos, []).append(' !!! nested #if\n') | |
1364 | skipping = not self._iftest(lsplit[1:]) |
|
1364 | skipping = not self._iftest(lsplit[1:]) | |
1365 | after.setdefault(pos, []).append(l) |
|
1365 | after.setdefault(pos, []).append(l) | |
1366 | elif l.startswith(b'#else'): |
|
1366 | elif l.startswith(b'#else'): | |
1367 | if skipping is None: |
|
1367 | if skipping is None: | |
1368 | after.setdefault(pos, []).append(' !!! missing #if\n') |
|
1368 | after.setdefault(pos, []).append(' !!! missing #if\n') | |
1369 | skipping = not skipping |
|
1369 | skipping = not skipping | |
1370 | after.setdefault(pos, []).append(l) |
|
1370 | after.setdefault(pos, []).append(l) | |
1371 | elif l.startswith(b'#endif'): |
|
1371 | elif l.startswith(b'#endif'): | |
1372 | if skipping is None: |
|
1372 | if skipping is None: | |
1373 | after.setdefault(pos, []).append(' !!! missing #if\n') |
|
1373 | after.setdefault(pos, []).append(' !!! missing #if\n') | |
1374 | skipping = None |
|
1374 | skipping = None | |
1375 | after.setdefault(pos, []).append(l) |
|
1375 | after.setdefault(pos, []).append(l) | |
1376 | elif skipping: |
|
1376 | elif skipping: | |
1377 | after.setdefault(pos, []).append(l) |
|
1377 | after.setdefault(pos, []).append(l) | |
1378 | elif l.startswith(b' >>> '): # python inlines |
|
1378 | elif l.startswith(b' >>> '): # python inlines | |
1379 | after.setdefault(pos, []).append(l) |
|
1379 | after.setdefault(pos, []).append(l) | |
1380 | prepos = pos |
|
1380 | prepos = pos | |
1381 | pos = n |
|
1381 | pos = n | |
1382 | if not inpython: |
|
1382 | if not inpython: | |
1383 | # We've just entered a Python block. Add the header. |
|
1383 | # We've just entered a Python block. Add the header. | |
1384 | inpython = True |
|
1384 | inpython = True | |
1385 | addsalt(prepos, False) # Make sure we report the exit code. |
|
1385 | addsalt(prepos, False) # Make sure we report the exit code. | |
1386 | script.append(b'%s -m heredoctest <<EOF\n' % PYTHON) |
|
1386 | script.append(b'%s -m heredoctest <<EOF\n' % PYTHON) | |
1387 | addsalt(n, True) |
|
1387 | addsalt(n, True) | |
1388 | script.append(l[2:]) |
|
1388 | script.append(l[2:]) | |
1389 | elif l.startswith(b' ... '): # python inlines |
|
1389 | elif l.startswith(b' ... '): # python inlines | |
1390 | after.setdefault(prepos, []).append(l) |
|
1390 | after.setdefault(prepos, []).append(l) | |
1391 | script.append(l[2:]) |
|
1391 | script.append(l[2:]) | |
1392 | elif l.startswith(b' $ '): # commands |
|
1392 | elif l.startswith(b' $ '): # commands | |
1393 | if inpython: |
|
1393 | if inpython: | |
1394 | script.append(b'EOF\n') |
|
1394 | script.append(b'EOF\n') | |
1395 | inpython = False |
|
1395 | inpython = False | |
1396 | after.setdefault(pos, []).append(l) |
|
1396 | after.setdefault(pos, []).append(l) | |
1397 | prepos = pos |
|
1397 | prepos = pos | |
1398 | pos = n |
|
1398 | pos = n | |
1399 | addsalt(n, False) |
|
1399 | addsalt(n, False) | |
1400 | cmd = l[4:].split() |
|
1400 | cmd = l[4:].split() | |
1401 | if len(cmd) == 2 and cmd[0] == b'cd': |
|
1401 | if len(cmd) == 2 and cmd[0] == b'cd': | |
1402 | l = b' $ cd %s || exit 1\n' % cmd[1] |
|
1402 | l = b' $ cd %s || exit 1\n' % cmd[1] | |
1403 | script.append(l[4:]) |
|
1403 | script.append(l[4:]) | |
1404 | elif l.startswith(b' > '): # continuations |
|
1404 | elif l.startswith(b' > '): # continuations | |
1405 | after.setdefault(prepos, []).append(l) |
|
1405 | after.setdefault(prepos, []).append(l) | |
1406 | script.append(l[4:]) |
|
1406 | script.append(l[4:]) | |
1407 | elif l.startswith(b' '): # results |
|
1407 | elif l.startswith(b' '): # results | |
1408 | # Queue up a list of expected results. |
|
1408 | # Queue up a list of expected results. | |
1409 | expected.setdefault(pos, []).append(l[2:]) |
|
1409 | expected.setdefault(pos, []).append(l[2:]) | |
1410 | else: |
|
1410 | else: | |
1411 | if inpython: |
|
1411 | if inpython: | |
1412 | script.append(b'EOF\n') |
|
1412 | script.append(b'EOF\n') | |
1413 | inpython = False |
|
1413 | inpython = False | |
1414 | # Non-command/result. Queue up for merged output. |
|
1414 | # Non-command/result. Queue up for merged output. | |
1415 | after.setdefault(pos, []).append(l) |
|
1415 | after.setdefault(pos, []).append(l) | |
1416 |
|
1416 | |||
1417 | if inpython: |
|
1417 | if inpython: | |
1418 | script.append(b'EOF\n') |
|
1418 | script.append(b'EOF\n') | |
1419 | if skipping is not None: |
|
1419 | if skipping is not None: | |
1420 | after.setdefault(pos, []).append(' !!! missing #endif\n') |
|
1420 | after.setdefault(pos, []).append(' !!! missing #endif\n') | |
1421 | addsalt(n + 1, False) |
|
1421 | addsalt(n + 1, False) | |
1422 |
|
1422 | |||
1423 | return salt, script, after, expected |
|
1423 | return salt, script, after, expected | |
1424 |
|
1424 | |||
1425 | def _processoutput(self, exitcode, output, salt, after, expected): |
|
1425 | def _processoutput(self, exitcode, output, salt, after, expected): | |
1426 | # Merge the script output back into a unified test. |
|
1426 | # Merge the script output back into a unified test. | |
1427 | warnonly = 1 # 1: not yet; 2: yes; 3: for sure not |
|
1427 | warnonly = 1 # 1: not yet; 2: yes; 3: for sure not | |
1428 | if exitcode != 0: |
|
1428 | if exitcode != 0: | |
1429 | warnonly = 3 |
|
1429 | warnonly = 3 | |
1430 |
|
1430 | |||
1431 | pos = -1 |
|
1431 | pos = -1 | |
1432 | postout = [] |
|
1432 | postout = [] | |
1433 | for l in output: |
|
1433 | for l in output: | |
1434 | lout, lcmd = l, None |
|
1434 | lout, lcmd = l, None | |
1435 | if salt in l: |
|
1435 | if salt in l: | |
1436 | lout, lcmd = l.split(salt, 1) |
|
1436 | lout, lcmd = l.split(salt, 1) | |
1437 |
|
1437 | |||
1438 | while lout: |
|
1438 | while lout: | |
1439 | if not lout.endswith(b'\n'): |
|
1439 | if not lout.endswith(b'\n'): | |
1440 | lout += b' (no-eol)\n' |
|
1440 | lout += b' (no-eol)\n' | |
1441 |
|
1441 | |||
1442 | # Find the expected output at the current position. |
|
1442 | # Find the expected output at the current position. | |
1443 | els = [None] |
|
1443 | els = [None] | |
1444 | if expected.get(pos, None): |
|
1444 | if expected.get(pos, None): | |
1445 | els = expected[pos] |
|
1445 | els = expected[pos] | |
1446 |
|
1446 | |||
1447 | i = 0 |
|
1447 | i = 0 | |
1448 | optional = [] |
|
1448 | optional = [] | |
1449 | while i < len(els): |
|
1449 | while i < len(els): | |
1450 | el = els[i] |
|
1450 | el = els[i] | |
1451 |
|
1451 | |||
1452 | r = self.linematch(el, lout) |
|
1452 | r = self.linematch(el, lout) | |
1453 | if isinstance(r, str): |
|
1453 | if isinstance(r, str): | |
1454 | if r == '-glob': |
|
1454 | if r == '-glob': | |
1455 | lout = ''.join(el.rsplit(' (glob)', 1)) |
|
1455 | lout = ''.join(el.rsplit(' (glob)', 1)) | |
1456 | r = '' # Warn only this line. |
|
1456 | r = '' # Warn only this line. | |
1457 | elif r == "retry": |
|
1457 | elif r == "retry": | |
1458 | postout.append(b' ' + el) |
|
1458 | postout.append(b' ' + el) | |
1459 | els.pop(i) |
|
1459 | els.pop(i) | |
1460 | break |
|
1460 | break | |
1461 | else: |
|
1461 | else: | |
1462 | log('\ninfo, unknown linematch result: %r\n' % r) |
|
1462 | log('\ninfo, unknown linematch result: %r\n' % r) | |
1463 | r = False |
|
1463 | r = False | |
1464 | if r: |
|
1464 | if r: | |
1465 | els.pop(i) |
|
1465 | els.pop(i) | |
1466 | break |
|
1466 | break | |
1467 | if el: |
|
1467 | if el: | |
1468 | if el.endswith(b" (?)\n"): |
|
1468 | if el.endswith(b" (?)\n"): | |
1469 | optional.append(i) |
|
1469 | optional.append(i) | |
1470 | else: |
|
1470 | else: | |
1471 | m = optline.match(el) |
|
1471 | m = optline.match(el) | |
1472 | if m: |
|
1472 | if m: | |
1473 | conditions = [ |
|
1473 | conditions = [ | |
1474 | c for c in m.group(2).split(b' ')] |
|
1474 | c for c in m.group(2).split(b' ')] | |
1475 |
|
1475 | |||
1476 | if not self._iftest(conditions): |
|
1476 | if not self._iftest(conditions): | |
1477 | optional.append(i) |
|
1477 | optional.append(i) | |
1478 |
|
1478 | |||
1479 | i += 1 |
|
1479 | i += 1 | |
1480 |
|
1480 | |||
1481 | if r: |
|
1481 | if r: | |
1482 | if r == "retry": |
|
1482 | if r == "retry": | |
1483 | continue |
|
1483 | continue | |
1484 | # clean up any optional leftovers |
|
1484 | # clean up any optional leftovers | |
1485 | for i in optional: |
|
1485 | for i in optional: | |
1486 | postout.append(b' ' + els[i]) |
|
1486 | postout.append(b' ' + els[i]) | |
1487 | for i in reversed(optional): |
|
1487 | for i in reversed(optional): | |
1488 | del els[i] |
|
1488 | del els[i] | |
1489 | postout.append(b' ' + el) |
|
1489 | postout.append(b' ' + el) | |
1490 | else: |
|
1490 | else: | |
1491 | if self.NEEDESCAPE(lout): |
|
1491 | if self.NEEDESCAPE(lout): | |
1492 | lout = TTest._stringescape(b'%s (esc)\n' % |
|
1492 | lout = TTest._stringescape(b'%s (esc)\n' % | |
1493 | lout.rstrip(b'\n')) |
|
1493 | lout.rstrip(b'\n')) | |
1494 | postout.append(b' ' + lout) # Let diff deal with it. |
|
1494 | postout.append(b' ' + lout) # Let diff deal with it. | |
1495 | if r != '': # If line failed. |
|
1495 | if r != '': # If line failed. | |
1496 | warnonly = 3 # for sure not |
|
1496 | warnonly = 3 # for sure not | |
1497 | elif warnonly == 1: # Is "not yet" and line is warn only. |
|
1497 | elif warnonly == 1: # Is "not yet" and line is warn only. | |
1498 | warnonly = 2 # Yes do warn. |
|
1498 | warnonly = 2 # Yes do warn. | |
1499 | break |
|
1499 | break | |
1500 | else: |
|
1500 | else: | |
1501 | # clean up any optional leftovers |
|
1501 | # clean up any optional leftovers | |
1502 | while expected.get(pos, None): |
|
1502 | while expected.get(pos, None): | |
1503 | el = expected[pos].pop(0) |
|
1503 | el = expected[pos].pop(0) | |
1504 | if el: |
|
1504 | if el: | |
1505 | if not el.endswith(b" (?)\n"): |
|
1505 | if not el.endswith(b" (?)\n"): | |
1506 | m = optline.match(el) |
|
1506 | m = optline.match(el) | |
1507 | if m: |
|
1507 | if m: | |
1508 | conditions = [c for c in m.group(2).split(b' ')] |
|
1508 | conditions = [c for c in m.group(2).split(b' ')] | |
1509 |
|
1509 | |||
1510 | if self._iftest(conditions): |
|
1510 | if self._iftest(conditions): | |
1511 | # Don't append as optional line |
|
1511 | # Don't append as optional line | |
1512 | continue |
|
1512 | continue | |
1513 | else: |
|
1513 | else: | |
1514 | continue |
|
1514 | continue | |
1515 | postout.append(b' ' + el) |
|
1515 | postout.append(b' ' + el) | |
1516 |
|
1516 | |||
1517 | if lcmd: |
|
1517 | if lcmd: | |
1518 | # Add on last return code. |
|
1518 | # Add on last return code. | |
1519 | ret = int(lcmd.split()[1]) |
|
1519 | ret = int(lcmd.split()[1]) | |
1520 | if ret != 0: |
|
1520 | if ret != 0: | |
1521 | postout.append(b' [%d]\n' % ret) |
|
1521 | postout.append(b' [%d]\n' % ret) | |
1522 | if pos in after: |
|
1522 | if pos in after: | |
1523 | # Merge in non-active test bits. |
|
1523 | # Merge in non-active test bits. | |
1524 | postout += after.pop(pos) |
|
1524 | postout += after.pop(pos) | |
1525 | pos = int(lcmd.split()[0]) |
|
1525 | pos = int(lcmd.split()[0]) | |
1526 |
|
1526 | |||
1527 | if pos in after: |
|
1527 | if pos in after: | |
1528 | postout += after.pop(pos) |
|
1528 | postout += after.pop(pos) | |
1529 |
|
1529 | |||
1530 | if warnonly == 2: |
|
1530 | if warnonly == 2: | |
1531 | exitcode = False # Set exitcode to warned. |
|
1531 | exitcode = False # Set exitcode to warned. | |
1532 |
|
1532 | |||
1533 | return exitcode, postout |
|
1533 | return exitcode, postout | |
1534 |
|
1534 | |||
1535 | @staticmethod |
|
1535 | @staticmethod | |
1536 | def rematch(el, l): |
|
1536 | def rematch(el, l): | |
1537 | try: |
|
1537 | try: | |
1538 | el = b'(?:' + el + b')' |
|
1538 | el = b'(?:' + el + b')' | |
1539 | # use \Z to ensure that the regex matches to the end of the string |
|
1539 | # use \Z to ensure that the regex matches to the end of the string | |
1540 | if os.name == 'nt': |
|
1540 | if os.name == 'nt': | |
1541 | return re.match(el + br'\r?\n\Z', l) |
|
1541 | return re.match(el + br'\r?\n\Z', l) | |
1542 | return re.match(el + br'\n\Z', l) |
|
1542 | return re.match(el + br'\n\Z', l) | |
1543 | except re.error: |
|
1543 | except re.error: | |
1544 | # el is an invalid regex |
|
1544 | # el is an invalid regex | |
1545 | return False |
|
1545 | return False | |
1546 |
|
1546 | |||
1547 | @staticmethod |
|
1547 | @staticmethod | |
1548 | def globmatch(el, l): |
|
1548 | def globmatch(el, l): | |
1549 | # The only supported special characters are * and ? plus / which also |
|
1549 | # The only supported special characters are * and ? plus / which also | |
1550 | # matches \ on windows. Escaping of these characters is supported. |
|
1550 | # matches \ on windows. Escaping of these characters is supported. | |
1551 | if el + b'\n' == l: |
|
1551 | if el + b'\n' == l: | |
1552 | if os.altsep: |
|
1552 | if os.altsep: | |
1553 | # matching on "/" is not needed for this line |
|
1553 | # matching on "/" is not needed for this line | |
1554 | for pat in checkcodeglobpats: |
|
1554 | for pat in checkcodeglobpats: | |
1555 | if pat.match(el): |
|
1555 | if pat.match(el): | |
1556 | return True |
|
1556 | return True | |
1557 | return b'-glob' |
|
1557 | return b'-glob' | |
1558 | return True |
|
1558 | return True | |
1559 | el = el.replace(b'$LOCALIP', b'*') |
|
1559 | el = el.replace(b'$LOCALIP', b'*') | |
1560 | i, n = 0, len(el) |
|
1560 | i, n = 0, len(el) | |
1561 | res = b'' |
|
1561 | res = b'' | |
1562 | while i < n: |
|
1562 | while i < n: | |
1563 | c = el[i:i + 1] |
|
1563 | c = el[i:i + 1] | |
1564 | i += 1 |
|
1564 | i += 1 | |
1565 | if c == b'\\' and i < n and el[i:i + 1] in b'*?\\/': |
|
1565 | if c == b'\\' and i < n and el[i:i + 1] in b'*?\\/': | |
1566 | res += el[i - 1:i + 1] |
|
1566 | res += el[i - 1:i + 1] | |
1567 | i += 1 |
|
1567 | i += 1 | |
1568 | elif c == b'*': |
|
1568 | elif c == b'*': | |
1569 | res += b'.*' |
|
1569 | res += b'.*' | |
1570 | elif c == b'?': |
|
1570 | elif c == b'?': | |
1571 | res += b'.' |
|
1571 | res += b'.' | |
1572 | elif c == b'/' and os.altsep: |
|
1572 | elif c == b'/' and os.altsep: | |
1573 | res += b'[/\\\\]' |
|
1573 | res += b'[/\\\\]' | |
1574 | else: |
|
1574 | else: | |
1575 | res += re.escape(c) |
|
1575 | res += re.escape(c) | |
1576 | return TTest.rematch(res, l) |
|
1576 | return TTest.rematch(res, l) | |
1577 |
|
1577 | |||
1578 | def linematch(self, el, l): |
|
1578 | def linematch(self, el, l): | |
1579 | retry = False |
|
1579 | retry = False | |
1580 | if el == l: # perfect match (fast) |
|
1580 | if el == l: # perfect match (fast) | |
1581 | return True |
|
1581 | return True | |
1582 | if el: |
|
1582 | if el: | |
1583 | if el.endswith(b" (?)\n"): |
|
1583 | if el.endswith(b" (?)\n"): | |
1584 | retry = "retry" |
|
1584 | retry = "retry" | |
1585 | el = el[:-5] + b"\n" |
|
1585 | el = el[:-5] + b"\n" | |
1586 | else: |
|
1586 | else: | |
1587 | m = optline.match(el) |
|
1587 | m = optline.match(el) | |
1588 | if m: |
|
1588 | if m: | |
1589 | conditions = [c for c in m.group(2).split(b' ')] |
|
1589 | conditions = [c for c in m.group(2).split(b' ')] | |
1590 |
|
1590 | |||
1591 | el = m.group(1) + b"\n" |
|
1591 | el = m.group(1) + b"\n" | |
1592 | if not self._iftest(conditions): |
|
1592 | if not self._iftest(conditions): | |
1593 | retry = "retry" # Not required by listed features |
|
1593 | retry = "retry" # Not required by listed features | |
1594 |
|
1594 | |||
1595 | if el.endswith(b" (esc)\n"): |
|
1595 | if el.endswith(b" (esc)\n"): | |
1596 | if PYTHON3: |
|
1596 | if PYTHON3: | |
1597 | el = el[:-7].decode('unicode_escape') + '\n' |
|
1597 | el = el[:-7].decode('unicode_escape') + '\n' | |
1598 | el = el.encode('utf-8') |
|
1598 | el = el.encode('utf-8') | |
1599 | else: |
|
1599 | else: | |
1600 | el = el[:-7].decode('string-escape') + '\n' |
|
1600 | el = el[:-7].decode('string-escape') + '\n' | |
1601 | if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l: |
|
1601 | if el == l or os.name == 'nt' and el[:-1] + b'\r\n' == l: | |
1602 | return True |
|
1602 | return True | |
1603 | if el.endswith(b" (re)\n"): |
|
1603 | if el.endswith(b" (re)\n"): | |
1604 | return TTest.rematch(el[:-6], l) or retry |
|
1604 | return TTest.rematch(el[:-6], l) or retry | |
1605 | if el.endswith(b" (glob)\n"): |
|
1605 | if el.endswith(b" (glob)\n"): | |
1606 | # ignore '(glob)' added to l by 'replacements' |
|
1606 | # ignore '(glob)' added to l by 'replacements' | |
1607 | if l.endswith(b" (glob)\n"): |
|
1607 | if l.endswith(b" (glob)\n"): | |
1608 | l = l[:-8] + b"\n" |
|
1608 | l = l[:-8] + b"\n" | |
1609 | return TTest.globmatch(el[:-8], l) or retry |
|
1609 | return TTest.globmatch(el[:-8], l) or retry | |
1610 | if os.altsep: |
|
1610 | if os.altsep: | |
1611 | _l = l.replace(b'\\', b'/') |
|
1611 | _l = l.replace(b'\\', b'/') | |
1612 | if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l: |
|
1612 | if el == _l or os.name == 'nt' and el[:-1] + b'\r\n' == _l: | |
1613 | return True |
|
1613 | return True | |
1614 | return retry |
|
1614 | return retry | |
1615 |
|
1615 | |||
1616 | @staticmethod |
|
1616 | @staticmethod | |
1617 | def parsehghaveoutput(lines): |
|
1617 | def parsehghaveoutput(lines): | |
1618 | '''Parse hghave log lines. |
|
1618 | '''Parse hghave log lines. | |
1619 |
|
1619 | |||
1620 | Return tuple of lists (missing, failed): |
|
1620 | Return tuple of lists (missing, failed): | |
1621 | * the missing/unknown features |
|
1621 | * the missing/unknown features | |
1622 | * the features for which existence check failed''' |
|
1622 | * the features for which existence check failed''' | |
1623 | missing = [] |
|
1623 | missing = [] | |
1624 | failed = [] |
|
1624 | failed = [] | |
1625 | for line in lines: |
|
1625 | for line in lines: | |
1626 | if line.startswith(TTest.SKIPPED_PREFIX): |
|
1626 | if line.startswith(TTest.SKIPPED_PREFIX): | |
1627 | line = line.splitlines()[0] |
|
1627 | line = line.splitlines()[0] | |
1628 | missing.append(line[len(TTest.SKIPPED_PREFIX):].decode('utf-8')) |
|
1628 | missing.append(line[len(TTest.SKIPPED_PREFIX):].decode('utf-8')) | |
1629 | elif line.startswith(TTest.FAILED_PREFIX): |
|
1629 | elif line.startswith(TTest.FAILED_PREFIX): | |
1630 | line = line.splitlines()[0] |
|
1630 | line = line.splitlines()[0] | |
1631 | failed.append(line[len(TTest.FAILED_PREFIX):].decode('utf-8')) |
|
1631 | failed.append(line[len(TTest.FAILED_PREFIX):].decode('utf-8')) | |
1632 |
|
1632 | |||
1633 | return missing, failed |
|
1633 | return missing, failed | |
1634 |
|
1634 | |||
1635 | @staticmethod |
|
1635 | @staticmethod | |
1636 | def _escapef(m): |
|
1636 | def _escapef(m): | |
1637 | return TTest.ESCAPEMAP[m.group(0)] |
|
1637 | return TTest.ESCAPEMAP[m.group(0)] | |
1638 |
|
1638 | |||
1639 | @staticmethod |
|
1639 | @staticmethod | |
1640 | def _stringescape(s): |
|
1640 | def _stringescape(s): | |
1641 | return TTest.ESCAPESUB(TTest._escapef, s) |
|
1641 | return TTest.ESCAPESUB(TTest._escapef, s) | |
1642 |
|
1642 | |||
1643 | iolock = threading.RLock() |
|
1643 | iolock = threading.RLock() | |
1644 |
|
1644 | |||
1645 | class TestResult(unittest._TextTestResult): |
|
1645 | class TestResult(unittest._TextTestResult): | |
1646 | """Holds results when executing via unittest.""" |
|
1646 | """Holds results when executing via unittest.""" | |
1647 | # Don't worry too much about accessing the non-public _TextTestResult. |
|
1647 | # Don't worry too much about accessing the non-public _TextTestResult. | |
1648 | # It is relatively common in Python testing tools. |
|
1648 | # It is relatively common in Python testing tools. | |
1649 | def __init__(self, options, *args, **kwargs): |
|
1649 | def __init__(self, options, *args, **kwargs): | |
1650 | super(TestResult, self).__init__(*args, **kwargs) |
|
1650 | super(TestResult, self).__init__(*args, **kwargs) | |
1651 |
|
1651 | |||
1652 | self._options = options |
|
1652 | self._options = options | |
1653 |
|
1653 | |||
1654 | # unittest.TestResult didn't have skipped until 2.7. We need to |
|
1654 | # unittest.TestResult didn't have skipped until 2.7. We need to | |
1655 | # polyfill it. |
|
1655 | # polyfill it. | |
1656 | self.skipped = [] |
|
1656 | self.skipped = [] | |
1657 |
|
1657 | |||
1658 | # We have a custom "ignored" result that isn't present in any Python |
|
1658 | # We have a custom "ignored" result that isn't present in any Python | |
1659 | # unittest implementation. It is very similar to skipped. It may make |
|
1659 | # unittest implementation. It is very similar to skipped. It may make | |
1660 | # sense to map it into skip some day. |
|
1660 | # sense to map it into skip some day. | |
1661 | self.ignored = [] |
|
1661 | self.ignored = [] | |
1662 |
|
1662 | |||
1663 | self.times = [] |
|
1663 | self.times = [] | |
1664 | self._firststarttime = None |
|
1664 | self._firststarttime = None | |
1665 | # Data stored for the benefit of generating xunit reports. |
|
1665 | # Data stored for the benefit of generating xunit reports. | |
1666 | self.successes = [] |
|
1666 | self.successes = [] | |
1667 | self.faildata = {} |
|
1667 | self.faildata = {} | |
1668 |
|
1668 | |||
1669 | if options.color == 'auto': |
|
1669 | if options.color == 'auto': | |
1670 | self.color = pygmentspresent and self.stream.isatty() |
|
1670 | self.color = pygmentspresent and self.stream.isatty() | |
1671 | elif options.color == 'never': |
|
1671 | elif options.color == 'never': | |
1672 | self.color = False |
|
1672 | self.color = False | |
1673 | else: # 'always', for testing purposes |
|
1673 | else: # 'always', for testing purposes | |
1674 | self.color = pygmentspresent |
|
1674 | self.color = pygmentspresent | |
1675 |
|
1675 | |||
1676 | def addFailure(self, test, reason): |
|
1676 | def addFailure(self, test, reason): | |
1677 | self.failures.append((test, reason)) |
|
1677 | self.failures.append((test, reason)) | |
1678 |
|
1678 | |||
1679 | if self._options.first: |
|
1679 | if self._options.first: | |
1680 | self.stop() |
|
1680 | self.stop() | |
1681 | else: |
|
1681 | else: | |
1682 | with iolock: |
|
1682 | with iolock: | |
1683 | if reason == "timed out": |
|
1683 | if reason == "timed out": | |
1684 | self.stream.write('t') |
|
1684 | self.stream.write('t') | |
1685 | else: |
|
1685 | else: | |
1686 | if not self._options.nodiff: |
|
1686 | if not self._options.nodiff: | |
1687 | self.stream.write('\n') |
|
1687 | self.stream.write('\n') | |
1688 | # Exclude the '\n' from highlighting to lex correctly |
|
1688 | # Exclude the '\n' from highlighting to lex correctly | |
1689 | formatted = 'ERROR: %s output changed\n' % test |
|
1689 | formatted = 'ERROR: %s output changed\n' % test | |
1690 | self.stream.write(highlightmsg(formatted, self.color)) |
|
1690 | self.stream.write(highlightmsg(formatted, self.color)) | |
1691 | self.stream.write('!') |
|
1691 | self.stream.write('!') | |
1692 |
|
1692 | |||
1693 | self.stream.flush() |
|
1693 | self.stream.flush() | |
1694 |
|
1694 | |||
1695 | def addSuccess(self, test): |
|
1695 | def addSuccess(self, test): | |
1696 | with iolock: |
|
1696 | with iolock: | |
1697 | super(TestResult, self).addSuccess(test) |
|
1697 | super(TestResult, self).addSuccess(test) | |
1698 | self.successes.append(test) |
|
1698 | self.successes.append(test) | |
1699 |
|
1699 | |||
1700 | def addError(self, test, err): |
|
1700 | def addError(self, test, err): | |
1701 | super(TestResult, self).addError(test, err) |
|
1701 | super(TestResult, self).addError(test, err) | |
1702 | if self._options.first: |
|
1702 | if self._options.first: | |
1703 | self.stop() |
|
1703 | self.stop() | |
1704 |
|
1704 | |||
1705 | # Polyfill. |
|
1705 | # Polyfill. | |
1706 | def addSkip(self, test, reason): |
|
1706 | def addSkip(self, test, reason): | |
1707 | self.skipped.append((test, reason)) |
|
1707 | self.skipped.append((test, reason)) | |
1708 | with iolock: |
|
1708 | with iolock: | |
1709 | if self.showAll: |
|
1709 | if self.showAll: | |
1710 | self.stream.writeln('skipped %s' % reason) |
|
1710 | self.stream.writeln('skipped %s' % reason) | |
1711 | else: |
|
1711 | else: | |
1712 | self.stream.write('s') |
|
1712 | self.stream.write('s') | |
1713 | self.stream.flush() |
|
1713 | self.stream.flush() | |
1714 |
|
1714 | |||
1715 | def addIgnore(self, test, reason): |
|
1715 | def addIgnore(self, test, reason): | |
1716 | self.ignored.append((test, reason)) |
|
1716 | self.ignored.append((test, reason)) | |
1717 | with iolock: |
|
1717 | with iolock: | |
1718 | if self.showAll: |
|
1718 | if self.showAll: | |
1719 | self.stream.writeln('ignored %s' % reason) |
|
1719 | self.stream.writeln('ignored %s' % reason) | |
1720 | else: |
|
1720 | else: | |
1721 | if reason not in ('not retesting', "doesn't match keyword"): |
|
1721 | if reason not in ('not retesting', "doesn't match keyword"): | |
1722 | self.stream.write('i') |
|
1722 | self.stream.write('i') | |
1723 | else: |
|
1723 | else: | |
1724 | self.testsRun += 1 |
|
1724 | self.testsRun += 1 | |
1725 | self.stream.flush() |
|
1725 | self.stream.flush() | |
1726 |
|
1726 | |||
1727 | def addOutputMismatch(self, test, ret, got, expected): |
|
1727 | def addOutputMismatch(self, test, ret, got, expected): | |
1728 | """Record a mismatch in test output for a particular test.""" |
|
1728 | """Record a mismatch in test output for a particular test.""" | |
1729 | if self.shouldStop: |
|
1729 | if self.shouldStop: | |
1730 | # don't print, some other test case already failed and |
|
1730 | # don't print, some other test case already failed and | |
1731 | # printed, we're just stale and probably failed due to our |
|
1731 | # printed, we're just stale and probably failed due to our | |
1732 | # temp dir getting cleaned up. |
|
1732 | # temp dir getting cleaned up. | |
1733 | return |
|
1733 | return | |
1734 |
|
1734 | |||
1735 | accepted = False |
|
1735 | accepted = False | |
1736 | lines = [] |
|
1736 | lines = [] | |
1737 |
|
1737 | |||
1738 | with iolock: |
|
1738 | with iolock: | |
1739 | if self._options.nodiff: |
|
1739 | if self._options.nodiff: | |
1740 | pass |
|
1740 | pass | |
1741 | elif self._options.view: |
|
1741 | elif self._options.view: | |
1742 | v = self._options.view |
|
1742 | v = self._options.view | |
1743 | if PYTHON3: |
|
1743 | if PYTHON3: | |
1744 | v = _bytespath(v) |
|
1744 | v = _bytespath(v) | |
1745 | os.system(b"%s %s %s" % |
|
1745 | os.system(b"%s %s %s" % | |
1746 | (v, test.refpath, test.errpath)) |
|
1746 | (v, test.refpath, test.errpath)) | |
1747 | else: |
|
1747 | else: | |
1748 | servefail, lines = getdiff(expected, got, |
|
1748 | servefail, lines = getdiff(expected, got, | |
1749 | test.refpath, test.errpath) |
|
1749 | test.refpath, test.errpath) | |
1750 | if servefail: |
|
1750 | if servefail: | |
1751 | raise test.failureException( |
|
1751 | raise test.failureException( | |
1752 | 'server failed to start (HGPORT=%s)' % test._startport) |
|
1752 | 'server failed to start (HGPORT=%s)' % test._startport) | |
1753 | else: |
|
1753 | else: | |
1754 | self.stream.write('\n') |
|
1754 | self.stream.write('\n') | |
1755 | for line in lines: |
|
1755 | for line in lines: | |
1756 | line = highlightdiff(line, self.color) |
|
1756 | line = highlightdiff(line, self.color) | |
1757 | if PYTHON3: |
|
1757 | if PYTHON3: | |
1758 | self.stream.flush() |
|
1758 | self.stream.flush() | |
1759 | self.stream.buffer.write(line) |
|
1759 | self.stream.buffer.write(line) | |
1760 | self.stream.buffer.flush() |
|
1760 | self.stream.buffer.flush() | |
1761 | else: |
|
1761 | else: | |
1762 | self.stream.write(line) |
|
1762 | self.stream.write(line) | |
1763 | self.stream.flush() |
|
1763 | self.stream.flush() | |
1764 |
|
1764 | |||
1765 | # handle interactive prompt without releasing iolock |
|
1765 | # handle interactive prompt without releasing iolock | |
1766 | if self._options.interactive: |
|
1766 | if self._options.interactive: | |
1767 | if test.readrefout() != expected: |
|
1767 | if test.readrefout() != expected: | |
1768 | self.stream.write( |
|
1768 | self.stream.write( | |
1769 | 'Reference output has changed (run again to prompt ' |
|
1769 | 'Reference output has changed (run again to prompt ' | |
1770 | 'changes)') |
|
1770 | 'changes)') | |
1771 | else: |
|
1771 | else: | |
1772 | self.stream.write('Accept this change? [n] ') |
|
1772 | self.stream.write('Accept this change? [n] ') | |
1773 | answer = sys.stdin.readline().strip() |
|
1773 | answer = sys.stdin.readline().strip() | |
1774 | if answer.lower() in ('y', 'yes'): |
|
1774 | if answer.lower() in ('y', 'yes'): | |
1775 | if test.path.endswith(b'.t'): |
|
1775 | if test.path.endswith(b'.t'): | |
1776 | rename(test.errpath, test.path) |
|
1776 | rename(test.errpath, test.path) | |
1777 | else: |
|
1777 | else: | |
1778 | rename(test.errpath, '%s.out' % test.path) |
|
1778 | rename(test.errpath, '%s.out' % test.path) | |
1779 | accepted = True |
|
1779 | accepted = True | |
1780 | if not accepted: |
|
1780 | if not accepted: | |
1781 | self.faildata[test.name] = b''.join(lines) |
|
1781 | self.faildata[test.name] = b''.join(lines) | |
1782 |
|
1782 | |||
1783 | return accepted |
|
1783 | return accepted | |
1784 |
|
1784 | |||
1785 | def startTest(self, test): |
|
1785 | def startTest(self, test): | |
1786 | super(TestResult, self).startTest(test) |
|
1786 | super(TestResult, self).startTest(test) | |
1787 |
|
1787 | |||
1788 | # os.times module computes the user time and system time spent by |
|
1788 | # os.times module computes the user time and system time spent by | |
1789 | # child's processes along with real elapsed time taken by a process. |
|
1789 | # child's processes along with real elapsed time taken by a process. | |
1790 | # This module has one limitation. It can only work for Linux user |
|
1790 | # This module has one limitation. It can only work for Linux user | |
1791 | # and not for Windows. |
|
1791 | # and not for Windows. | |
1792 | test.started = os.times() |
|
1792 | test.started = os.times() | |
1793 | if self._firststarttime is None: # thread racy but irrelevant |
|
1793 | if self._firststarttime is None: # thread racy but irrelevant | |
1794 | self._firststarttime = test.started[4] |
|
1794 | self._firststarttime = test.started[4] | |
1795 |
|
1795 | |||
1796 | def stopTest(self, test, interrupted=False): |
|
1796 | def stopTest(self, test, interrupted=False): | |
1797 | super(TestResult, self).stopTest(test) |
|
1797 | super(TestResult, self).stopTest(test) | |
1798 |
|
1798 | |||
1799 | test.stopped = os.times() |
|
1799 | test.stopped = os.times() | |
1800 |
|
1800 | |||
1801 | starttime = test.started |
|
1801 | starttime = test.started | |
1802 | endtime = test.stopped |
|
1802 | endtime = test.stopped | |
1803 | origin = self._firststarttime |
|
1803 | origin = self._firststarttime | |
1804 | self.times.append((test.name, |
|
1804 | self.times.append((test.name, | |
1805 | endtime[2] - starttime[2], # user space CPU time |
|
1805 | endtime[2] - starttime[2], # user space CPU time | |
1806 | endtime[3] - starttime[3], # sys space CPU time |
|
1806 | endtime[3] - starttime[3], # sys space CPU time | |
1807 | endtime[4] - starttime[4], # real time |
|
1807 | endtime[4] - starttime[4], # real time | |
1808 | starttime[4] - origin, # start date in run context |
|
1808 | starttime[4] - origin, # start date in run context | |
1809 | endtime[4] - origin, # end date in run context |
|
1809 | endtime[4] - origin, # end date in run context | |
1810 | )) |
|
1810 | )) | |
1811 |
|
1811 | |||
1812 | if interrupted: |
|
1812 | if interrupted: | |
1813 | with iolock: |
|
1813 | with iolock: | |
1814 | self.stream.writeln('INTERRUPTED: %s (after %d seconds)' % ( |
|
1814 | self.stream.writeln('INTERRUPTED: %s (after %d seconds)' % ( | |
1815 | test.name, self.times[-1][3])) |
|
1815 | test.name, self.times[-1][3])) | |
1816 |
|
1816 | |||
1817 | class TestSuite(unittest.TestSuite): |
|
1817 | class TestSuite(unittest.TestSuite): | |
1818 | """Custom unittest TestSuite that knows how to execute Mercurial tests.""" |
|
1818 | """Custom unittest TestSuite that knows how to execute Mercurial tests.""" | |
1819 |
|
1819 | |||
1820 | def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None, |
|
1820 | def __init__(self, testdir, jobs=1, whitelist=None, blacklist=None, | |
1821 | retest=False, keywords=None, loop=False, runs_per_test=1, |
|
1821 | retest=False, keywords=None, loop=False, runs_per_test=1, | |
1822 | loadtest=None, showchannels=False, |
|
1822 | loadtest=None, showchannels=False, | |
1823 | *args, **kwargs): |
|
1823 | *args, **kwargs): | |
1824 | """Create a new instance that can run tests with a configuration. |
|
1824 | """Create a new instance that can run tests with a configuration. | |
1825 |
|
1825 | |||
1826 | testdir specifies the directory where tests are executed from. This |
|
1826 | testdir specifies the directory where tests are executed from. This | |
1827 | is typically the ``tests`` directory from Mercurial's source |
|
1827 | is typically the ``tests`` directory from Mercurial's source | |
1828 | repository. |
|
1828 | repository. | |
1829 |
|
1829 | |||
1830 | jobs specifies the number of jobs to run concurrently. Each test |
|
1830 | jobs specifies the number of jobs to run concurrently. Each test | |
1831 | executes on its own thread. Tests actually spawn new processes, so |
|
1831 | executes on its own thread. Tests actually spawn new processes, so | |
1832 | state mutation should not be an issue. |
|
1832 | state mutation should not be an issue. | |
1833 |
|
1833 | |||
1834 | If there is only one job, it will use the main thread. |
|
1834 | If there is only one job, it will use the main thread. | |
1835 |
|
1835 | |||
1836 | whitelist and blacklist denote tests that have been whitelisted and |
|
1836 | whitelist and blacklist denote tests that have been whitelisted and | |
1837 | blacklisted, respectively. These arguments don't belong in TestSuite. |
|
1837 | blacklisted, respectively. These arguments don't belong in TestSuite. | |
1838 | Instead, whitelist and blacklist should be handled by the thing that |
|
1838 | Instead, whitelist and blacklist should be handled by the thing that | |
1839 | populates the TestSuite with tests. They are present to preserve |
|
1839 | populates the TestSuite with tests. They are present to preserve | |
1840 | backwards compatible behavior which reports skipped tests as part |
|
1840 | backwards compatible behavior which reports skipped tests as part | |
1841 | of the results. |
|
1841 | of the results. | |
1842 |
|
1842 | |||
1843 | retest denotes whether to retest failed tests. This arguably belongs |
|
1843 | retest denotes whether to retest failed tests. This arguably belongs | |
1844 | outside of TestSuite. |
|
1844 | outside of TestSuite. | |
1845 |
|
1845 | |||
1846 | keywords denotes key words that will be used to filter which tests |
|
1846 | keywords denotes key words that will be used to filter which tests | |
1847 | to execute. This arguably belongs outside of TestSuite. |
|
1847 | to execute. This arguably belongs outside of TestSuite. | |
1848 |
|
1848 | |||
1849 | loop denotes whether to loop over tests forever. |
|
1849 | loop denotes whether to loop over tests forever. | |
1850 | """ |
|
1850 | """ | |
1851 | super(TestSuite, self).__init__(*args, **kwargs) |
|
1851 | super(TestSuite, self).__init__(*args, **kwargs) | |
1852 |
|
1852 | |||
1853 | self._jobs = jobs |
|
1853 | self._jobs = jobs | |
1854 | self._whitelist = whitelist |
|
1854 | self._whitelist = whitelist | |
1855 | self._blacklist = blacklist |
|
1855 | self._blacklist = blacklist | |
1856 | self._retest = retest |
|
1856 | self._retest = retest | |
1857 | self._keywords = keywords |
|
1857 | self._keywords = keywords | |
1858 | self._loop = loop |
|
1858 | self._loop = loop | |
1859 | self._runs_per_test = runs_per_test |
|
1859 | self._runs_per_test = runs_per_test | |
1860 | self._loadtest = loadtest |
|
1860 | self._loadtest = loadtest | |
1861 | self._showchannels = showchannels |
|
1861 | self._showchannels = showchannels | |
1862 |
|
1862 | |||
1863 | def run(self, result): |
|
1863 | def run(self, result): | |
1864 | # We have a number of filters that need to be applied. We do this |
|
1864 | # We have a number of filters that need to be applied. We do this | |
1865 | # here instead of inside Test because it makes the running logic for |
|
1865 | # here instead of inside Test because it makes the running logic for | |
1866 | # Test simpler. |
|
1866 | # Test simpler. | |
1867 | tests = [] |
|
1867 | tests = [] | |
1868 | num_tests = [0] |
|
1868 | num_tests = [0] | |
1869 | for test in self._tests: |
|
1869 | for test in self._tests: | |
1870 | def get(): |
|
1870 | def get(): | |
1871 | num_tests[0] += 1 |
|
1871 | num_tests[0] += 1 | |
1872 | if getattr(test, 'should_reload', False): |
|
1872 | if getattr(test, 'should_reload', False): | |
1873 | return self._loadtest(test, num_tests[0]) |
|
1873 | return self._loadtest(test, num_tests[0]) | |
1874 | return test |
|
1874 | return test | |
1875 | if not os.path.exists(test.path): |
|
1875 | if not os.path.exists(test.path): | |
1876 | result.addSkip(test, "Doesn't exist") |
|
1876 | result.addSkip(test, "Doesn't exist") | |
1877 | continue |
|
1877 | continue | |
1878 |
|
1878 | |||
1879 | if not (self._whitelist and test.bname in self._whitelist): |
|
1879 | if not (self._whitelist and test.bname in self._whitelist): | |
1880 | if self._blacklist and test.bname in self._blacklist: |
|
1880 | if self._blacklist and test.bname in self._blacklist: | |
1881 | result.addSkip(test, 'blacklisted') |
|
1881 | result.addSkip(test, 'blacklisted') | |
1882 | continue |
|
1882 | continue | |
1883 |
|
1883 | |||
1884 | if self._retest and not os.path.exists(test.errpath): |
|
1884 | if self._retest and not os.path.exists(test.errpath): | |
1885 | result.addIgnore(test, 'not retesting') |
|
1885 | result.addIgnore(test, 'not retesting') | |
1886 | continue |
|
1886 | continue | |
1887 |
|
1887 | |||
1888 | if self._keywords: |
|
1888 | if self._keywords: | |
1889 | f = open(test.path, 'rb') |
|
1889 | f = open(test.path, 'rb') | |
1890 | t = f.read().lower() + test.bname.lower() |
|
1890 | t = f.read().lower() + test.bname.lower() | |
1891 | f.close() |
|
1891 | f.close() | |
1892 | ignored = False |
|
1892 | ignored = False | |
1893 | for k in self._keywords.lower().split(): |
|
1893 | for k in self._keywords.lower().split(): | |
1894 | if k not in t: |
|
1894 | if k not in t: | |
1895 | result.addIgnore(test, "doesn't match keyword") |
|
1895 | result.addIgnore(test, "doesn't match keyword") | |
1896 | ignored = True |
|
1896 | ignored = True | |
1897 | break |
|
1897 | break | |
1898 |
|
1898 | |||
1899 | if ignored: |
|
1899 | if ignored: | |
1900 | continue |
|
1900 | continue | |
1901 | for _ in xrange(self._runs_per_test): |
|
1901 | for _ in xrange(self._runs_per_test): | |
1902 | tests.append(get()) |
|
1902 | tests.append(get()) | |
1903 |
|
1903 | |||
1904 | runtests = list(tests) |
|
1904 | runtests = list(tests) | |
1905 | done = queue.Queue() |
|
1905 | done = queue.Queue() | |
1906 | running = 0 |
|
1906 | running = 0 | |
1907 |
|
1907 | |||
1908 | channels = [""] * self._jobs |
|
1908 | channels = [""] * self._jobs | |
1909 |
|
1909 | |||
1910 | def job(test, result): |
|
1910 | def job(test, result): | |
1911 | for n, v in enumerate(channels): |
|
1911 | for n, v in enumerate(channels): | |
1912 | if not v: |
|
1912 | if not v: | |
1913 | channel = n |
|
1913 | channel = n | |
1914 | break |
|
1914 | break | |
1915 | else: |
|
1915 | else: | |
1916 | raise ValueError('Could not find output channel') |
|
1916 | raise ValueError('Could not find output channel') | |
1917 | channels[channel] = "=" + test.name[5:].split(".")[0] |
|
1917 | channels[channel] = "=" + test.name[5:].split(".")[0] | |
1918 | try: |
|
1918 | try: | |
1919 | test(result) |
|
1919 | test(result) | |
1920 | done.put(None) |
|
1920 | done.put(None) | |
1921 | except KeyboardInterrupt: |
|
1921 | except KeyboardInterrupt: | |
1922 | pass |
|
1922 | pass | |
1923 | except: # re-raises |
|
1923 | except: # re-raises | |
1924 | done.put(('!', test, 'run-test raised an error, see traceback')) |
|
1924 | done.put(('!', test, 'run-test raised an error, see traceback')) | |
1925 | raise |
|
1925 | raise | |
1926 | finally: |
|
1926 | finally: | |
1927 | try: |
|
1927 | try: | |
1928 | channels[channel] = '' |
|
1928 | channels[channel] = '' | |
1929 | except IndexError: |
|
1929 | except IndexError: | |
1930 | pass |
|
1930 | pass | |
1931 |
|
1931 | |||
1932 | def stat(): |
|
1932 | def stat(): | |
1933 | count = 0 |
|
1933 | count = 0 | |
1934 | while channels: |
|
1934 | while channels: | |
1935 | d = '\n%03s ' % count |
|
1935 | d = '\n%03s ' % count | |
1936 | for n, v in enumerate(channels): |
|
1936 | for n, v in enumerate(channels): | |
1937 | if v: |
|
1937 | if v: | |
1938 | d += v[0] |
|
1938 | d += v[0] | |
1939 | channels[n] = v[1:] or '.' |
|
1939 | channels[n] = v[1:] or '.' | |
1940 | else: |
|
1940 | else: | |
1941 | d += ' ' |
|
1941 | d += ' ' | |
1942 | d += ' ' |
|
1942 | d += ' ' | |
1943 | with iolock: |
|
1943 | with iolock: | |
1944 | sys.stdout.write(d + ' ') |
|
1944 | sys.stdout.write(d + ' ') | |
1945 | sys.stdout.flush() |
|
1945 | sys.stdout.flush() | |
1946 | for x in xrange(10): |
|
1946 | for x in xrange(10): | |
1947 | if channels: |
|
1947 | if channels: | |
1948 | time.sleep(.1) |
|
1948 | time.sleep(.1) | |
1949 | count += 1 |
|
1949 | count += 1 | |
1950 |
|
1950 | |||
1951 | stoppedearly = False |
|
1951 | stoppedearly = False | |
1952 |
|
1952 | |||
1953 | if self._showchannels: |
|
1953 | if self._showchannels: | |
1954 | statthread = threading.Thread(target=stat, name="stat") |
|
1954 | statthread = threading.Thread(target=stat, name="stat") | |
1955 | statthread.start() |
|
1955 | statthread.start() | |
1956 |
|
1956 | |||
1957 | try: |
|
1957 | try: | |
1958 | while tests or running: |
|
1958 | while tests or running: | |
1959 | if not done.empty() or running == self._jobs or not tests: |
|
1959 | if not done.empty() or running == self._jobs or not tests: | |
1960 | try: |
|
1960 | try: | |
1961 | done.get(True, 1) |
|
1961 | done.get(True, 1) | |
1962 | running -= 1 |
|
1962 | running -= 1 | |
1963 | if result and result.shouldStop: |
|
1963 | if result and result.shouldStop: | |
1964 | stoppedearly = True |
|
1964 | stoppedearly = True | |
1965 | break |
|
1965 | break | |
1966 | except queue.Empty: |
|
1966 | except queue.Empty: | |
1967 | continue |
|
1967 | continue | |
1968 | if tests and not running == self._jobs: |
|
1968 | if tests and not running == self._jobs: | |
1969 | test = tests.pop(0) |
|
1969 | test = tests.pop(0) | |
1970 | if self._loop: |
|
1970 | if self._loop: | |
1971 | if getattr(test, 'should_reload', False): |
|
1971 | if getattr(test, 'should_reload', False): | |
1972 | num_tests[0] += 1 |
|
1972 | num_tests[0] += 1 | |
1973 | tests.append( |
|
1973 | tests.append( | |
1974 | self._loadtest(test, num_tests[0])) |
|
1974 | self._loadtest(test, num_tests[0])) | |
1975 | else: |
|
1975 | else: | |
1976 | tests.append(test) |
|
1976 | tests.append(test) | |
1977 | if self._jobs == 1: |
|
1977 | if self._jobs == 1: | |
1978 | job(test, result) |
|
1978 | job(test, result) | |
1979 | else: |
|
1979 | else: | |
1980 | t = threading.Thread(target=job, name=test.name, |
|
1980 | t = threading.Thread(target=job, name=test.name, | |
1981 | args=(test, result)) |
|
1981 | args=(test, result)) | |
1982 | t.start() |
|
1982 | t.start() | |
1983 | running += 1 |
|
1983 | running += 1 | |
1984 |
|
1984 | |||
1985 | # If we stop early we still need to wait on started tests to |
|
1985 | # If we stop early we still need to wait on started tests to | |
1986 | # finish. Otherwise, there is a race between the test completing |
|
1986 | # finish. Otherwise, there is a race between the test completing | |
1987 | # and the test's cleanup code running. This could result in the |
|
1987 | # and the test's cleanup code running. This could result in the | |
1988 | # test reporting incorrect. |
|
1988 | # test reporting incorrect. | |
1989 | if stoppedearly: |
|
1989 | if stoppedearly: | |
1990 | while running: |
|
1990 | while running: | |
1991 | try: |
|
1991 | try: | |
1992 | done.get(True, 1) |
|
1992 | done.get(True, 1) | |
1993 | running -= 1 |
|
1993 | running -= 1 | |
1994 | except queue.Empty: |
|
1994 | except queue.Empty: | |
1995 | continue |
|
1995 | continue | |
1996 | except KeyboardInterrupt: |
|
1996 | except KeyboardInterrupt: | |
1997 | for test in runtests: |
|
1997 | for test in runtests: | |
1998 | test.abort() |
|
1998 | test.abort() | |
1999 |
|
1999 | |||
2000 | channels = [] |
|
2000 | channels = [] | |
2001 |
|
2001 | |||
2002 | return result |
|
2002 | return result | |
2003 |
|
2003 | |||
2004 | # Save the most recent 5 wall-clock runtimes of each test to a |
|
2004 | # Save the most recent 5 wall-clock runtimes of each test to a | |
2005 | # human-readable text file named .testtimes. Tests are sorted |
|
2005 | # human-readable text file named .testtimes. Tests are sorted | |
2006 | # alphabetically, while times for each test are listed from oldest to |
|
2006 | # alphabetically, while times for each test are listed from oldest to | |
2007 | # newest. |
|
2007 | # newest. | |
2008 |
|
2008 | |||
2009 | def loadtimes(outputdir): |
|
2009 | def loadtimes(outputdir): | |
2010 | times = [] |
|
2010 | times = [] | |
2011 | try: |
|
2011 | try: | |
2012 | with open(os.path.join(outputdir, b'.testtimes-')) as fp: |
|
2012 | with open(os.path.join(outputdir, b'.testtimes-')) as fp: | |
2013 | for line in fp: |
|
2013 | for line in fp: | |
2014 | ts = line.split() |
|
2014 | ts = line.split() | |
2015 | times.append((ts[0], [float(t) for t in ts[1:]])) |
|
2015 | times.append((ts[0], [float(t) for t in ts[1:]])) | |
2016 | except IOError as err: |
|
2016 | except IOError as err: | |
2017 | if err.errno != errno.ENOENT: |
|
2017 | if err.errno != errno.ENOENT: | |
2018 | raise |
|
2018 | raise | |
2019 | return times |
|
2019 | return times | |
2020 |
|
2020 | |||
2021 | def savetimes(outputdir, result): |
|
2021 | def savetimes(outputdir, result): | |
2022 | saved = dict(loadtimes(outputdir)) |
|
2022 | saved = dict(loadtimes(outputdir)) | |
2023 | maxruns = 5 |
|
2023 | maxruns = 5 | |
2024 | skipped = set([str(t[0]) for t in result.skipped]) |
|
2024 | skipped = set([str(t[0]) for t in result.skipped]) | |
2025 | for tdata in result.times: |
|
2025 | for tdata in result.times: | |
2026 | test, real = tdata[0], tdata[3] |
|
2026 | test, real = tdata[0], tdata[3] | |
2027 | if test not in skipped: |
|
2027 | if test not in skipped: | |
2028 | ts = saved.setdefault(test, []) |
|
2028 | ts = saved.setdefault(test, []) | |
2029 | ts.append(real) |
|
2029 | ts.append(real) | |
2030 | ts[:] = ts[-maxruns:] |
|
2030 | ts[:] = ts[-maxruns:] | |
2031 |
|
2031 | |||
2032 | fd, tmpname = tempfile.mkstemp(prefix=b'.testtimes', |
|
2032 | fd, tmpname = tempfile.mkstemp(prefix=b'.testtimes', | |
2033 | dir=outputdir, text=True) |
|
2033 | dir=outputdir, text=True) | |
2034 | with os.fdopen(fd, 'w') as fp: |
|
2034 | with os.fdopen(fd, 'w') as fp: | |
2035 | for name, ts in sorted(saved.items()): |
|
2035 | for name, ts in sorted(saved.items()): | |
2036 | fp.write('%s %s\n' % (name, ' '.join(['%.3f' % (t,) for t in ts]))) |
|
2036 | fp.write('%s %s\n' % (name, ' '.join(['%.3f' % (t,) for t in ts]))) | |
2037 | timepath = os.path.join(outputdir, b'.testtimes') |
|
2037 | timepath = os.path.join(outputdir, b'.testtimes') | |
2038 | try: |
|
2038 | try: | |
2039 | os.unlink(timepath) |
|
2039 | os.unlink(timepath) | |
2040 | except OSError: |
|
2040 | except OSError: | |
2041 | pass |
|
2041 | pass | |
2042 | try: |
|
2042 | try: | |
2043 | os.rename(tmpname, timepath) |
|
2043 | os.rename(tmpname, timepath) | |
2044 | except OSError: |
|
2044 | except OSError: | |
2045 | pass |
|
2045 | pass | |
2046 |
|
2046 | |||
2047 | class TextTestRunner(unittest.TextTestRunner): |
|
2047 | class TextTestRunner(unittest.TextTestRunner): | |
2048 | """Custom unittest test runner that uses appropriate settings.""" |
|
2048 | """Custom unittest test runner that uses appropriate settings.""" | |
2049 |
|
2049 | |||
2050 | def __init__(self, runner, *args, **kwargs): |
|
2050 | def __init__(self, runner, *args, **kwargs): | |
2051 | super(TextTestRunner, self).__init__(*args, **kwargs) |
|
2051 | super(TextTestRunner, self).__init__(*args, **kwargs) | |
2052 |
|
2052 | |||
2053 | self._runner = runner |
|
2053 | self._runner = runner | |
2054 |
|
2054 | |||
2055 | def listtests(self, test): |
|
2055 | def listtests(self, test): | |
2056 | result = TestResult(self._runner.options, self.stream, |
|
2056 | result = TestResult(self._runner.options, self.stream, | |
2057 | self.descriptions, 0) |
|
2057 | self.descriptions, 0) | |
2058 | test = sorted(test, key=lambda t: t.name) |
|
2058 | test = sorted(test, key=lambda t: t.name) | |
2059 | for t in test: |
|
2059 | for t in test: | |
2060 | print(t.name) |
|
2060 | print(t.name) | |
2061 | result.addSuccess(t) |
|
2061 | result.addSuccess(t) | |
2062 |
|
2062 | |||
2063 | if self._runner.options.xunit: |
|
2063 | if self._runner.options.xunit: | |
2064 | with open(self._runner.options.xunit, "wb") as xuf: |
|
2064 | with open(self._runner.options.xunit, "wb") as xuf: | |
2065 | self._writexunit(result, xuf) |
|
2065 | self._writexunit(result, xuf) | |
2066 |
|
2066 | |||
2067 | if self._runner.options.json: |
|
2067 | if self._runner.options.json: | |
2068 | jsonpath = os.path.join(self._runner._outputdir, b'report.json') |
|
2068 | jsonpath = os.path.join(self._runner._outputdir, b'report.json') | |
2069 | with open(jsonpath, 'w') as fp: |
|
2069 | with open(jsonpath, 'w') as fp: | |
2070 | self._writejson(result, fp) |
|
2070 | self._writejson(result, fp) | |
2071 |
|
2071 | |||
2072 | return result |
|
2072 | return result | |
2073 |
|
2073 | |||
2074 | def run(self, test): |
|
2074 | def run(self, test): | |
2075 | result = TestResult(self._runner.options, self.stream, |
|
2075 | result = TestResult(self._runner.options, self.stream, | |
2076 | self.descriptions, self.verbosity) |
|
2076 | self.descriptions, self.verbosity) | |
2077 |
|
2077 | |||
2078 | test(result) |
|
2078 | test(result) | |
2079 |
|
2079 | |||
2080 | failed = len(result.failures) |
|
2080 | failed = len(result.failures) | |
2081 | skipped = len(result.skipped) |
|
2081 | skipped = len(result.skipped) | |
2082 | ignored = len(result.ignored) |
|
2082 | ignored = len(result.ignored) | |
2083 |
|
2083 | |||
2084 | with iolock: |
|
2084 | with iolock: | |
2085 | self.stream.writeln('') |
|
2085 | self.stream.writeln('') | |
2086 |
|
2086 | |||
2087 | if not self._runner.options.noskips: |
|
2087 | if not self._runner.options.noskips: | |
2088 | for test, msg in result.skipped: |
|
2088 | for test, msg in result.skipped: | |
2089 | formatted = 'Skipped %s: %s\n' % (test.name, msg) |
|
2089 | formatted = 'Skipped %s: %s\n' % (test.name, msg) | |
2090 | self.stream.write(highlightmsg(formatted, result.color)) |
|
2090 | self.stream.write(highlightmsg(formatted, result.color)) | |
2091 | for test, msg in result.failures: |
|
2091 | for test, msg in result.failures: | |
2092 | formatted = 'Failed %s: %s\n' % (test.name, msg) |
|
2092 | formatted = 'Failed %s: %s\n' % (test.name, msg) | |
2093 | self.stream.write(highlightmsg(formatted, result.color)) |
|
2093 | self.stream.write(highlightmsg(formatted, result.color)) | |
2094 | for test, msg in result.errors: |
|
2094 | for test, msg in result.errors: | |
2095 | self.stream.writeln('Errored %s: %s' % (test.name, msg)) |
|
2095 | self.stream.writeln('Errored %s: %s' % (test.name, msg)) | |
2096 |
|
2096 | |||
2097 | if self._runner.options.xunit: |
|
2097 | if self._runner.options.xunit: | |
2098 | with open(self._runner.options.xunit, "wb") as xuf: |
|
2098 | with open(self._runner.options.xunit, "wb") as xuf: | |
2099 | self._writexunit(result, xuf) |
|
2099 | self._writexunit(result, xuf) | |
2100 |
|
2100 | |||
2101 | if self._runner.options.json: |
|
2101 | if self._runner.options.json: | |
2102 | jsonpath = os.path.join(self._runner._outputdir, b'report.json') |
|
2102 | jsonpath = os.path.join(self._runner._outputdir, b'report.json') | |
2103 | with open(jsonpath, 'w') as fp: |
|
2103 | with open(jsonpath, 'w') as fp: | |
2104 | self._writejson(result, fp) |
|
2104 | self._writejson(result, fp) | |
2105 |
|
2105 | |||
2106 | self._runner._checkhglib('Tested') |
|
2106 | self._runner._checkhglib('Tested') | |
2107 |
|
2107 | |||
2108 | savetimes(self._runner._outputdir, result) |
|
2108 | savetimes(self._runner._outputdir, result) | |
2109 |
|
2109 | |||
2110 | if failed and self._runner.options.known_good_rev: |
|
2110 | if failed and self._runner.options.known_good_rev: | |
2111 | self._bisecttests(t for t, m in result.failures) |
|
2111 | self._bisecttests(t for t, m in result.failures) | |
2112 | self.stream.writeln( |
|
2112 | self.stream.writeln( | |
2113 | '# Ran %d tests, %d skipped, %d failed.' |
|
2113 | '# Ran %d tests, %d skipped, %d failed.' | |
2114 | % (result.testsRun, skipped + ignored, failed)) |
|
2114 | % (result.testsRun, skipped + ignored, failed)) | |
2115 | if failed: |
|
2115 | if failed: | |
2116 | self.stream.writeln('python hash seed: %s' % |
|
2116 | self.stream.writeln('python hash seed: %s' % | |
2117 | os.environ['PYTHONHASHSEED']) |
|
2117 | os.environ['PYTHONHASHSEED']) | |
2118 | if self._runner.options.time: |
|
2118 | if self._runner.options.time: | |
2119 | self.printtimes(result.times) |
|
2119 | self.printtimes(result.times) | |
2120 |
|
2120 | |||
2121 | if self._runner.options.exceptions: |
|
2121 | if self._runner.options.exceptions: | |
2122 | exceptions = aggregateexceptions( |
|
2122 | exceptions = aggregateexceptions( | |
2123 | os.path.join(self._runner._outputdir, b'exceptions')) |
|
2123 | os.path.join(self._runner._outputdir, b'exceptions')) | |
2124 | total = sum(exceptions.values()) |
|
2124 | total = sum(exceptions.values()) | |
2125 |
|
2125 | |||
2126 | self.stream.writeln('Exceptions Report:') |
|
2126 | self.stream.writeln('Exceptions Report:') | |
2127 | self.stream.writeln('%d total from %d frames' % |
|
2127 | self.stream.writeln('%d total from %d frames' % | |
2128 | (total, len(exceptions))) |
|
2128 | (total, len(exceptions))) | |
2129 | for (frame, line, exc), count in exceptions.most_common(): |
|
2129 | for (frame, line, exc), count in exceptions.most_common(): | |
2130 | self.stream.writeln('%d\t%s: %s' % (count, frame, exc)) |
|
2130 | self.stream.writeln('%d\t%s: %s' % (count, frame, exc)) | |
2131 |
|
2131 | |||
2132 | self.stream.flush() |
|
2132 | self.stream.flush() | |
2133 |
|
2133 | |||
2134 | return result |
|
2134 | return result | |
2135 |
|
2135 | |||
2136 | def _bisecttests(self, tests): |
|
2136 | def _bisecttests(self, tests): | |
2137 | bisectcmd = ['hg', 'bisect'] |
|
2137 | bisectcmd = ['hg', 'bisect'] | |
2138 | bisectrepo = self._runner.options.bisect_repo |
|
2138 | bisectrepo = self._runner.options.bisect_repo | |
2139 | if bisectrepo: |
|
2139 | if bisectrepo: | |
2140 | bisectcmd.extend(['-R', os.path.abspath(bisectrepo)]) |
|
2140 | bisectcmd.extend(['-R', os.path.abspath(bisectrepo)]) | |
2141 | def pread(args): |
|
2141 | def pread(args): | |
2142 | env = os.environ.copy() |
|
2142 | env = os.environ.copy() | |
2143 | env['HGPLAIN'] = '1' |
|
2143 | env['HGPLAIN'] = '1' | |
2144 | p = subprocess.Popen(args, stderr=subprocess.STDOUT, |
|
2144 | p = subprocess.Popen(args, stderr=subprocess.STDOUT, | |
2145 | stdout=subprocess.PIPE, env=env) |
|
2145 | stdout=subprocess.PIPE, env=env) | |
2146 | data = p.stdout.read() |
|
2146 | data = p.stdout.read() | |
2147 | p.wait() |
|
2147 | p.wait() | |
2148 | return data |
|
2148 | return data | |
2149 | for test in tests: |
|
2149 | for test in tests: | |
2150 | pread(bisectcmd + ['--reset']), |
|
2150 | pread(bisectcmd + ['--reset']), | |
2151 | pread(bisectcmd + ['--bad', '.']) |
|
2151 | pread(bisectcmd + ['--bad', '.']) | |
2152 | pread(bisectcmd + ['--good', self._runner.options.known_good_rev]) |
|
2152 | pread(bisectcmd + ['--good', self._runner.options.known_good_rev]) | |
2153 | # TODO: we probably need to forward more options |
|
2153 | # TODO: we probably need to forward more options | |
2154 | # that alter hg's behavior inside the tests. |
|
2154 | # that alter hg's behavior inside the tests. | |
2155 | opts = '' |
|
2155 | opts = '' | |
2156 | withhg = self._runner.options.with_hg |
|
2156 | withhg = self._runner.options.with_hg | |
2157 | if withhg: |
|
2157 | if withhg: | |
2158 | opts += ' --with-hg=%s ' % shellquote(_strpath(withhg)) |
|
2158 | opts += ' --with-hg=%s ' % shellquote(_strpath(withhg)) | |
2159 | rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts, |
|
2159 | rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts, | |
2160 | test) |
|
2160 | test) | |
2161 | data = pread(bisectcmd + ['--command', rtc]) |
|
2161 | data = pread(bisectcmd + ['--command', rtc]) | |
2162 | m = re.search( |
|
2162 | m = re.search( | |
2163 | (br'\nThe first (?P<goodbad>bad|good) revision ' |
|
2163 | (br'\nThe first (?P<goodbad>bad|good) revision ' | |
2164 | br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n' |
|
2164 | br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n' | |
2165 | br'summary: +(?P<summary>[^\n]+)\n'), |
|
2165 | br'summary: +(?P<summary>[^\n]+)\n'), | |
2166 | data, (re.MULTILINE | re.DOTALL)) |
|
2166 | data, (re.MULTILINE | re.DOTALL)) | |
2167 | if m is None: |
|
2167 | if m is None: | |
2168 | self.stream.writeln( |
|
2168 | self.stream.writeln( | |
2169 | 'Failed to identify failure point for %s' % test) |
|
2169 | 'Failed to identify failure point for %s' % test) | |
2170 | continue |
|
2170 | continue | |
2171 | dat = m.groupdict() |
|
2171 | dat = m.groupdict() | |
2172 | verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed' |
|
2172 | verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed' | |
2173 | self.stream.writeln( |
|
2173 | self.stream.writeln( | |
2174 | '%s %s by %s (%s)' % ( |
|
2174 | '%s %s by %s (%s)' % ( | |
2175 | test, verb, dat['node'], dat['summary'])) |
|
2175 | test, verb, dat['node'], dat['summary'])) | |
2176 |
|
2176 | |||
2177 | def printtimes(self, times): |
|
2177 | def printtimes(self, times): | |
2178 | # iolock held by run |
|
2178 | # iolock held by run | |
2179 | self.stream.writeln('# Producing time report') |
|
2179 | self.stream.writeln('# Producing time report') | |
2180 | times.sort(key=lambda t: (t[3])) |
|
2180 | times.sort(key=lambda t: (t[3])) | |
2181 | cols = '%7.3f %7.3f %7.3f %7.3f %7.3f %s' |
|
2181 | cols = '%7.3f %7.3f %7.3f %7.3f %7.3f %s' | |
2182 | self.stream.writeln('%-7s %-7s %-7s %-7s %-7s %s' % |
|
2182 | self.stream.writeln('%-7s %-7s %-7s %-7s %-7s %s' % | |
2183 | ('start', 'end', 'cuser', 'csys', 'real', 'Test')) |
|
2183 | ('start', 'end', 'cuser', 'csys', 'real', 'Test')) | |
2184 | for tdata in times: |
|
2184 | for tdata in times: | |
2185 | test = tdata[0] |
|
2185 | test = tdata[0] | |
2186 | cuser, csys, real, start, end = tdata[1:6] |
|
2186 | cuser, csys, real, start, end = tdata[1:6] | |
2187 | self.stream.writeln(cols % (start, end, cuser, csys, real, test)) |
|
2187 | self.stream.writeln(cols % (start, end, cuser, csys, real, test)) | |
2188 |
|
2188 | |||
2189 | @staticmethod |
|
2189 | @staticmethod | |
2190 | def _writexunit(result, outf): |
|
2190 | def _writexunit(result, outf): | |
2191 | # See http://llg.cubic.org/docs/junit/ for a reference. |
|
2191 | # See http://llg.cubic.org/docs/junit/ for a reference. | |
2192 | timesd = dict((t[0], t[3]) for t in result.times) |
|
2192 | timesd = dict((t[0], t[3]) for t in result.times) | |
2193 | doc = minidom.Document() |
|
2193 | doc = minidom.Document() | |
2194 | s = doc.createElement('testsuite') |
|
2194 | s = doc.createElement('testsuite') | |
2195 | s.setAttribute('name', 'run-tests') |
|
2195 | s.setAttribute('name', 'run-tests') | |
2196 | s.setAttribute('tests', str(result.testsRun)) |
|
2196 | s.setAttribute('tests', str(result.testsRun)) | |
2197 | s.setAttribute('errors', "0") # TODO |
|
2197 | s.setAttribute('errors', "0") # TODO | |
2198 | s.setAttribute('failures', str(len(result.failures))) |
|
2198 | s.setAttribute('failures', str(len(result.failures))) | |
2199 | s.setAttribute('skipped', str(len(result.skipped) + |
|
2199 | s.setAttribute('skipped', str(len(result.skipped) + | |
2200 | len(result.ignored))) |
|
2200 | len(result.ignored))) | |
2201 | doc.appendChild(s) |
|
2201 | doc.appendChild(s) | |
2202 | for tc in result.successes: |
|
2202 | for tc in result.successes: | |
2203 | t = doc.createElement('testcase') |
|
2203 | t = doc.createElement('testcase') | |
2204 | t.setAttribute('name', tc.name) |
|
2204 | t.setAttribute('name', tc.name) | |
2205 | tctime = timesd.get(tc.name) |
|
2205 | tctime = timesd.get(tc.name) | |
2206 | if tctime is not None: |
|
2206 | if tctime is not None: | |
2207 | t.setAttribute('time', '%.3f' % tctime) |
|
2207 | t.setAttribute('time', '%.3f' % tctime) | |
2208 | s.appendChild(t) |
|
2208 | s.appendChild(t) | |
2209 | for tc, err in sorted(result.faildata.items()): |
|
2209 | for tc, err in sorted(result.faildata.items()): | |
2210 | t = doc.createElement('testcase') |
|
2210 | t = doc.createElement('testcase') | |
2211 | t.setAttribute('name', tc) |
|
2211 | t.setAttribute('name', tc) | |
2212 | tctime = timesd.get(tc) |
|
2212 | tctime = timesd.get(tc) | |
2213 | if tctime is not None: |
|
2213 | if tctime is not None: | |
2214 | t.setAttribute('time', '%.3f' % tctime) |
|
2214 | t.setAttribute('time', '%.3f' % tctime) | |
2215 | # createCDATASection expects a unicode or it will |
|
2215 | # createCDATASection expects a unicode or it will | |
2216 | # convert using default conversion rules, which will |
|
2216 | # convert using default conversion rules, which will | |
2217 | # fail if string isn't ASCII. |
|
2217 | # fail if string isn't ASCII. | |
2218 | err = cdatasafe(err).decode('utf-8', 'replace') |
|
2218 | err = cdatasafe(err).decode('utf-8', 'replace') | |
2219 | cd = doc.createCDATASection(err) |
|
2219 | cd = doc.createCDATASection(err) | |
2220 | # Use 'failure' here instead of 'error' to match errors = 0, |
|
2220 | # Use 'failure' here instead of 'error' to match errors = 0, | |
2221 | # failures = len(result.failures) in the testsuite element. |
|
2221 | # failures = len(result.failures) in the testsuite element. | |
2222 | failelem = doc.createElement('failure') |
|
2222 | failelem = doc.createElement('failure') | |
2223 | failelem.setAttribute('message', 'output changed') |
|
2223 | failelem.setAttribute('message', 'output changed') | |
2224 | failelem.setAttribute('type', 'output-mismatch') |
|
2224 | failelem.setAttribute('type', 'output-mismatch') | |
2225 | failelem.appendChild(cd) |
|
2225 | failelem.appendChild(cd) | |
2226 | t.appendChild(failelem) |
|
2226 | t.appendChild(failelem) | |
2227 | s.appendChild(t) |
|
2227 | s.appendChild(t) | |
2228 | for tc, message in result.skipped: |
|
2228 | for tc, message in result.skipped: | |
2229 | # According to the schema, 'skipped' has no attributes. So store |
|
2229 | # According to the schema, 'skipped' has no attributes. So store | |
2230 | # the skip message as a text node instead. |
|
2230 | # the skip message as a text node instead. | |
2231 | t = doc.createElement('testcase') |
|
2231 | t = doc.createElement('testcase') | |
2232 | t.setAttribute('name', tc.name) |
|
2232 | t.setAttribute('name', tc.name) | |
2233 | binmessage = message.encode('utf-8') |
|
2233 | binmessage = message.encode('utf-8') | |
2234 | message = cdatasafe(binmessage).decode('utf-8', 'replace') |
|
2234 | message = cdatasafe(binmessage).decode('utf-8', 'replace') | |
2235 | cd = doc.createCDATASection(message) |
|
2235 | cd = doc.createCDATASection(message) | |
2236 | skipelem = doc.createElement('skipped') |
|
2236 | skipelem = doc.createElement('skipped') | |
2237 | skipelem.appendChild(cd) |
|
2237 | skipelem.appendChild(cd) | |
2238 | t.appendChild(skipelem) |
|
2238 | t.appendChild(skipelem) | |
2239 | s.appendChild(t) |
|
2239 | s.appendChild(t) | |
2240 | outf.write(doc.toprettyxml(indent=' ', encoding='utf-8')) |
|
2240 | outf.write(doc.toprettyxml(indent=' ', encoding='utf-8')) | |
2241 |
|
2241 | |||
2242 | @staticmethod |
|
2242 | @staticmethod | |
2243 | def _writejson(result, outf): |
|
2243 | def _writejson(result, outf): | |
2244 | timesd = {} |
|
2244 | timesd = {} | |
2245 | for tdata in result.times: |
|
2245 | for tdata in result.times: | |
2246 | test = tdata[0] |
|
2246 | test = tdata[0] | |
2247 | timesd[test] = tdata[1:] |
|
2247 | timesd[test] = tdata[1:] | |
2248 |
|
2248 | |||
2249 | outcome = {} |
|
2249 | outcome = {} | |
2250 | groups = [('success', ((tc, None) |
|
2250 | groups = [('success', ((tc, None) | |
2251 | for tc in result.successes)), |
|
2251 | for tc in result.successes)), | |
2252 | ('failure', result.failures), |
|
2252 | ('failure', result.failures), | |
2253 | ('skip', result.skipped)] |
|
2253 | ('skip', result.skipped)] | |
2254 | for res, testcases in groups: |
|
2254 | for res, testcases in groups: | |
2255 | for tc, __ in testcases: |
|
2255 | for tc, __ in testcases: | |
2256 | if tc.name in timesd: |
|
2256 | if tc.name in timesd: | |
2257 | diff = result.faildata.get(tc.name, b'') |
|
2257 | diff = result.faildata.get(tc.name, b'') | |
2258 | try: |
|
2258 | try: | |
2259 | diff = diff.decode('unicode_escape') |
|
2259 | diff = diff.decode('unicode_escape') | |
2260 | except UnicodeDecodeError as e: |
|
2260 | except UnicodeDecodeError as e: | |
2261 | diff = '%r decoding diff, sorry' % e |
|
2261 | diff = '%r decoding diff, sorry' % e | |
2262 | tres = {'result': res, |
|
2262 | tres = {'result': res, | |
2263 | 'time': ('%0.3f' % timesd[tc.name][2]), |
|
2263 | 'time': ('%0.3f' % timesd[tc.name][2]), | |
2264 | 'cuser': ('%0.3f' % timesd[tc.name][0]), |
|
2264 | 'cuser': ('%0.3f' % timesd[tc.name][0]), | |
2265 | 'csys': ('%0.3f' % timesd[tc.name][1]), |
|
2265 | 'csys': ('%0.3f' % timesd[tc.name][1]), | |
2266 | 'start': ('%0.3f' % timesd[tc.name][3]), |
|
2266 | 'start': ('%0.3f' % timesd[tc.name][3]), | |
2267 | 'end': ('%0.3f' % timesd[tc.name][4]), |
|
2267 | 'end': ('%0.3f' % timesd[tc.name][4]), | |
2268 | 'diff': diff, |
|
2268 | 'diff': diff, | |
2269 | } |
|
2269 | } | |
2270 | else: |
|
2270 | else: | |
2271 | # blacklisted test |
|
2271 | # blacklisted test | |
2272 | tres = {'result': res} |
|
2272 | tres = {'result': res} | |
2273 |
|
2273 | |||
2274 | outcome[tc.name] = tres |
|
2274 | outcome[tc.name] = tres | |
2275 | jsonout = json.dumps(outcome, sort_keys=True, indent=4, |
|
2275 | jsonout = json.dumps(outcome, sort_keys=True, indent=4, | |
2276 | separators=(',', ': ')) |
|
2276 | separators=(',', ': ')) | |
2277 | outf.writelines(("testreport =", jsonout)) |
|
2277 | outf.writelines(("testreport =", jsonout)) | |
2278 |
|
2278 | |||
2279 | class TestRunner(object): |
|
2279 | class TestRunner(object): | |
2280 | """Holds context for executing tests. |
|
2280 | """Holds context for executing tests. | |
2281 |
|
2281 | |||
2282 | Tests rely on a lot of state. This object holds it for them. |
|
2282 | Tests rely on a lot of state. This object holds it for them. | |
2283 | """ |
|
2283 | """ | |
2284 |
|
2284 | |||
2285 | # Programs required to run tests. |
|
2285 | # Programs required to run tests. | |
2286 | REQUIREDTOOLS = [ |
|
2286 | REQUIREDTOOLS = [ | |
2287 | b'diff', |
|
2287 | b'diff', | |
2288 | b'grep', |
|
2288 | b'grep', | |
2289 | b'unzip', |
|
2289 | b'unzip', | |
2290 | b'gunzip', |
|
2290 | b'gunzip', | |
2291 | b'bunzip2', |
|
2291 | b'bunzip2', | |
2292 | b'sed', |
|
2292 | b'sed', | |
2293 | ] |
|
2293 | ] | |
2294 |
|
2294 | |||
2295 | # Maps file extensions to test class. |
|
2295 | # Maps file extensions to test class. | |
2296 | TESTTYPES = [ |
|
2296 | TESTTYPES = [ | |
2297 | (b'.py', PythonTest), |
|
2297 | (b'.py', PythonTest), | |
2298 | (b'.t', TTest), |
|
2298 | (b'.t', TTest), | |
2299 | ] |
|
2299 | ] | |
2300 |
|
2300 | |||
2301 | def __init__(self): |
|
2301 | def __init__(self): | |
2302 | self.options = None |
|
2302 | self.options = None | |
2303 | self._hgroot = None |
|
2303 | self._hgroot = None | |
2304 | self._testdir = None |
|
2304 | self._testdir = None | |
2305 | self._outputdir = None |
|
2305 | self._outputdir = None | |
2306 | self._hgtmp = None |
|
2306 | self._hgtmp = None | |
2307 | self._installdir = None |
|
2307 | self._installdir = None | |
2308 | self._bindir = None |
|
2308 | self._bindir = None | |
2309 | self._tmpbinddir = None |
|
2309 | self._tmpbinddir = None | |
2310 | self._pythondir = None |
|
2310 | self._pythondir = None | |
2311 | self._coveragefile = None |
|
2311 | self._coveragefile = None | |
2312 | self._createdfiles = [] |
|
2312 | self._createdfiles = [] | |
2313 | self._hgcommand = None |
|
2313 | self._hgcommand = None | |
2314 | self._hgpath = None |
|
2314 | self._hgpath = None | |
2315 | self._portoffset = 0 |
|
2315 | self._portoffset = 0 | |
2316 | self._ports = {} |
|
2316 | self._ports = {} | |
2317 |
|
2317 | |||
2318 | def run(self, args, parser=None): |
|
2318 | def run(self, args, parser=None): | |
2319 | """Run the test suite.""" |
|
2319 | """Run the test suite.""" | |
2320 | oldmask = os.umask(0o22) |
|
2320 | oldmask = os.umask(0o22) | |
2321 | try: |
|
2321 | try: | |
2322 | parser = parser or getparser() |
|
2322 | parser = parser or getparser() | |
2323 | options = parseargs(args, parser) |
|
2323 | options = parseargs(args, parser) | |
2324 | tests = [_bytespath(a) for a in options.tests] |
|
2324 | tests = [_bytespath(a) for a in options.tests] | |
2325 | if options.test_list is not None: |
|
2325 | if options.test_list is not None: | |
2326 | for listfile in options.test_list: |
|
2326 | for listfile in options.test_list: | |
2327 | with open(listfile, 'rb') as f: |
|
2327 | with open(listfile, 'rb') as f: | |
2328 | tests.extend(t for t in f.read().splitlines() if t) |
|
2328 | tests.extend(t for t in f.read().splitlines() if t) | |
2329 | self.options = options |
|
2329 | self.options = options | |
2330 |
|
2330 | |||
2331 | self._checktools() |
|
2331 | self._checktools() | |
2332 | testdescs = self.findtests(tests) |
|
2332 | testdescs = self.findtests(tests) | |
2333 | if options.profile_runner: |
|
2333 | if options.profile_runner: | |
2334 | import statprof |
|
2334 | import statprof | |
2335 | statprof.start() |
|
2335 | statprof.start() | |
2336 | result = self._run(testdescs) |
|
2336 | result = self._run(testdescs) | |
2337 | if options.profile_runner: |
|
2337 | if options.profile_runner: | |
2338 | statprof.stop() |
|
2338 | statprof.stop() | |
2339 | statprof.display() |
|
2339 | statprof.display() | |
2340 | return result |
|
2340 | return result | |
2341 |
|
2341 | |||
2342 | finally: |
|
2342 | finally: | |
2343 | os.umask(oldmask) |
|
2343 | os.umask(oldmask) | |
2344 |
|
2344 | |||
2345 | def _run(self, testdescs): |
|
2345 | def _run(self, testdescs): | |
2346 | if self.options.random: |
|
2346 | if self.options.random: | |
2347 | random.shuffle(testdescs) |
|
2347 | random.shuffle(testdescs) | |
2348 | else: |
|
2348 | else: | |
2349 | # keywords for slow tests |
|
2349 | # keywords for slow tests | |
2350 | slow = {b'svn': 10, |
|
2350 | slow = {b'svn': 10, | |
2351 | b'cvs': 10, |
|
2351 | b'cvs': 10, | |
2352 | b'hghave': 10, |
|
2352 | b'hghave': 10, | |
2353 | b'largefiles-update': 10, |
|
2353 | b'largefiles-update': 10, | |
2354 | b'run-tests': 10, |
|
2354 | b'run-tests': 10, | |
2355 | b'corruption': 10, |
|
2355 | b'corruption': 10, | |
2356 | b'race': 10, |
|
2356 | b'race': 10, | |
2357 | b'i18n': 10, |
|
2357 | b'i18n': 10, | |
2358 | b'check': 100, |
|
2358 | b'check': 100, | |
2359 | b'gendoc': 100, |
|
2359 | b'gendoc': 100, | |
2360 | b'contrib-perf': 200, |
|
2360 | b'contrib-perf': 200, | |
2361 | } |
|
2361 | } | |
2362 | perf = {} |
|
2362 | perf = {} | |
2363 | def sortkey(f): |
|
2363 | def sortkey(f): | |
2364 | # run largest tests first, as they tend to take the longest |
|
2364 | # run largest tests first, as they tend to take the longest | |
2365 | f = f['path'] |
|
2365 | f = f['path'] | |
2366 | try: |
|
2366 | try: | |
2367 | return perf[f] |
|
2367 | return perf[f] | |
2368 | except KeyError: |
|
2368 | except KeyError: | |
2369 | try: |
|
2369 | try: | |
2370 | val = -os.stat(f).st_size |
|
2370 | val = -os.stat(f).st_size | |
2371 | except OSError as e: |
|
2371 | except OSError as e: | |
2372 | if e.errno != errno.ENOENT: |
|
2372 | if e.errno != errno.ENOENT: | |
2373 | raise |
|
2373 | raise | |
2374 | perf[f] = -1e9 # file does not exist, tell early |
|
2374 | perf[f] = -1e9 # file does not exist, tell early | |
2375 | return -1e9 |
|
2375 | return -1e9 | |
2376 | for kw, mul in slow.items(): |
|
2376 | for kw, mul in slow.items(): | |
2377 | if kw in f: |
|
2377 | if kw in f: | |
2378 | val *= mul |
|
2378 | val *= mul | |
2379 | if f.endswith(b'.py'): |
|
2379 | if f.endswith(b'.py'): | |
2380 | val /= 10.0 |
|
2380 | val /= 10.0 | |
2381 | perf[f] = val / 1000.0 |
|
2381 | perf[f] = val / 1000.0 | |
2382 | return perf[f] |
|
2382 | return perf[f] | |
2383 | testdescs.sort(key=sortkey) |
|
2383 | testdescs.sort(key=sortkey) | |
2384 |
|
2384 | |||
2385 | self._testdir = osenvironb[b'TESTDIR'] = getattr( |
|
2385 | self._testdir = osenvironb[b'TESTDIR'] = getattr( | |
2386 | os, 'getcwdb', os.getcwd)() |
|
2386 | os, 'getcwdb', os.getcwd)() | |
2387 | # assume all tests in same folder for now |
|
2387 | # assume all tests in same folder for now | |
2388 | if testdescs: |
|
2388 | if testdescs: | |
2389 | pathname = os.path.dirname(testdescs[0]['path']) |
|
2389 | pathname = os.path.dirname(testdescs[0]['path']) | |
2390 | if pathname: |
|
2390 | if pathname: | |
2391 | osenvironb[b'TESTDIR'] = os.path.join(osenvironb[b'TESTDIR'], |
|
2391 | osenvironb[b'TESTDIR'] = os.path.join(osenvironb[b'TESTDIR'], | |
2392 | pathname) |
|
2392 | pathname) | |
2393 | if self.options.outputdir: |
|
2393 | if self.options.outputdir: | |
2394 | self._outputdir = canonpath(_bytespath(self.options.outputdir)) |
|
2394 | self._outputdir = canonpath(_bytespath(self.options.outputdir)) | |
2395 | else: |
|
2395 | else: | |
2396 | self._outputdir = self._testdir |
|
2396 | self._outputdir = self._testdir | |
2397 | if testdescs and pathname: |
|
2397 | if testdescs and pathname: | |
2398 | self._outputdir = os.path.join(self._outputdir, pathname) |
|
2398 | self._outputdir = os.path.join(self._outputdir, pathname) | |
2399 |
|
2399 | |||
2400 | if 'PYTHONHASHSEED' not in os.environ: |
|
2400 | if 'PYTHONHASHSEED' not in os.environ: | |
2401 | # use a random python hash seed all the time |
|
2401 | # use a random python hash seed all the time | |
2402 | # we do the randomness ourself to know what seed is used |
|
2402 | # we do the randomness ourself to know what seed is used | |
2403 | os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) |
|
2403 | os.environ['PYTHONHASHSEED'] = str(random.getrandbits(32)) | |
2404 |
|
2404 | |||
2405 | if self.options.tmpdir: |
|
2405 | if self.options.tmpdir: | |
2406 | self.options.keep_tmpdir = True |
|
2406 | self.options.keep_tmpdir = True | |
2407 | tmpdir = _bytespath(self.options.tmpdir) |
|
2407 | tmpdir = _bytespath(self.options.tmpdir) | |
2408 | if os.path.exists(tmpdir): |
|
2408 | if os.path.exists(tmpdir): | |
2409 | # Meaning of tmpdir has changed since 1.3: we used to create |
|
2409 | # Meaning of tmpdir has changed since 1.3: we used to create | |
2410 | # HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if |
|
2410 | # HGTMP inside tmpdir; now HGTMP is tmpdir. So fail if | |
2411 | # tmpdir already exists. |
|
2411 | # tmpdir already exists. | |
2412 | print("error: temp dir %r already exists" % tmpdir) |
|
2412 | print("error: temp dir %r already exists" % tmpdir) | |
2413 | return 1 |
|
2413 | return 1 | |
2414 |
|
2414 | |||
2415 | # Automatically removing tmpdir sounds convenient, but could |
|
2415 | # Automatically removing tmpdir sounds convenient, but could | |
2416 | # really annoy anyone in the habit of using "--tmpdir=/tmp" |
|
2416 | # really annoy anyone in the habit of using "--tmpdir=/tmp" | |
2417 | # or "--tmpdir=$HOME". |
|
2417 | # or "--tmpdir=$HOME". | |
2418 | #vlog("# Removing temp dir", tmpdir) |
|
2418 | #vlog("# Removing temp dir", tmpdir) | |
2419 | #shutil.rmtree(tmpdir) |
|
2419 | #shutil.rmtree(tmpdir) | |
2420 | os.makedirs(tmpdir) |
|
2420 | os.makedirs(tmpdir) | |
2421 | else: |
|
2421 | else: | |
2422 | d = None |
|
2422 | d = None | |
2423 | if os.name == 'nt': |
|
2423 | if os.name == 'nt': | |
2424 | # without this, we get the default temp dir location, but |
|
2424 | # without this, we get the default temp dir location, but | |
2425 | # in all lowercase, which causes troubles with paths (issue3490) |
|
2425 | # in all lowercase, which causes troubles with paths (issue3490) | |
2426 | d = osenvironb.get(b'TMP', None) |
|
2426 | d = osenvironb.get(b'TMP', None) | |
2427 | tmpdir = tempfile.mkdtemp(b'', b'hgtests.', d) |
|
2427 | tmpdir = tempfile.mkdtemp(b'', b'hgtests.', d) | |
2428 |
|
2428 | |||
2429 | self._hgtmp = osenvironb[b'HGTMP'] = ( |
|
2429 | self._hgtmp = osenvironb[b'HGTMP'] = ( | |
2430 | os.path.realpath(tmpdir)) |
|
2430 | os.path.realpath(tmpdir)) | |
2431 |
|
2431 | |||
2432 | if self.options.with_hg: |
|
2432 | if self.options.with_hg: | |
2433 | self._installdir = None |
|
2433 | self._installdir = None | |
2434 | whg = self.options.with_hg |
|
2434 | whg = self.options.with_hg | |
2435 | self._bindir = os.path.dirname(os.path.realpath(whg)) |
|
2435 | self._bindir = os.path.dirname(os.path.realpath(whg)) | |
2436 | assert isinstance(self._bindir, bytes) |
|
2436 | assert isinstance(self._bindir, bytes) | |
2437 | self._hgcommand = os.path.basename(whg) |
|
2437 | self._hgcommand = os.path.basename(whg) | |
2438 | self._tmpbindir = os.path.join(self._hgtmp, b'install', b'bin') |
|
2438 | self._tmpbindir = os.path.join(self._hgtmp, b'install', b'bin') | |
2439 | os.makedirs(self._tmpbindir) |
|
2439 | os.makedirs(self._tmpbindir) | |
2440 |
|
2440 | |||
2441 | # This looks redundant with how Python initializes sys.path from |
|
2441 | # This looks redundant with how Python initializes sys.path from | |
2442 | # the location of the script being executed. Needed because the |
|
2442 | # the location of the script being executed. Needed because the | |
2443 | # "hg" specified by --with-hg is not the only Python script |
|
2443 | # "hg" specified by --with-hg is not the only Python script | |
2444 | # executed in the test suite that needs to import 'mercurial' |
|
2444 | # executed in the test suite that needs to import 'mercurial' | |
2445 | # ... which means it's not really redundant at all. |
|
2445 | # ... which means it's not really redundant at all. | |
2446 | self._pythondir = self._bindir |
|
2446 | self._pythondir = self._bindir | |
2447 | else: |
|
2447 | else: | |
2448 | self._installdir = os.path.join(self._hgtmp, b"install") |
|
2448 | self._installdir = os.path.join(self._hgtmp, b"install") | |
2449 | self._bindir = os.path.join(self._installdir, b"bin") |
|
2449 | self._bindir = os.path.join(self._installdir, b"bin") | |
2450 | self._hgcommand = b'hg' |
|
2450 | self._hgcommand = b'hg' | |
2451 | self._tmpbindir = self._bindir |
|
2451 | self._tmpbindir = self._bindir | |
2452 | self._pythondir = os.path.join(self._installdir, b"lib", b"python") |
|
2452 | self._pythondir = os.path.join(self._installdir, b"lib", b"python") | |
2453 |
|
2453 | |||
2454 | # set CHGHG, then replace "hg" command by "chg" |
|
2454 | # set CHGHG, then replace "hg" command by "chg" | |
2455 | chgbindir = self._bindir |
|
2455 | chgbindir = self._bindir | |
2456 | if self.options.chg or self.options.with_chg: |
|
2456 | if self.options.chg or self.options.with_chg: | |
2457 | osenvironb[b'CHGHG'] = os.path.join(self._bindir, self._hgcommand) |
|
2457 | osenvironb[b'CHGHG'] = os.path.join(self._bindir, self._hgcommand) | |
2458 | else: |
|
2458 | else: | |
2459 | osenvironb.pop(b'CHGHG', None) # drop flag for hghave |
|
2459 | osenvironb.pop(b'CHGHG', None) # drop flag for hghave | |
2460 | if self.options.chg: |
|
2460 | if self.options.chg: | |
2461 | self._hgcommand = b'chg' |
|
2461 | self._hgcommand = b'chg' | |
2462 | elif self.options.with_chg: |
|
2462 | elif self.options.with_chg: | |
2463 | chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg)) |
|
2463 | chgbindir = os.path.dirname(os.path.realpath(self.options.with_chg)) | |
2464 | self._hgcommand = os.path.basename(self.options.with_chg) |
|
2464 | self._hgcommand = os.path.basename(self.options.with_chg) | |
2465 |
|
2465 | |||
2466 | osenvironb[b"BINDIR"] = self._bindir |
|
2466 | osenvironb[b"BINDIR"] = self._bindir | |
2467 | osenvironb[b"PYTHON"] = PYTHON |
|
2467 | osenvironb[b"PYTHON"] = PYTHON | |
2468 |
|
2468 | |||
2469 | if self.options.with_python3: |
|
2469 | if self.options.with_python3: | |
2470 | osenvironb[b'PYTHON3'] = self.options.with_python3 |
|
2470 | osenvironb[b'PYTHON3'] = self.options.with_python3 | |
2471 |
|
2471 | |||
2472 | fileb = _bytespath(__file__) |
|
2472 | fileb = _bytespath(__file__) | |
2473 | runtestdir = os.path.abspath(os.path.dirname(fileb)) |
|
2473 | runtestdir = os.path.abspath(os.path.dirname(fileb)) | |
2474 | osenvironb[b'RUNTESTDIR'] = runtestdir |
|
2474 | osenvironb[b'RUNTESTDIR'] = runtestdir | |
2475 | if PYTHON3: |
|
2475 | if PYTHON3: | |
2476 | sepb = _bytespath(os.pathsep) |
|
2476 | sepb = _bytespath(os.pathsep) | |
2477 | else: |
|
2477 | else: | |
2478 | sepb = os.pathsep |
|
2478 | sepb = os.pathsep | |
2479 | path = [self._bindir, runtestdir] + osenvironb[b"PATH"].split(sepb) |
|
2479 | path = [self._bindir, runtestdir] + osenvironb[b"PATH"].split(sepb) | |
2480 | if os.path.islink(__file__): |
|
2480 | if os.path.islink(__file__): | |
2481 | # test helper will likely be at the end of the symlink |
|
2481 | # test helper will likely be at the end of the symlink | |
2482 | realfile = os.path.realpath(fileb) |
|
2482 | realfile = os.path.realpath(fileb) | |
2483 | realdir = os.path.abspath(os.path.dirname(realfile)) |
|
2483 | realdir = os.path.abspath(os.path.dirname(realfile)) | |
2484 | path.insert(2, realdir) |
|
2484 | path.insert(2, realdir) | |
2485 | if chgbindir != self._bindir: |
|
2485 | if chgbindir != self._bindir: | |
2486 | path.insert(1, chgbindir) |
|
2486 | path.insert(1, chgbindir) | |
2487 | if self._testdir != runtestdir: |
|
2487 | if self._testdir != runtestdir: | |
2488 | path = [self._testdir] + path |
|
2488 | path = [self._testdir] + path | |
2489 | if self._tmpbindir != self._bindir: |
|
2489 | if self._tmpbindir != self._bindir: | |
2490 | path = [self._tmpbindir] + path |
|
2490 | path = [self._tmpbindir] + path | |
2491 | osenvironb[b"PATH"] = sepb.join(path) |
|
2491 | osenvironb[b"PATH"] = sepb.join(path) | |
2492 |
|
2492 | |||
2493 | # Include TESTDIR in PYTHONPATH so that out-of-tree extensions |
|
2493 | # Include TESTDIR in PYTHONPATH so that out-of-tree extensions | |
2494 | # can run .../tests/run-tests.py test-foo where test-foo |
|
2494 | # can run .../tests/run-tests.py test-foo where test-foo | |
2495 | # adds an extension to HGRC. Also include run-test.py directory to |
|
2495 | # adds an extension to HGRC. Also include run-test.py directory to | |
2496 | # import modules like heredoctest. |
|
2496 | # import modules like heredoctest. | |
2497 | pypath = [self._pythondir, self._testdir, runtestdir] |
|
2497 | pypath = [self._pythondir, self._testdir, runtestdir] | |
2498 | # We have to augment PYTHONPATH, rather than simply replacing |
|
2498 | # We have to augment PYTHONPATH, rather than simply replacing | |
2499 | # it, in case external libraries are only available via current |
|
2499 | # it, in case external libraries are only available via current | |
2500 | # PYTHONPATH. (In particular, the Subversion bindings on OS X |
|
2500 | # PYTHONPATH. (In particular, the Subversion bindings on OS X | |
2501 | # are in /opt/subversion.) |
|
2501 | # are in /opt/subversion.) | |
2502 | oldpypath = osenvironb.get(IMPL_PATH) |
|
2502 | oldpypath = osenvironb.get(IMPL_PATH) | |
2503 | if oldpypath: |
|
2503 | if oldpypath: | |
2504 | pypath.append(oldpypath) |
|
2504 | pypath.append(oldpypath) | |
2505 | osenvironb[IMPL_PATH] = sepb.join(pypath) |
|
2505 | osenvironb[IMPL_PATH] = sepb.join(pypath) | |
2506 |
|
2506 | |||
2507 | if self.options.pure: |
|
2507 | if self.options.pure: | |
2508 | os.environ["HGTEST_RUN_TESTS_PURE"] = "--pure" |
|
2508 | os.environ["HGTEST_RUN_TESTS_PURE"] = "--pure" | |
2509 | os.environ["HGMODULEPOLICY"] = "py" |
|
2509 | os.environ["HGMODULEPOLICY"] = "py" | |
2510 |
|
2510 | |||
2511 | if self.options.allow_slow_tests: |
|
2511 | if self.options.allow_slow_tests: | |
2512 | os.environ["HGTEST_SLOW"] = "slow" |
|
2512 | os.environ["HGTEST_SLOW"] = "slow" | |
2513 | elif 'HGTEST_SLOW' in os.environ: |
|
2513 | elif 'HGTEST_SLOW' in os.environ: | |
2514 | del os.environ['HGTEST_SLOW'] |
|
2514 | del os.environ['HGTEST_SLOW'] | |
2515 |
|
2515 | |||
2516 | self._coveragefile = os.path.join(self._testdir, b'.coverage') |
|
2516 | self._coveragefile = os.path.join(self._testdir, b'.coverage') | |
2517 |
|
2517 | |||
2518 | if self.options.exceptions: |
|
2518 | if self.options.exceptions: | |
2519 | exceptionsdir = os.path.join(self._outputdir, b'exceptions') |
|
2519 | exceptionsdir = os.path.join(self._outputdir, b'exceptions') | |
2520 | try: |
|
2520 | try: | |
2521 | os.makedirs(exceptionsdir) |
|
2521 | os.makedirs(exceptionsdir) | |
2522 | except OSError as e: |
|
2522 | except OSError as e: | |
2523 | if e.errno != errno.EEXIST: |
|
2523 | if e.errno != errno.EEXIST: | |
2524 | raise |
|
2524 | raise | |
2525 |
|
2525 | |||
2526 | # Remove all existing exception reports. |
|
2526 | # Remove all existing exception reports. | |
2527 | for f in os.listdir(exceptionsdir): |
|
2527 | for f in os.listdir(exceptionsdir): | |
2528 | os.unlink(os.path.join(exceptionsdir, f)) |
|
2528 | os.unlink(os.path.join(exceptionsdir, f)) | |
2529 |
|
2529 | |||
2530 | osenvironb[b'HGEXCEPTIONSDIR'] = exceptionsdir |
|
2530 | osenvironb[b'HGEXCEPTIONSDIR'] = exceptionsdir | |
2531 | logexceptions = os.path.join(self._testdir, b'logexceptions.py') |
|
2531 | logexceptions = os.path.join(self._testdir, b'logexceptions.py') | |
2532 | self.options.extra_config_opt.append( |
|
2532 | self.options.extra_config_opt.append( | |
2533 | 'extensions.logexceptions=%s' % logexceptions.decode('utf-8')) |
|
2533 | 'extensions.logexceptions=%s' % logexceptions.decode('utf-8')) | |
2534 |
|
2534 | |||
2535 | vlog("# Using TESTDIR", self._testdir) |
|
2535 | vlog("# Using TESTDIR", self._testdir) | |
2536 | vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR']) |
|
2536 | vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR']) | |
2537 | vlog("# Using HGTMP", self._hgtmp) |
|
2537 | vlog("# Using HGTMP", self._hgtmp) | |
2538 | vlog("# Using PATH", os.environ["PATH"]) |
|
2538 | vlog("# Using PATH", os.environ["PATH"]) | |
2539 | vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) |
|
2539 | vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) | |
2540 | vlog("# Writing to directory", self._outputdir) |
|
2540 | vlog("# Writing to directory", self._outputdir) | |
2541 |
|
2541 | |||
2542 | try: |
|
2542 | try: | |
2543 | return self._runtests(testdescs) or 0 |
|
2543 | return self._runtests(testdescs) or 0 | |
2544 | finally: |
|
2544 | finally: | |
2545 | time.sleep(.1) |
|
2545 | time.sleep(.1) | |
2546 | self._cleanup() |
|
2546 | self._cleanup() | |
2547 |
|
2547 | |||
2548 | def findtests(self, args): |
|
2548 | def findtests(self, args): | |
2549 | """Finds possible test files from arguments. |
|
2549 | """Finds possible test files from arguments. | |
2550 |
|
2550 | |||
2551 | If you wish to inject custom tests into the test harness, this would |
|
2551 | If you wish to inject custom tests into the test harness, this would | |
2552 | be a good function to monkeypatch or override in a derived class. |
|
2552 | be a good function to monkeypatch or override in a derived class. | |
2553 | """ |
|
2553 | """ | |
2554 | if not args: |
|
2554 | if not args: | |
2555 | if self.options.changed: |
|
2555 | if self.options.changed: | |
2556 | proc = Popen4('hg st --rev "%s" -man0 .' % |
|
2556 | proc = Popen4('hg st --rev "%s" -man0 .' % | |
2557 | self.options.changed, None, 0) |
|
2557 | self.options.changed, None, 0) | |
2558 | stdout, stderr = proc.communicate() |
|
2558 | stdout, stderr = proc.communicate() | |
2559 | args = stdout.strip(b'\0').split(b'\0') |
|
2559 | args = stdout.strip(b'\0').split(b'\0') | |
2560 | else: |
|
2560 | else: | |
2561 | args = os.listdir(b'.') |
|
2561 | args = os.listdir(b'.') | |
2562 |
|
2562 | |||
2563 | expanded_args = [] |
|
2563 | expanded_args = [] | |
2564 | for arg in args: |
|
2564 | for arg in args: | |
2565 | if os.path.isdir(arg): |
|
2565 | if os.path.isdir(arg): | |
2566 | if not arg.endswith(b'/'): |
|
2566 | if not arg.endswith(b'/'): | |
2567 | arg += b'/' |
|
2567 | arg += b'/' | |
2568 | expanded_args.extend([arg + a for a in os.listdir(arg)]) |
|
2568 | expanded_args.extend([arg + a for a in os.listdir(arg)]) | |
2569 | else: |
|
2569 | else: | |
2570 | expanded_args.append(arg) |
|
2570 | expanded_args.append(arg) | |
2571 | args = expanded_args |
|
2571 | args = expanded_args | |
2572 |
|
2572 | |||
2573 | tests = [] |
|
2573 | tests = [] | |
2574 | for t in args: |
|
2574 | for t in args: | |
2575 | if not (os.path.basename(t).startswith(b'test-') |
|
2575 | if not (os.path.basename(t).startswith(b'test-') | |
2576 | and (t.endswith(b'.py') or t.endswith(b'.t'))): |
|
2576 | and (t.endswith(b'.py') or t.endswith(b'.t'))): | |
2577 | continue |
|
2577 | continue | |
2578 | if t.endswith(b'.t'): |
|
2578 | if t.endswith(b'.t'): | |
2579 | # .t file may contain multiple test cases |
|
2579 | # .t file may contain multiple test cases | |
2580 | cases = sorted(parsettestcases(t)) |
|
2580 | cases = sorted(parsettestcases(t)) | |
2581 | if cases: |
|
2581 | if cases: | |
2582 | tests += [{'path': t, 'case': c} for c in sorted(cases)] |
|
2582 | tests += [{'path': t, 'case': c} for c in sorted(cases)] | |
2583 | else: |
|
2583 | else: | |
2584 | tests.append({'path': t}) |
|
2584 | tests.append({'path': t}) | |
2585 | else: |
|
2585 | else: | |
2586 | tests.append({'path': t}) |
|
2586 | tests.append({'path': t}) | |
2587 | return tests |
|
2587 | return tests | |
2588 |
|
2588 | |||
2589 | def _runtests(self, testdescs): |
|
2589 | def _runtests(self, testdescs): | |
2590 | def _reloadtest(test, i): |
|
2590 | def _reloadtest(test, i): | |
2591 | # convert a test back to its description dict |
|
2591 | # convert a test back to its description dict | |
2592 | desc = {'path': test.path} |
|
2592 | desc = {'path': test.path} | |
2593 | case = getattr(test, '_case', None) |
|
2593 | case = getattr(test, '_case', None) | |
2594 | if case: |
|
2594 | if case: | |
2595 | desc['case'] = case |
|
2595 | desc['case'] = case | |
2596 | return self._gettest(desc, i) |
|
2596 | return self._gettest(desc, i) | |
2597 |
|
2597 | |||
2598 | try: |
|
2598 | try: | |
2599 | if self.options.restart: |
|
2599 | if self.options.restart: | |
2600 | orig = list(testdescs) |
|
2600 | orig = list(testdescs) | |
2601 | while testdescs: |
|
2601 | while testdescs: | |
2602 | desc = testdescs[0] |
|
2602 | desc = testdescs[0] | |
2603 | # desc['path'] is a relative path |
|
2603 | # desc['path'] is a relative path | |
2604 | if 'case' in desc: |
|
2604 | if 'case' in desc: | |
2605 | errpath = b'%s.%s.err' % (desc['path'], desc['case']) |
|
2605 | errpath = b'%s.%s.err' % (desc['path'], desc['case']) | |
2606 | else: |
|
2606 | else: | |
2607 | errpath = b'%s.err' % desc['path'] |
|
2607 | errpath = b'%s.err' % desc['path'] | |
2608 | errpath = os.path.join(self._outputdir, errpath) |
|
2608 | errpath = os.path.join(self._outputdir, errpath) | |
2609 | if os.path.exists(errpath): |
|
2609 | if os.path.exists(errpath): | |
2610 | break |
|
2610 | break | |
2611 | testdescs.pop(0) |
|
2611 | testdescs.pop(0) | |
2612 | if not testdescs: |
|
2612 | if not testdescs: | |
2613 | print("running all tests") |
|
2613 | print("running all tests") | |
2614 | testdescs = orig |
|
2614 | testdescs = orig | |
2615 |
|
2615 | |||
2616 | tests = [self._gettest(d, i) for i, d in enumerate(testdescs)] |
|
2616 | tests = [self._gettest(d, i) for i, d in enumerate(testdescs)] | |
2617 |
|
2617 | |||
2618 | failed = False |
|
2618 | failed = False | |
2619 | kws = self.options.keywords |
|
2619 | kws = self.options.keywords | |
2620 | if kws is not None and PYTHON3: |
|
2620 | if kws is not None and PYTHON3: | |
2621 | kws = kws.encode('utf-8') |
|
2621 | kws = kws.encode('utf-8') | |
2622 |
|
2622 | |||
2623 | suite = TestSuite(self._testdir, |
|
2623 | suite = TestSuite(self._testdir, | |
2624 | jobs=self.options.jobs, |
|
2624 | jobs=self.options.jobs, | |
2625 | whitelist=self.options.whitelisted, |
|
2625 | whitelist=self.options.whitelisted, | |
2626 | blacklist=self.options.blacklist, |
|
2626 | blacklist=self.options.blacklist, | |
2627 | retest=self.options.retest, |
|
2627 | retest=self.options.retest, | |
2628 | keywords=kws, |
|
2628 | keywords=kws, | |
2629 | loop=self.options.loop, |
|
2629 | loop=self.options.loop, | |
2630 | runs_per_test=self.options.runs_per_test, |
|
2630 | runs_per_test=self.options.runs_per_test, | |
2631 | showchannels=self.options.showchannels, |
|
2631 | showchannels=self.options.showchannels, | |
2632 | tests=tests, loadtest=_reloadtest) |
|
2632 | tests=tests, loadtest=_reloadtest) | |
2633 | verbosity = 1 |
|
2633 | verbosity = 1 | |
2634 | if self.options.verbose: |
|
2634 | if self.options.verbose: | |
2635 | verbosity = 2 |
|
2635 | verbosity = 2 | |
2636 | runner = TextTestRunner(self, verbosity=verbosity) |
|
2636 | runner = TextTestRunner(self, verbosity=verbosity) | |
2637 |
|
2637 | |||
2638 | if self.options.list_tests: |
|
2638 | if self.options.list_tests: | |
2639 | result = runner.listtests(suite) |
|
2639 | result = runner.listtests(suite) | |
2640 | else: |
|
2640 | else: | |
2641 | if self._installdir: |
|
2641 | if self._installdir: | |
2642 | self._installhg() |
|
2642 | self._installhg() | |
2643 | self._checkhglib("Testing") |
|
2643 | self._checkhglib("Testing") | |
2644 | else: |
|
2644 | else: | |
2645 | self._usecorrectpython() |
|
2645 | self._usecorrectpython() | |
2646 | if self.options.chg: |
|
2646 | if self.options.chg: | |
2647 | assert self._installdir |
|
2647 | assert self._installdir | |
2648 | self._installchg() |
|
2648 | self._installchg() | |
2649 |
|
2649 | |||
2650 | result = runner.run(suite) |
|
2650 | result = runner.run(suite) | |
2651 |
|
2651 | |||
2652 | if result.failures: |
|
2652 | if result.failures: | |
2653 | failed = True |
|
2653 | failed = True | |
2654 |
|
2654 | |||
2655 | if self.options.anycoverage: |
|
2655 | if self.options.anycoverage: | |
2656 | self._outputcoverage() |
|
2656 | self._outputcoverage() | |
2657 | except KeyboardInterrupt: |
|
2657 | except KeyboardInterrupt: | |
2658 | failed = True |
|
2658 | failed = True | |
2659 | print("\ninterrupted!") |
|
2659 | print("\ninterrupted!") | |
2660 |
|
2660 | |||
2661 | if failed: |
|
2661 | if failed: | |
2662 | return 1 |
|
2662 | return 1 | |
2663 |
|
2663 | |||
2664 | def _getport(self, count): |
|
2664 | def _getport(self, count): | |
2665 | port = self._ports.get(count) # do we have a cached entry? |
|
2665 | port = self._ports.get(count) # do we have a cached entry? | |
2666 | if port is None: |
|
2666 | if port is None: | |
2667 | portneeded = 3 |
|
2667 | portneeded = 3 | |
2668 | # above 100 tries we just give up and let test reports failure |
|
2668 | # above 100 tries we just give up and let test reports failure | |
2669 | for tries in xrange(100): |
|
2669 | for tries in xrange(100): | |
2670 | allfree = True |
|
2670 | allfree = True | |
2671 | port = self.options.port + self._portoffset |
|
2671 | port = self.options.port + self._portoffset | |
2672 | for idx in xrange(portneeded): |
|
2672 | for idx in xrange(portneeded): | |
2673 | if not checkportisavailable(port + idx): |
|
2673 | if not checkportisavailable(port + idx): | |
2674 | allfree = False |
|
2674 | allfree = False | |
2675 | break |
|
2675 | break | |
2676 | self._portoffset += portneeded |
|
2676 | self._portoffset += portneeded | |
2677 | if allfree: |
|
2677 | if allfree: | |
2678 | break |
|
2678 | break | |
2679 | self._ports[count] = port |
|
2679 | self._ports[count] = port | |
2680 | return port |
|
2680 | return port | |
2681 |
|
2681 | |||
2682 | def _gettest(self, testdesc, count): |
|
2682 | def _gettest(self, testdesc, count): | |
2683 | """Obtain a Test by looking at its filename. |
|
2683 | """Obtain a Test by looking at its filename. | |
2684 |
|
2684 | |||
2685 | Returns a Test instance. The Test may not be runnable if it doesn't |
|
2685 | Returns a Test instance. The Test may not be runnable if it doesn't | |
2686 | map to a known type. |
|
2686 | map to a known type. | |
2687 | """ |
|
2687 | """ | |
2688 | path = testdesc['path'] |
|
2688 | path = testdesc['path'] | |
2689 | lctest = path.lower() |
|
2689 | lctest = path.lower() | |
2690 | testcls = Test |
|
2690 | testcls = Test | |
2691 |
|
2691 | |||
2692 | for ext, cls in self.TESTTYPES: |
|
2692 | for ext, cls in self.TESTTYPES: | |
2693 | if lctest.endswith(ext): |
|
2693 | if lctest.endswith(ext): | |
2694 | testcls = cls |
|
2694 | testcls = cls | |
2695 | break |
|
2695 | break | |
2696 |
|
2696 | |||
2697 | refpath = os.path.join(self._testdir, path) |
|
2697 | refpath = os.path.join(self._testdir, path) | |
2698 | tmpdir = os.path.join(self._hgtmp, b'child%d' % count) |
|
2698 | tmpdir = os.path.join(self._hgtmp, b'child%d' % count) | |
2699 |
|
2699 | |||
2700 | # extra keyword parameters. 'case' is used by .t tests |
|
2700 | # extra keyword parameters. 'case' is used by .t tests | |
2701 | kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) |
|
2701 | kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) | |
2702 |
|
2702 | |||
2703 | t = testcls(refpath, self._outputdir, tmpdir, |
|
2703 | t = testcls(refpath, self._outputdir, tmpdir, | |
2704 | keeptmpdir=self.options.keep_tmpdir, |
|
2704 | keeptmpdir=self.options.keep_tmpdir, | |
2705 | debug=self.options.debug, |
|
2705 | debug=self.options.debug, | |
2706 | timeout=self.options.timeout, |
|
2706 | timeout=self.options.timeout, | |
2707 | startport=self._getport(count), |
|
2707 | startport=self._getport(count), | |
2708 | extraconfigopts=self.options.extra_config_opt, |
|
2708 | extraconfigopts=self.options.extra_config_opt, | |
2709 | py3kwarnings=self.options.py3k_warnings, |
|
2709 | py3kwarnings=self.options.py3k_warnings, | |
2710 | shell=self.options.shell, |
|
2710 | shell=self.options.shell, | |
2711 | hgcommand=self._hgcommand, |
|
2711 | hgcommand=self._hgcommand, | |
2712 | usechg=bool(self.options.with_chg or self.options.chg), |
|
2712 | usechg=bool(self.options.with_chg or self.options.chg), | |
2713 | useipv6=useipv6, **kwds) |
|
2713 | useipv6=useipv6, **kwds) | |
2714 | t.should_reload = True |
|
2714 | t.should_reload = True | |
2715 | return t |
|
2715 | return t | |
2716 |
|
2716 | |||
2717 | def _cleanup(self): |
|
2717 | def _cleanup(self): | |
2718 | """Clean up state from this test invocation.""" |
|
2718 | """Clean up state from this test invocation.""" | |
2719 | if self.options.keep_tmpdir: |
|
2719 | if self.options.keep_tmpdir: | |
2720 | return |
|
2720 | return | |
2721 |
|
2721 | |||
2722 | vlog("# Cleaning up HGTMP", self._hgtmp) |
|
2722 | vlog("# Cleaning up HGTMP", self._hgtmp) | |
2723 | shutil.rmtree(self._hgtmp, True) |
|
2723 | shutil.rmtree(self._hgtmp, True) | |
2724 | for f in self._createdfiles: |
|
2724 | for f in self._createdfiles: | |
2725 | try: |
|
2725 | try: | |
2726 | os.remove(f) |
|
2726 | os.remove(f) | |
2727 | except OSError: |
|
2727 | except OSError: | |
2728 | pass |
|
2728 | pass | |
2729 |
|
2729 | |||
2730 | def _usecorrectpython(self): |
|
2730 | def _usecorrectpython(self): | |
2731 | """Configure the environment to use the appropriate Python in tests.""" |
|
2731 | """Configure the environment to use the appropriate Python in tests.""" | |
2732 | # Tests must use the same interpreter as us or bad things will happen. |
|
2732 | # Tests must use the same interpreter as us or bad things will happen. | |
2733 | pyexename = sys.platform == 'win32' and b'python.exe' or b'python' |
|
2733 | pyexename = sys.platform == 'win32' and b'python.exe' or b'python' | |
2734 | if getattr(os, 'symlink', None): |
|
2734 | if getattr(os, 'symlink', None): | |
2735 | vlog("# Making python executable in test path a symlink to '%s'" % |
|
2735 | vlog("# Making python executable in test path a symlink to '%s'" % | |
2736 | sys.executable) |
|
2736 | sys.executable) | |
2737 | mypython = os.path.join(self._tmpbindir, pyexename) |
|
2737 | mypython = os.path.join(self._tmpbindir, pyexename) | |
2738 | try: |
|
2738 | try: | |
2739 | if os.readlink(mypython) == sys.executable: |
|
2739 | if os.readlink(mypython) == sys.executable: | |
2740 | return |
|
2740 | return | |
2741 | os.unlink(mypython) |
|
2741 | os.unlink(mypython) | |
2742 | except OSError as err: |
|
2742 | except OSError as err: | |
2743 | if err.errno != errno.ENOENT: |
|
2743 | if err.errno != errno.ENOENT: | |
2744 | raise |
|
2744 | raise | |
2745 | if self._findprogram(pyexename) != sys.executable: |
|
2745 | if self._findprogram(pyexename) != sys.executable: | |
2746 | try: |
|
2746 | try: | |
2747 | os.symlink(sys.executable, mypython) |
|
2747 | os.symlink(sys.executable, mypython) | |
2748 | self._createdfiles.append(mypython) |
|
2748 | self._createdfiles.append(mypython) | |
2749 | except OSError as err: |
|
2749 | except OSError as err: | |
2750 | # child processes may race, which is harmless |
|
2750 | # child processes may race, which is harmless | |
2751 | if err.errno != errno.EEXIST: |
|
2751 | if err.errno != errno.EEXIST: | |
2752 | raise |
|
2752 | raise | |
2753 | else: |
|
2753 | else: | |
2754 | exedir, exename = os.path.split(sys.executable) |
|
2754 | exedir, exename = os.path.split(sys.executable) | |
2755 | vlog("# Modifying search path to find %s as %s in '%s'" % |
|
2755 | vlog("# Modifying search path to find %s as %s in '%s'" % | |
2756 | (exename, pyexename, exedir)) |
|
2756 | (exename, pyexename, exedir)) | |
2757 | path = os.environ['PATH'].split(os.pathsep) |
|
2757 | path = os.environ['PATH'].split(os.pathsep) | |
2758 | while exedir in path: |
|
2758 | while exedir in path: | |
2759 | path.remove(exedir) |
|
2759 | path.remove(exedir) | |
2760 | os.environ['PATH'] = os.pathsep.join([exedir] + path) |
|
2760 | os.environ['PATH'] = os.pathsep.join([exedir] + path) | |
2761 | if not self._findprogram(pyexename): |
|
2761 | if not self._findprogram(pyexename): | |
2762 | print("WARNING: Cannot find %s in search path" % pyexename) |
|
2762 | print("WARNING: Cannot find %s in search path" % pyexename) | |
2763 |
|
2763 | |||
2764 | def _installhg(self): |
|
2764 | def _installhg(self): | |
2765 | """Install hg into the test environment. |
|
2765 | """Install hg into the test environment. | |
2766 |
|
2766 | |||
2767 | This will also configure hg with the appropriate testing settings. |
|
2767 | This will also configure hg with the appropriate testing settings. | |
2768 | """ |
|
2768 | """ | |
2769 | vlog("# Performing temporary installation of HG") |
|
2769 | vlog("# Performing temporary installation of HG") | |
2770 | installerrs = os.path.join(self._hgtmp, b"install.err") |
|
2770 | installerrs = os.path.join(self._hgtmp, b"install.err") | |
2771 | compiler = '' |
|
2771 | compiler = '' | |
2772 | if self.options.compiler: |
|
2772 | if self.options.compiler: | |
2773 | compiler = '--compiler ' + self.options.compiler |
|
2773 | compiler = '--compiler ' + self.options.compiler | |
2774 | if self.options.pure: |
|
2774 | if self.options.pure: | |
2775 | pure = b"--pure" |
|
2775 | pure = b"--pure" | |
2776 | else: |
|
2776 | else: | |
2777 | pure = b"" |
|
2777 | pure = b"" | |
2778 |
|
2778 | |||
2779 | # Run installer in hg root |
|
2779 | # Run installer in hg root | |
2780 | script = os.path.realpath(sys.argv[0]) |
|
2780 | script = os.path.realpath(sys.argv[0]) | |
2781 | exe = sys.executable |
|
2781 | exe = sys.executable | |
2782 | if PYTHON3: |
|
2782 | if PYTHON3: | |
2783 | compiler = _bytespath(compiler) |
|
2783 | compiler = _bytespath(compiler) | |
2784 | script = _bytespath(script) |
|
2784 | script = _bytespath(script) | |
2785 | exe = _bytespath(exe) |
|
2785 | exe = _bytespath(exe) | |
2786 | hgroot = os.path.dirname(os.path.dirname(script)) |
|
2786 | hgroot = os.path.dirname(os.path.dirname(script)) | |
2787 | self._hgroot = hgroot |
|
2787 | self._hgroot = hgroot | |
2788 | os.chdir(hgroot) |
|
2788 | os.chdir(hgroot) | |
2789 | nohome = b'--home=""' |
|
2789 | nohome = b'--home=""' | |
2790 | if os.name == 'nt': |
|
2790 | if os.name == 'nt': | |
2791 | # The --home="" trick works only on OS where os.sep == '/' |
|
2791 | # The --home="" trick works only on OS where os.sep == '/' | |
2792 | # because of a distutils convert_path() fast-path. Avoid it at |
|
2792 | # because of a distutils convert_path() fast-path. Avoid it at | |
2793 | # least on Windows for now, deal with .pydistutils.cfg bugs |
|
2793 | # least on Windows for now, deal with .pydistutils.cfg bugs | |
2794 | # when they happen. |
|
2794 | # when they happen. | |
2795 | nohome = b'' |
|
2795 | nohome = b'' | |
2796 | cmd = (b'%(exe)s setup.py %(pure)s clean --all' |
|
2796 | cmd = (b'%(exe)s setup.py %(pure)s clean --all' | |
2797 | b' build %(compiler)s --build-base="%(base)s"' |
|
2797 | b' build %(compiler)s --build-base="%(base)s"' | |
2798 | b' install --force --prefix="%(prefix)s"' |
|
2798 | b' install --force --prefix="%(prefix)s"' | |
2799 | b' --install-lib="%(libdir)s"' |
|
2799 | b' --install-lib="%(libdir)s"' | |
2800 | b' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1' |
|
2800 | b' --install-scripts="%(bindir)s" %(nohome)s >%(logfile)s 2>&1' | |
2801 | % {b'exe': exe, b'pure': pure, |
|
2801 | % {b'exe': exe, b'pure': pure, | |
2802 | b'compiler': compiler, |
|
2802 | b'compiler': compiler, | |
2803 | b'base': os.path.join(self._hgtmp, b"build"), |
|
2803 | b'base': os.path.join(self._hgtmp, b"build"), | |
2804 | b'prefix': self._installdir, b'libdir': self._pythondir, |
|
2804 | b'prefix': self._installdir, b'libdir': self._pythondir, | |
2805 | b'bindir': self._bindir, |
|
2805 | b'bindir': self._bindir, | |
2806 | b'nohome': nohome, b'logfile': installerrs}) |
|
2806 | b'nohome': nohome, b'logfile': installerrs}) | |
2807 |
|
2807 | |||
2808 | # setuptools requires install directories to exist. |
|
2808 | # setuptools requires install directories to exist. | |
2809 | def makedirs(p): |
|
2809 | def makedirs(p): | |
2810 | try: |
|
2810 | try: | |
2811 | os.makedirs(p) |
|
2811 | os.makedirs(p) | |
2812 | except OSError as e: |
|
2812 | except OSError as e: | |
2813 | if e.errno != errno.EEXIST: |
|
2813 | if e.errno != errno.EEXIST: | |
2814 | raise |
|
2814 | raise | |
2815 | makedirs(self._pythondir) |
|
2815 | makedirs(self._pythondir) | |
2816 | makedirs(self._bindir) |
|
2816 | makedirs(self._bindir) | |
2817 |
|
2817 | |||
2818 | vlog("# Running", cmd) |
|
2818 | vlog("# Running", cmd) | |
2819 | if os.system(cmd) == 0: |
|
2819 | if os.system(cmd) == 0: | |
2820 | if not self.options.verbose: |
|
2820 | if not self.options.verbose: | |
2821 | try: |
|
2821 | try: | |
2822 | os.remove(installerrs) |
|
2822 | os.remove(installerrs) | |
2823 | except OSError as e: |
|
2823 | except OSError as e: | |
2824 | if e.errno != errno.ENOENT: |
|
2824 | if e.errno != errno.ENOENT: | |
2825 | raise |
|
2825 | raise | |
2826 | else: |
|
2826 | else: | |
2827 | f = open(installerrs, 'rb') |
|
2827 | f = open(installerrs, 'rb') | |
2828 | for line in f: |
|
2828 | for line in f: | |
2829 | if PYTHON3: |
|
2829 | if PYTHON3: | |
2830 | sys.stdout.buffer.write(line) |
|
2830 | sys.stdout.buffer.write(line) | |
2831 | else: |
|
2831 | else: | |
2832 | sys.stdout.write(line) |
|
2832 | sys.stdout.write(line) | |
2833 | f.close() |
|
2833 | f.close() | |
2834 | sys.exit(1) |
|
2834 | sys.exit(1) | |
2835 | os.chdir(self._testdir) |
|
2835 | os.chdir(self._testdir) | |
2836 |
|
2836 | |||
2837 | self._usecorrectpython() |
|
2837 | self._usecorrectpython() | |
2838 |
|
2838 | |||
2839 | if self.options.py3k_warnings and not self.options.anycoverage: |
|
2839 | if self.options.py3k_warnings and not self.options.anycoverage: | |
2840 | vlog("# Updating hg command to enable Py3k Warnings switch") |
|
2840 | vlog("# Updating hg command to enable Py3k Warnings switch") | |
2841 | f = open(os.path.join(self._bindir, 'hg'), 'rb') |
|
2841 | f = open(os.path.join(self._bindir, 'hg'), 'rb') | |
2842 | lines = [line.rstrip() for line in f] |
|
2842 | lines = [line.rstrip() for line in f] | |
2843 | lines[0] += ' -3' |
|
2843 | lines[0] += ' -3' | |
2844 | f.close() |
|
2844 | f.close() | |
2845 | f = open(os.path.join(self._bindir, 'hg'), 'wb') |
|
2845 | f = open(os.path.join(self._bindir, 'hg'), 'wb') | |
2846 | for line in lines: |
|
2846 | for line in lines: | |
2847 | f.write(line + '\n') |
|
2847 | f.write(line + '\n') | |
2848 | f.close() |
|
2848 | f.close() | |
2849 |
|
2849 | |||
2850 | hgbat = os.path.join(self._bindir, b'hg.bat') |
|
2850 | hgbat = os.path.join(self._bindir, b'hg.bat') | |
2851 | if os.path.isfile(hgbat): |
|
2851 | if os.path.isfile(hgbat): | |
2852 | # hg.bat expects to be put in bin/scripts while run-tests.py |
|
2852 | # hg.bat expects to be put in bin/scripts while run-tests.py | |
2853 | # installation layout put it in bin/ directly. Fix it |
|
2853 | # installation layout put it in bin/ directly. Fix it | |
2854 | f = open(hgbat, 'rb') |
|
2854 | f = open(hgbat, 'rb') | |
2855 | data = f.read() |
|
2855 | data = f.read() | |
2856 | f.close() |
|
2856 | f.close() | |
2857 | if b'"%~dp0..\python" "%~dp0hg" %*' in data: |
|
2857 | if b'"%~dp0..\python" "%~dp0hg" %*' in data: | |
2858 | data = data.replace(b'"%~dp0..\python" "%~dp0hg" %*', |
|
2858 | data = data.replace(b'"%~dp0..\python" "%~dp0hg" %*', | |
2859 | b'"%~dp0python" "%~dp0hg" %*') |
|
2859 | b'"%~dp0python" "%~dp0hg" %*') | |
2860 | f = open(hgbat, 'wb') |
|
2860 | f = open(hgbat, 'wb') | |
2861 | f.write(data) |
|
2861 | f.write(data) | |
2862 | f.close() |
|
2862 | f.close() | |
2863 | else: |
|
2863 | else: | |
2864 | print('WARNING: cannot fix hg.bat reference to python.exe') |
|
2864 | print('WARNING: cannot fix hg.bat reference to python.exe') | |
2865 |
|
2865 | |||
2866 | if self.options.anycoverage: |
|
2866 | if self.options.anycoverage: | |
2867 | custom = os.path.join(self._testdir, 'sitecustomize.py') |
|
2867 | custom = os.path.join(self._testdir, 'sitecustomize.py') | |
2868 | target = os.path.join(self._pythondir, 'sitecustomize.py') |
|
2868 | target = os.path.join(self._pythondir, 'sitecustomize.py') | |
2869 | vlog('# Installing coverage trigger to %s' % target) |
|
2869 | vlog('# Installing coverage trigger to %s' % target) | |
2870 | shutil.copyfile(custom, target) |
|
2870 | shutil.copyfile(custom, target) | |
2871 | rc = os.path.join(self._testdir, '.coveragerc') |
|
2871 | rc = os.path.join(self._testdir, '.coveragerc') | |
2872 | vlog('# Installing coverage rc to %s' % rc) |
|
2872 | vlog('# Installing coverage rc to %s' % rc) | |
2873 | os.environ['COVERAGE_PROCESS_START'] = rc |
|
2873 | os.environ['COVERAGE_PROCESS_START'] = rc | |
2874 | covdir = os.path.join(self._installdir, '..', 'coverage') |
|
2874 | covdir = os.path.join(self._installdir, '..', 'coverage') | |
2875 | try: |
|
2875 | try: | |
2876 | os.mkdir(covdir) |
|
2876 | os.mkdir(covdir) | |
2877 | except OSError as e: |
|
2877 | except OSError as e: | |
2878 | if e.errno != errno.EEXIST: |
|
2878 | if e.errno != errno.EEXIST: | |
2879 | raise |
|
2879 | raise | |
2880 |
|
2880 | |||
2881 | os.environ['COVERAGE_DIR'] = covdir |
|
2881 | os.environ['COVERAGE_DIR'] = covdir | |
2882 |
|
2882 | |||
2883 | def _checkhglib(self, verb): |
|
2883 | def _checkhglib(self, verb): | |
2884 | """Ensure that the 'mercurial' package imported by python is |
|
2884 | """Ensure that the 'mercurial' package imported by python is | |
2885 | the one we expect it to be. If not, print a warning to stderr.""" |
|
2885 | the one we expect it to be. If not, print a warning to stderr.""" | |
2886 | if ((self._bindir == self._pythondir) and |
|
2886 | if ((self._bindir == self._pythondir) and | |
2887 | (self._bindir != self._tmpbindir)): |
|
2887 | (self._bindir != self._tmpbindir)): | |
2888 | # The pythondir has been inferred from --with-hg flag. |
|
2888 | # The pythondir has been inferred from --with-hg flag. | |
2889 | # We cannot expect anything sensible here. |
|
2889 | # We cannot expect anything sensible here. | |
2890 | return |
|
2890 | return | |
2891 | expecthg = os.path.join(self._pythondir, b'mercurial') |
|
2891 | expecthg = os.path.join(self._pythondir, b'mercurial') | |
2892 | actualhg = self._gethgpath() |
|
2892 | actualhg = self._gethgpath() | |
2893 | if os.path.abspath(actualhg) != os.path.abspath(expecthg): |
|
2893 | if os.path.abspath(actualhg) != os.path.abspath(expecthg): | |
2894 | sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' |
|
2894 | sys.stderr.write('warning: %s with unexpected mercurial lib: %s\n' | |
2895 | ' (expected %s)\n' |
|
2895 | ' (expected %s)\n' | |
2896 | % (verb, actualhg, expecthg)) |
|
2896 | % (verb, actualhg, expecthg)) | |
2897 | def _gethgpath(self): |
|
2897 | def _gethgpath(self): | |
2898 | """Return the path to the mercurial package that is actually found by |
|
2898 | """Return the path to the mercurial package that is actually found by | |
2899 | the current Python interpreter.""" |
|
2899 | the current Python interpreter.""" | |
2900 | if self._hgpath is not None: |
|
2900 | if self._hgpath is not None: | |
2901 | return self._hgpath |
|
2901 | return self._hgpath | |
2902 |
|
2902 | |||
2903 | cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"' |
|
2903 | cmd = b'%s -c "import mercurial; print (mercurial.__path__[0])"' | |
2904 | cmd = cmd % PYTHON |
|
2904 | cmd = cmd % PYTHON | |
2905 | if PYTHON3: |
|
2905 | if PYTHON3: | |
2906 | cmd = _strpath(cmd) |
|
2906 | cmd = _strpath(cmd) | |
2907 | pipe = os.popen(cmd) |
|
2907 | pipe = os.popen(cmd) | |
2908 | try: |
|
2908 | try: | |
2909 | self._hgpath = _bytespath(pipe.read().strip()) |
|
2909 | self._hgpath = _bytespath(pipe.read().strip()) | |
2910 | finally: |
|
2910 | finally: | |
2911 | pipe.close() |
|
2911 | pipe.close() | |
2912 |
|
2912 | |||
2913 | return self._hgpath |
|
2913 | return self._hgpath | |
2914 |
|
2914 | |||
2915 | def _installchg(self): |
|
2915 | def _installchg(self): | |
2916 | """Install chg into the test environment""" |
|
2916 | """Install chg into the test environment""" | |
2917 | vlog('# Performing temporary installation of CHG') |
|
2917 | vlog('# Performing temporary installation of CHG') | |
2918 | assert os.path.dirname(self._bindir) == self._installdir |
|
2918 | assert os.path.dirname(self._bindir) == self._installdir | |
2919 | assert self._hgroot, 'must be called after _installhg()' |
|
2919 | assert self._hgroot, 'must be called after _installhg()' | |
2920 | cmd = (b'"%(make)s" clean install PREFIX="%(prefix)s"' |
|
2920 | cmd = (b'"%(make)s" clean install PREFIX="%(prefix)s"' | |
2921 | % {b'make': 'make', # TODO: switch by option or environment? |
|
2921 | % {b'make': 'make', # TODO: switch by option or environment? | |
2922 | b'prefix': self._installdir}) |
|
2922 | b'prefix': self._installdir}) | |
2923 | cwd = os.path.join(self._hgroot, b'contrib', b'chg') |
|
2923 | cwd = os.path.join(self._hgroot, b'contrib', b'chg') | |
2924 | vlog("# Running", cmd) |
|
2924 | vlog("# Running", cmd) | |
2925 | proc = subprocess.Popen(cmd, shell=True, cwd=cwd, |
|
2925 | proc = subprocess.Popen(cmd, shell=True, cwd=cwd, | |
2926 | stdin=subprocess.PIPE, stdout=subprocess.PIPE, |
|
2926 | stdin=subprocess.PIPE, stdout=subprocess.PIPE, | |
2927 | stderr=subprocess.STDOUT) |
|
2927 | stderr=subprocess.STDOUT) | |
2928 | out, _err = proc.communicate() |
|
2928 | out, _err = proc.communicate() | |
2929 | if proc.returncode != 0: |
|
2929 | if proc.returncode != 0: | |
2930 | if PYTHON3: |
|
2930 | if PYTHON3: | |
2931 | sys.stdout.buffer.write(out) |
|
2931 | sys.stdout.buffer.write(out) | |
2932 | else: |
|
2932 | else: | |
2933 | sys.stdout.write(out) |
|
2933 | sys.stdout.write(out) | |
2934 | sys.exit(1) |
|
2934 | sys.exit(1) | |
2935 |
|
2935 | |||
2936 | def _outputcoverage(self): |
|
2936 | def _outputcoverage(self): | |
2937 | """Produce code coverage output.""" |
|
2937 | """Produce code coverage output.""" | |
2938 | import coverage |
|
2938 | import coverage | |
2939 | coverage = coverage.coverage |
|
2939 | coverage = coverage.coverage | |
2940 |
|
2940 | |||
2941 | vlog('# Producing coverage report') |
|
2941 | vlog('# Producing coverage report') | |
2942 | # chdir is the easiest way to get short, relative paths in the |
|
2942 | # chdir is the easiest way to get short, relative paths in the | |
2943 | # output. |
|
2943 | # output. | |
2944 | os.chdir(self._hgroot) |
|
2944 | os.chdir(self._hgroot) | |
2945 | covdir = os.path.join(self._installdir, '..', 'coverage') |
|
2945 | covdir = os.path.join(self._installdir, '..', 'coverage') | |
2946 | cov = coverage(data_file=os.path.join(covdir, 'cov')) |
|
2946 | cov = coverage(data_file=os.path.join(covdir, 'cov')) | |
2947 |
|
2947 | |||
2948 | # Map install directory paths back to source directory. |
|
2948 | # Map install directory paths back to source directory. | |
2949 | cov.config.paths['srcdir'] = ['.', self._pythondir] |
|
2949 | cov.config.paths['srcdir'] = ['.', self._pythondir] | |
2950 |
|
2950 | |||
2951 | cov.combine() |
|
2951 | cov.combine() | |
2952 |
|
2952 | |||
2953 | omit = [os.path.join(x, '*') for x in [self._bindir, self._testdir]] |
|
2953 | omit = [os.path.join(x, '*') for x in [self._bindir, self._testdir]] | |
2954 | cov.report(ignore_errors=True, omit=omit) |
|
2954 | cov.report(ignore_errors=True, omit=omit) | |
2955 |
|
2955 | |||
2956 | if self.options.htmlcov: |
|
2956 | if self.options.htmlcov: | |
2957 | htmldir = os.path.join(self._outputdir, 'htmlcov') |
|
2957 | htmldir = os.path.join(self._outputdir, 'htmlcov') | |
2958 | cov.html_report(directory=htmldir, omit=omit) |
|
2958 | cov.html_report(directory=htmldir, omit=omit) | |
2959 | if self.options.annotate: |
|
2959 | if self.options.annotate: | |
2960 | adir = os.path.join(self._outputdir, 'annotated') |
|
2960 | adir = os.path.join(self._outputdir, 'annotated') | |
2961 | if not os.path.isdir(adir): |
|
2961 | if not os.path.isdir(adir): | |
2962 | os.mkdir(adir) |
|
2962 | os.mkdir(adir) | |
2963 | cov.annotate(directory=adir, omit=omit) |
|
2963 | cov.annotate(directory=adir, omit=omit) | |
2964 |
|
2964 | |||
2965 | def _findprogram(self, program): |
|
2965 | def _findprogram(self, program): | |
2966 | """Search PATH for a executable program""" |
|
2966 | """Search PATH for a executable program""" | |
2967 | dpb = _bytespath(os.defpath) |
|
2967 | dpb = _bytespath(os.defpath) | |
2968 | sepb = _bytespath(os.pathsep) |
|
2968 | sepb = _bytespath(os.pathsep) | |
2969 | for p in osenvironb.get(b'PATH', dpb).split(sepb): |
|
2969 | for p in osenvironb.get(b'PATH', dpb).split(sepb): | |
2970 | name = os.path.join(p, program) |
|
2970 | name = os.path.join(p, program) | |
2971 | if os.name == 'nt' or os.access(name, os.X_OK): |
|
2971 | if os.name == 'nt' or os.access(name, os.X_OK): | |
2972 | return name |
|
2972 | return name | |
2973 | return None |
|
2973 | return None | |
2974 |
|
2974 | |||
2975 | def _checktools(self): |
|
2975 | def _checktools(self): | |
2976 | """Ensure tools required to run tests are present.""" |
|
2976 | """Ensure tools required to run tests are present.""" | |
2977 | for p in self.REQUIREDTOOLS: |
|
2977 | for p in self.REQUIREDTOOLS: | |
2978 | if os.name == 'nt' and not p.endswith('.exe'): |
|
2978 | if os.name == 'nt' and not p.endswith('.exe'): | |
2979 | p += '.exe' |
|
2979 | p += '.exe' | |
2980 | found = self._findprogram(p) |
|
2980 | found = self._findprogram(p) | |
2981 | if found: |
|
2981 | if found: | |
2982 | vlog("# Found prerequisite", p, "at", found) |
|
2982 | vlog("# Found prerequisite", p, "at", found) | |
2983 | else: |
|
2983 | else: | |
2984 | print("WARNING: Did not find prerequisite tool: %s " % |
|
2984 | print("WARNING: Did not find prerequisite tool: %s " % | |
2985 | p.decode("utf-8")) |
|
2985 | p.decode("utf-8")) | |
2986 |
|
2986 | |||
2987 | def aggregateexceptions(path): |
|
2987 | def aggregateexceptions(path): | |
2988 | exceptions = collections.Counter() |
|
2988 | exceptions = collections.Counter() | |
2989 |
|
2989 | |||
2990 | for f in os.listdir(path): |
|
2990 | for f in os.listdir(path): | |
2991 | with open(os.path.join(path, f), 'rb') as fh: |
|
2991 | with open(os.path.join(path, f), 'rb') as fh: | |
2992 | data = fh.read().split(b'\0') |
|
2992 | data = fh.read().split(b'\0') | |
2993 | if len(data) != 4: |
|
2993 | if len(data) != 4: | |
2994 | continue |
|
2994 | continue | |
2995 |
|
2995 | |||
2996 | exc, mainframe, hgframe, hgline = data |
|
2996 | exc, mainframe, hgframe, hgline = data | |
2997 | exc = exc.decode('utf-8') |
|
2997 | exc = exc.decode('utf-8') | |
2998 | mainframe = mainframe.decode('utf-8') |
|
2998 | mainframe = mainframe.decode('utf-8') | |
2999 | hgframe = hgframe.decode('utf-8') |
|
2999 | hgframe = hgframe.decode('utf-8') | |
3000 | hgline = hgline.decode('utf-8') |
|
3000 | hgline = hgline.decode('utf-8') | |
3001 | exceptions[(hgframe, hgline, exc)] += 1 |
|
3001 | exceptions[(hgframe, hgline, exc)] += 1 | |
3002 |
|
3002 | |||
3003 | return exceptions |
|
3003 | return exceptions | |
3004 |
|
3004 | |||
3005 | if __name__ == '__main__': |
|
3005 | if __name__ == '__main__': | |
3006 | runner = TestRunner() |
|
3006 | runner = TestRunner() | |
3007 |
|
3007 | |||
3008 | try: |
|
3008 | try: | |
3009 | import msvcrt |
|
3009 | import msvcrt | |
3010 | msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
|
3010 | msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) | |
3011 | msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
|
3011 | msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | |
3012 | msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
|
3012 | msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) | |
3013 | except ImportError: |
|
3013 | except ImportError: | |
3014 | pass |
|
3014 | pass | |
3015 |
|
3015 | |||
3016 | sys.exit(runner.run(sys.argv[1:])) |
|
3016 | sys.exit(runner.run(sys.argv[1:])) |
@@ -1,1584 +1,1583 b'' | |||||
1 | This file tests the behavior of run-tests.py itself. |
|
1 | This file tests the behavior of run-tests.py itself. | |
2 |
|
2 | |||
3 | Avoid interference from actual test env: |
|
3 | Avoid interference from actual test env: | |
4 |
|
4 | |||
5 | $ . "$TESTDIR/helper-runtests.sh" |
|
5 | $ . "$TESTDIR/helper-runtests.sh" | |
6 |
|
6 | |||
7 | Smoke test with install |
|
7 | Smoke test with install | |
8 | ============ |
|
8 | ============ | |
9 |
|
9 | |||
10 | $ run-tests.py $HGTEST_RUN_TESTS_PURE -l |
|
10 | $ run-tests.py $HGTEST_RUN_TESTS_PURE -l | |
11 |
|
11 | |||
12 | # Ran 0 tests, 0 skipped, 0 failed. |
|
12 | # Ran 0 tests, 0 skipped, 0 failed. | |
13 |
|
13 | |||
14 | Define a helper to avoid the install step |
|
14 | Define a helper to avoid the install step | |
15 | ============= |
|
15 | ============= | |
16 | $ rt() |
|
16 | $ rt() | |
17 | > { |
|
17 | > { | |
18 | > run-tests.py --with-hg=`which hg` "$@" |
|
18 | > run-tests.py --with-hg=`which hg` "$@" | |
19 | > } |
|
19 | > } | |
20 |
|
20 | |||
21 | error paths |
|
21 | error paths | |
22 |
|
22 | |||
23 | #if symlink |
|
23 | #if symlink | |
24 | $ ln -s `which true` hg |
|
24 | $ ln -s `which true` hg | |
25 | $ run-tests.py --with-hg=./hg |
|
25 | $ run-tests.py --with-hg=./hg | |
26 | warning: --with-hg should specify an hg script |
|
26 | warning: --with-hg should specify an hg script | |
27 |
|
27 | |||
28 | # Ran 0 tests, 0 skipped, 0 failed. |
|
28 | # Ran 0 tests, 0 skipped, 0 failed. | |
29 | $ rm hg |
|
29 | $ rm hg | |
30 | #endif |
|
30 | #endif | |
31 |
|
31 | |||
32 | #if execbit |
|
32 | #if execbit | |
33 | $ touch hg |
|
33 | $ touch hg | |
34 | $ run-tests.py --with-hg=./hg |
|
34 | $ run-tests.py --with-hg=./hg | |
35 | usage: run-tests.py [options] [tests] |
|
35 | usage: run-tests.py [options] [tests] | |
36 | run-tests.py: error: --with-hg must specify an executable hg script |
|
36 | run-tests.py: error: --with-hg must specify an executable hg script | |
37 | [2] |
|
37 | [2] | |
38 | $ rm hg |
|
38 | $ rm hg | |
39 | #endif |
|
39 | #endif | |
40 |
|
40 | |||
41 | Features for testing optional lines |
|
41 | Features for testing optional lines | |
42 | =================================== |
|
42 | =================================== | |
43 |
|
43 | |||
44 | $ cat > hghaveaddon.py <<EOF |
|
44 | $ cat > hghaveaddon.py <<EOF | |
45 | > import hghave |
|
45 | > import hghave | |
46 | > @hghave.check("custom", "custom hghave feature") |
|
46 | > @hghave.check("custom", "custom hghave feature") | |
47 | > def has_custom(): |
|
47 | > def has_custom(): | |
48 | > return True |
|
48 | > return True | |
49 | > @hghave.check("missing", "missing hghave feature") |
|
49 | > @hghave.check("missing", "missing hghave feature") | |
50 | > def has_missing(): |
|
50 | > def has_missing(): | |
51 | > return False |
|
51 | > return False | |
52 | > EOF |
|
52 | > EOF | |
53 |
|
53 | |||
54 | an empty test |
|
54 | an empty test | |
55 | ======================= |
|
55 | ======================= | |
56 |
|
56 | |||
57 | $ touch test-empty.t |
|
57 | $ touch test-empty.t | |
58 | $ rt |
|
58 | $ rt | |
59 | . |
|
59 | . | |
60 | # Ran 1 tests, 0 skipped, 0 failed. |
|
60 | # Ran 1 tests, 0 skipped, 0 failed. | |
61 | $ rm test-empty.t |
|
61 | $ rm test-empty.t | |
62 |
|
62 | |||
63 | a succesful test |
|
63 | a succesful test | |
64 | ======================= |
|
64 | ======================= | |
65 |
|
65 | |||
66 | $ cat > test-success.t << EOF |
|
66 | $ cat > test-success.t << EOF | |
67 | > $ echo babar |
|
67 | > $ echo babar | |
68 | > babar |
|
68 | > babar | |
69 | > $ echo xyzzy |
|
69 | > $ echo xyzzy | |
70 | > dont_print (?) |
|
70 | > dont_print (?) | |
71 | > nothing[42]line (re) (?) |
|
71 | > nothing[42]line (re) (?) | |
72 | > never*happens (glob) (?) |
|
72 | > never*happens (glob) (?) | |
73 | > more_nothing (?) |
|
73 | > more_nothing (?) | |
74 | > xyzzy |
|
74 | > xyzzy | |
75 | > nor this (?) |
|
75 | > nor this (?) | |
76 | > $ printf 'abc\ndef\nxyz\n' |
|
76 | > $ printf 'abc\ndef\nxyz\n' | |
77 | > 123 (?) |
|
77 | > 123 (?) | |
78 | > abc |
|
78 | > abc | |
79 | > def (?) |
|
79 | > def (?) | |
80 | > 456 (?) |
|
80 | > 456 (?) | |
81 | > xyz |
|
81 | > xyz | |
82 | > $ printf 'zyx\nwvu\ntsr\n' |
|
82 | > $ printf 'zyx\nwvu\ntsr\n' | |
83 | > abc (?) |
|
83 | > abc (?) | |
84 | > zyx (custom !) |
|
84 | > zyx (custom !) | |
85 | > wvu |
|
85 | > wvu | |
86 | > no_print (no-custom !) |
|
86 | > no_print (no-custom !) | |
87 | > tsr (no-missing !) |
|
87 | > tsr (no-missing !) | |
88 | > missing (missing !) |
|
88 | > missing (missing !) | |
89 | > EOF |
|
89 | > EOF | |
90 |
|
90 | |||
91 | $ rt |
|
91 | $ rt | |
92 | . |
|
92 | . | |
93 | # Ran 1 tests, 0 skipped, 0 failed. |
|
93 | # Ran 1 tests, 0 skipped, 0 failed. | |
94 |
|
94 | |||
95 | failing test |
|
95 | failing test | |
96 | ================== |
|
96 | ================== | |
97 |
|
97 | |||
98 | test churn with globs |
|
98 | test churn with globs | |
99 | $ cat > test-failure.t <<EOF |
|
99 | $ cat > test-failure.t <<EOF | |
100 | > $ echo "bar-baz"; echo "bar-bad"; echo foo |
|
100 | > $ echo "bar-baz"; echo "bar-bad"; echo foo | |
101 | > bar*bad (glob) |
|
101 | > bar*bad (glob) | |
102 | > bar*baz (glob) |
|
102 | > bar*baz (glob) | |
103 | > | fo (re) |
|
103 | > | fo (re) | |
104 | > EOF |
|
104 | > EOF | |
105 | $ rt test-failure.t |
|
105 | $ rt test-failure.t | |
106 |
|
106 | |||
107 | --- $TESTTMP/test-failure.t |
|
107 | --- $TESTTMP/test-failure.t | |
108 | +++ $TESTTMP/test-failure.t.err |
|
108 | +++ $TESTTMP/test-failure.t.err | |
109 | @@ -1,4 +1,4 @@ |
|
109 | @@ -1,4 +1,4 @@ | |
110 | $ echo "bar-baz"; echo "bar-bad"; echo foo |
|
110 | $ echo "bar-baz"; echo "bar-bad"; echo foo | |
111 | + bar*baz (glob) |
|
111 | + bar*baz (glob) | |
112 | bar*bad (glob) |
|
112 | bar*bad (glob) | |
113 | - bar*baz (glob) |
|
113 | - bar*baz (glob) | |
114 | - | fo (re) |
|
114 | - | fo (re) | |
115 | + foo |
|
115 | + foo | |
116 |
|
116 | |||
117 | ERROR: test-failure.t output changed |
|
117 | ERROR: test-failure.t output changed | |
118 | ! |
|
118 | ! | |
119 | Failed test-failure.t: output changed |
|
119 | Failed test-failure.t: output changed | |
120 | # Ran 1 tests, 0 skipped, 1 failed. |
|
120 | # Ran 1 tests, 0 skipped, 1 failed. | |
121 | python hash seed: * (glob) |
|
121 | python hash seed: * (glob) | |
122 | [1] |
|
122 | [1] | |
123 |
|
123 | |||
124 | test diff colorisation |
|
124 | test diff colorisation | |
125 |
|
125 | |||
126 | #if no-windows pygments |
|
126 | #if no-windows pygments | |
127 | $ rt test-failure.t --color always |
|
127 | $ rt test-failure.t --color always | |
128 |
|
128 | |||
129 | \x1b[38;5;124m--- $TESTTMP/test-failure.t\x1b[39m (esc) |
|
129 | \x1b[38;5;124m--- $TESTTMP/test-failure.t\x1b[39m (esc) | |
130 | \x1b[38;5;34m+++ $TESTTMP/test-failure.t.err\x1b[39m (esc) |
|
130 | \x1b[38;5;34m+++ $TESTTMP/test-failure.t.err\x1b[39m (esc) | |
131 | \x1b[38;5;90;01m@@ -1,4 +1,4 @@\x1b[39;00m (esc) |
|
131 | \x1b[38;5;90;01m@@ -1,4 +1,4 @@\x1b[39;00m (esc) | |
132 | $ echo "bar-baz"; echo "bar-bad"; echo foo |
|
132 | $ echo "bar-baz"; echo "bar-bad"; echo foo | |
133 | \x1b[38;5;34m+ bar*baz (glob)\x1b[39m (esc) |
|
133 | \x1b[38;5;34m+ bar*baz (glob)\x1b[39m (esc) | |
134 | bar*bad (glob) |
|
134 | bar*bad (glob) | |
135 | \x1b[38;5;124m- bar*baz (glob)\x1b[39m (esc) |
|
135 | \x1b[38;5;124m- bar*baz (glob)\x1b[39m (esc) | |
136 | \x1b[38;5;124m- | fo (re)\x1b[39m (esc) |
|
136 | \x1b[38;5;124m- | fo (re)\x1b[39m (esc) | |
137 | \x1b[38;5;34m+ foo\x1b[39m (esc) |
|
137 | \x1b[38;5;34m+ foo\x1b[39m (esc) | |
138 |
|
138 | |||
139 | \x1b[38;5;88mERROR: \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m output changed\x1b[39m (esc) |
|
139 | \x1b[38;5;88mERROR: \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m output changed\x1b[39m (esc) | |
140 | ! |
|
140 | ! | |
141 | \x1b[38;5;88mFailed \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m: output changed\x1b[39m (esc) |
|
141 | \x1b[38;5;88mFailed \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m: output changed\x1b[39m (esc) | |
142 | # Ran 1 tests, 0 skipped, 1 failed. |
|
142 | # Ran 1 tests, 0 skipped, 1 failed. | |
143 | python hash seed: * (glob) |
|
143 | python hash seed: * (glob) | |
144 | [1] |
|
144 | [1] | |
145 |
|
145 | |||
146 | $ rt test-failure.t 2> tmp.log |
|
146 | $ rt test-failure.t 2> tmp.log | |
147 | [1] |
|
147 | [1] | |
148 | $ cat tmp.log |
|
148 | $ cat tmp.log | |
149 |
|
149 | |||
150 | --- $TESTTMP/test-failure.t |
|
150 | --- $TESTTMP/test-failure.t | |
151 | +++ $TESTTMP/test-failure.t.err |
|
151 | +++ $TESTTMP/test-failure.t.err | |
152 | @@ -1,4 +1,4 @@ |
|
152 | @@ -1,4 +1,4 @@ | |
153 | $ echo "bar-baz"; echo "bar-bad"; echo foo |
|
153 | $ echo "bar-baz"; echo "bar-bad"; echo foo | |
154 | + bar*baz (glob) |
|
154 | + bar*baz (glob) | |
155 | bar*bad (glob) |
|
155 | bar*bad (glob) | |
156 | - bar*baz (glob) |
|
156 | - bar*baz (glob) | |
157 | - | fo (re) |
|
157 | - | fo (re) | |
158 | + foo |
|
158 | + foo | |
159 |
|
159 | |||
160 | ERROR: test-failure.t output changed |
|
160 | ERROR: test-failure.t output changed | |
161 | ! |
|
161 | ! | |
162 | Failed test-failure.t: output changed |
|
162 | Failed test-failure.t: output changed | |
163 | # Ran 1 tests, 0 skipped, 1 failed. |
|
163 | # Ran 1 tests, 0 skipped, 1 failed. | |
164 | python hash seed: * (glob) |
|
164 | python hash seed: * (glob) | |
165 | #endif |
|
165 | #endif | |
166 |
|
166 | |||
167 | $ cat > test-failure.t << EOF |
|
167 | $ cat > test-failure.t << EOF | |
168 | > $ true |
|
168 | > $ true | |
169 | > should go away (true !) |
|
169 | > should go away (true !) | |
170 | > $ true |
|
170 | > $ true | |
171 | > should stay (false !) |
|
171 | > should stay (false !) | |
172 | > |
|
172 | > | |
173 | > Should remove first line, not second or third |
|
173 | > Should remove first line, not second or third | |
174 | > $ echo 'testing' |
|
174 | > $ echo 'testing' | |
175 | > baz*foo (glob) (true !) |
|
175 | > baz*foo (glob) (true !) | |
176 | > foobar*foo (glob) (false !) |
|
176 | > foobar*foo (glob) (false !) | |
177 | > te*ting (glob) (true !) |
|
177 | > te*ting (glob) (true !) | |
178 | > |
|
178 | > | |
179 | > Should keep first two lines, remove third and last |
|
179 | > Should keep first two lines, remove third and last | |
180 | > $ echo 'testing' |
|
180 | > $ echo 'testing' | |
181 | > test.ng (re) (true !) |
|
181 | > test.ng (re) (true !) | |
182 | > foo.ar (re) (false !) |
|
182 | > foo.ar (re) (false !) | |
183 | > b.r (re) (true !) |
|
183 | > b.r (re) (true !) | |
184 | > missing (?) |
|
184 | > missing (?) | |
185 | > awol (true !) |
|
185 | > awol (true !) | |
186 | > |
|
186 | > | |
187 | > The "missing" line should stay, even though awol is dropped |
|
187 | > The "missing" line should stay, even though awol is dropped | |
188 | > $ echo 'testing' |
|
188 | > $ echo 'testing' | |
189 | > test.ng (re) (true !) |
|
189 | > test.ng (re) (true !) | |
190 | > foo.ar (?) |
|
190 | > foo.ar (?) | |
191 | > awol |
|
191 | > awol | |
192 | > missing (?) |
|
192 | > missing (?) | |
193 | > EOF |
|
193 | > EOF | |
194 | $ rt test-failure.t |
|
194 | $ rt test-failure.t | |
195 |
|
195 | |||
196 | --- $TESTTMP/test-failure.t |
|
196 | --- $TESTTMP/test-failure.t | |
197 | +++ $TESTTMP/test-failure.t.err |
|
197 | +++ $TESTTMP/test-failure.t.err | |
198 | @@ -1,11 +1,9 @@ |
|
198 | @@ -1,11 +1,9 @@ | |
199 | $ true |
|
199 | $ true | |
200 | - should go away (true !) |
|
200 | - should go away (true !) | |
201 | $ true |
|
201 | $ true | |
202 | should stay (false !) |
|
202 | should stay (false !) | |
203 |
|
203 | |||
204 | Should remove first line, not second or third |
|
204 | Should remove first line, not second or third | |
205 | $ echo 'testing' |
|
205 | $ echo 'testing' | |
206 | - baz*foo (glob) (true !) |
|
206 | - baz*foo (glob) (true !) | |
207 | foobar*foo (glob) (false !) |
|
207 | foobar*foo (glob) (false !) | |
208 | te*ting (glob) (true !) |
|
208 | te*ting (glob) (true !) | |
209 |
|
209 | |||
210 | foo.ar (re) (false !) |
|
210 | foo.ar (re) (false !) | |
211 | missing (?) |
|
211 | missing (?) | |
212 | @@ -13,13 +11,10 @@ |
|
212 | @@ -13,13 +11,10 @@ | |
213 | $ echo 'testing' |
|
213 | $ echo 'testing' | |
214 | test.ng (re) (true !) |
|
214 | test.ng (re) (true !) | |
215 | foo.ar (re) (false !) |
|
215 | foo.ar (re) (false !) | |
216 | - b.r (re) (true !) |
|
216 | - b.r (re) (true !) | |
217 | missing (?) |
|
217 | missing (?) | |
218 | - awol (true !) |
|
218 | - awol (true !) | |
219 |
|
219 | |||
220 | The "missing" line should stay, even though awol is dropped |
|
220 | The "missing" line should stay, even though awol is dropped | |
221 | $ echo 'testing' |
|
221 | $ echo 'testing' | |
222 | test.ng (re) (true !) |
|
222 | test.ng (re) (true !) | |
223 | foo.ar (?) |
|
223 | foo.ar (?) | |
224 | - awol |
|
224 | - awol | |
225 | missing (?) |
|
225 | missing (?) | |
226 |
|
226 | |||
227 | ERROR: test-failure.t output changed |
|
227 | ERROR: test-failure.t output changed | |
228 | ! |
|
228 | ! | |
229 | Failed test-failure.t: output changed |
|
229 | Failed test-failure.t: output changed | |
230 | # Ran 1 tests, 0 skipped, 1 failed. |
|
230 | # Ran 1 tests, 0 skipped, 1 failed. | |
231 | python hash seed: * (glob) |
|
231 | python hash seed: * (glob) | |
232 | [1] |
|
232 | [1] | |
233 |
|
233 | |||
234 | basic failing test |
|
234 | basic failing test | |
235 | $ cat > test-failure.t << EOF |
|
235 | $ cat > test-failure.t << EOF | |
236 | > $ echo babar |
|
236 | > $ echo babar | |
237 | > rataxes |
|
237 | > rataxes | |
238 | > This is a noop statement so that |
|
238 | > This is a noop statement so that | |
239 | > this test is still more bytes than success. |
|
239 | > this test is still more bytes than success. | |
240 | > pad pad pad pad............................................................ |
|
240 | > pad pad pad pad............................................................ | |
241 | > pad pad pad pad............................................................ |
|
241 | > pad pad pad pad............................................................ | |
242 | > pad pad pad pad............................................................ |
|
242 | > pad pad pad pad............................................................ | |
243 | > pad pad pad pad............................................................ |
|
243 | > pad pad pad pad............................................................ | |
244 | > pad pad pad pad............................................................ |
|
244 | > pad pad pad pad............................................................ | |
245 | > pad pad pad pad............................................................ |
|
245 | > pad pad pad pad............................................................ | |
246 | > EOF |
|
246 | > EOF | |
247 |
|
247 | |||
248 | >>> fh = open('test-failure-unicode.t', 'wb') |
|
248 | >>> fh = open('test-failure-unicode.t', 'wb') | |
249 | >>> fh.write(u' $ echo babar\u03b1\n'.encode('utf-8')) and None |
|
249 | >>> fh.write(u' $ echo babar\u03b1\n'.encode('utf-8')) and None | |
250 | >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8')) and None |
|
250 | >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8')) and None | |
251 |
|
251 | |||
252 | $ rt |
|
252 | $ rt | |
253 |
|
253 | |||
254 | --- $TESTTMP/test-failure.t |
|
254 | --- $TESTTMP/test-failure.t | |
255 | +++ $TESTTMP/test-failure.t.err |
|
255 | +++ $TESTTMP/test-failure.t.err | |
256 | @@ -1,5 +1,5 @@ |
|
256 | @@ -1,5 +1,5 @@ | |
257 | $ echo babar |
|
257 | $ echo babar | |
258 | - rataxes |
|
258 | - rataxes | |
259 | + babar |
|
259 | + babar | |
260 | This is a noop statement so that |
|
260 | This is a noop statement so that | |
261 | this test is still more bytes than success. |
|
261 | this test is still more bytes than success. | |
262 | pad pad pad pad............................................................ |
|
262 | pad pad pad pad............................................................ | |
263 |
|
263 | |||
264 | ERROR: test-failure.t output changed |
|
264 | ERROR: test-failure.t output changed | |
265 | !. |
|
265 | !. | |
266 | --- $TESTTMP/test-failure-unicode.t |
|
266 | --- $TESTTMP/test-failure-unicode.t | |
267 | +++ $TESTTMP/test-failure-unicode.t.err |
|
267 | +++ $TESTTMP/test-failure-unicode.t.err | |
268 | @@ -1,2 +1,2 @@ |
|
268 | @@ -1,2 +1,2 @@ | |
269 | $ echo babar\xce\xb1 (esc) |
|
269 | $ echo babar\xce\xb1 (esc) | |
270 | - l\xce\xb5\xce\xb5t (esc) |
|
270 | - l\xce\xb5\xce\xb5t (esc) | |
271 | + babar\xce\xb1 (esc) |
|
271 | + babar\xce\xb1 (esc) | |
272 |
|
272 | |||
273 | ERROR: test-failure-unicode.t output changed |
|
273 | ERROR: test-failure-unicode.t output changed | |
274 | ! |
|
274 | ! | |
275 | Failed test-failure.t: output changed |
|
275 | Failed test-failure.t: output changed | |
276 | Failed test-failure-unicode.t: output changed |
|
276 | Failed test-failure-unicode.t: output changed | |
277 | # Ran 3 tests, 0 skipped, 2 failed. |
|
277 | # Ran 3 tests, 0 skipped, 2 failed. | |
278 | python hash seed: * (glob) |
|
278 | python hash seed: * (glob) | |
279 | [1] |
|
279 | [1] | |
280 |
|
280 | |||
281 | test --outputdir |
|
281 | test --outputdir | |
282 | $ mkdir output |
|
282 | $ mkdir output | |
283 | $ rt --outputdir output |
|
283 | $ rt --outputdir output | |
284 |
|
284 | |||
285 | --- $TESTTMP/test-failure.t |
|
285 | --- $TESTTMP/test-failure.t | |
286 | +++ $TESTTMP/output/test-failure.t.err |
|
286 | +++ $TESTTMP/output/test-failure.t.err | |
287 | @@ -1,5 +1,5 @@ |
|
287 | @@ -1,5 +1,5 @@ | |
288 | $ echo babar |
|
288 | $ echo babar | |
289 | - rataxes |
|
289 | - rataxes | |
290 | + babar |
|
290 | + babar | |
291 | This is a noop statement so that |
|
291 | This is a noop statement so that | |
292 | this test is still more bytes than success. |
|
292 | this test is still more bytes than success. | |
293 | pad pad pad pad............................................................ |
|
293 | pad pad pad pad............................................................ | |
294 |
|
294 | |||
295 | ERROR: test-failure.t output changed |
|
295 | ERROR: test-failure.t output changed | |
296 | !. |
|
296 | !. | |
297 | --- $TESTTMP/test-failure-unicode.t |
|
297 | --- $TESTTMP/test-failure-unicode.t | |
298 | +++ $TESTTMP/output/test-failure-unicode.t.err |
|
298 | +++ $TESTTMP/output/test-failure-unicode.t.err | |
299 | @@ -1,2 +1,2 @@ |
|
299 | @@ -1,2 +1,2 @@ | |
300 | $ echo babar\xce\xb1 (esc) |
|
300 | $ echo babar\xce\xb1 (esc) | |
301 | - l\xce\xb5\xce\xb5t (esc) |
|
301 | - l\xce\xb5\xce\xb5t (esc) | |
302 | + babar\xce\xb1 (esc) |
|
302 | + babar\xce\xb1 (esc) | |
303 |
|
303 | |||
304 | ERROR: test-failure-unicode.t output changed |
|
304 | ERROR: test-failure-unicode.t output changed | |
305 | ! |
|
305 | ! | |
306 | Failed test-failure.t: output changed |
|
306 | Failed test-failure.t: output changed | |
307 | Failed test-failure-unicode.t: output changed |
|
307 | Failed test-failure-unicode.t: output changed | |
308 | # Ran 3 tests, 0 skipped, 2 failed. |
|
308 | # Ran 3 tests, 0 skipped, 2 failed. | |
309 | python hash seed: * (glob) |
|
309 | python hash seed: * (glob) | |
310 | [1] |
|
310 | [1] | |
311 | $ ls -a output |
|
311 | $ ls -a output | |
312 | . |
|
312 | . | |
313 | .. |
|
313 | .. | |
314 | .testtimes |
|
314 | .testtimes | |
315 | test-failure-unicode.t.err |
|
315 | test-failure-unicode.t.err | |
316 | test-failure.t.err |
|
316 | test-failure.t.err | |
317 |
|
317 | |||
318 | test --xunit support |
|
318 | test --xunit support | |
319 | $ rt --xunit=xunit.xml |
|
319 | $ rt --xunit=xunit.xml | |
320 |
|
320 | |||
321 | --- $TESTTMP/test-failure.t |
|
321 | --- $TESTTMP/test-failure.t | |
322 | +++ $TESTTMP/test-failure.t.err |
|
322 | +++ $TESTTMP/test-failure.t.err | |
323 | @@ -1,5 +1,5 @@ |
|
323 | @@ -1,5 +1,5 @@ | |
324 | $ echo babar |
|
324 | $ echo babar | |
325 | - rataxes |
|
325 | - rataxes | |
326 | + babar |
|
326 | + babar | |
327 | This is a noop statement so that |
|
327 | This is a noop statement so that | |
328 | this test is still more bytes than success. |
|
328 | this test is still more bytes than success. | |
329 | pad pad pad pad............................................................ |
|
329 | pad pad pad pad............................................................ | |
330 |
|
330 | |||
331 | ERROR: test-failure.t output changed |
|
331 | ERROR: test-failure.t output changed | |
332 | !. |
|
332 | !. | |
333 | --- $TESTTMP/test-failure-unicode.t |
|
333 | --- $TESTTMP/test-failure-unicode.t | |
334 | +++ $TESTTMP/test-failure-unicode.t.err |
|
334 | +++ $TESTTMP/test-failure-unicode.t.err | |
335 | @@ -1,2 +1,2 @@ |
|
335 | @@ -1,2 +1,2 @@ | |
336 | $ echo babar\xce\xb1 (esc) |
|
336 | $ echo babar\xce\xb1 (esc) | |
337 | - l\xce\xb5\xce\xb5t (esc) |
|
337 | - l\xce\xb5\xce\xb5t (esc) | |
338 | + babar\xce\xb1 (esc) |
|
338 | + babar\xce\xb1 (esc) | |
339 |
|
339 | |||
340 | ERROR: test-failure-unicode.t output changed |
|
340 | ERROR: test-failure-unicode.t output changed | |
341 | ! |
|
341 | ! | |
342 | Failed test-failure.t: output changed |
|
342 | Failed test-failure.t: output changed | |
343 | Failed test-failure-unicode.t: output changed |
|
343 | Failed test-failure-unicode.t: output changed | |
344 | # Ran 3 tests, 0 skipped, 2 failed. |
|
344 | # Ran 3 tests, 0 skipped, 2 failed. | |
345 | python hash seed: * (glob) |
|
345 | python hash seed: * (glob) | |
346 | [1] |
|
346 | [1] | |
347 | $ cat xunit.xml |
|
347 | $ cat xunit.xml | |
348 | <?xml version="1.0" encoding="utf-8"?> |
|
348 | <?xml version="1.0" encoding="utf-8"?> | |
349 | <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3"> |
|
349 | <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3"> | |
350 | <testcase name="test-success.t" time="*"/> (glob) |
|
350 | <testcase name="test-success.t" time="*"/> (glob) | |
351 | <testcase name="test-failure-unicode.t" time="*"> (glob) |
|
351 | <testcase name="test-failure-unicode.t" time="*"> (glob) | |
352 | <failure message="output changed" type="output-mismatch"> |
|
352 | <failure message="output changed" type="output-mismatch"> | |
353 | <![CDATA[--- $TESTTMP/test-failure-unicode.t |
|
353 | <![CDATA[--- $TESTTMP/test-failure-unicode.t | |
354 | +++ $TESTTMP/test-failure-unicode.t.err |
|
354 | +++ $TESTTMP/test-failure-unicode.t.err | |
355 | @@ -1,2 +1,2 @@ |
|
355 | @@ -1,2 +1,2 @@ | |
356 | $ echo babar\xce\xb1 (esc) |
|
356 | $ echo babar\xce\xb1 (esc) | |
357 | - l\xce\xb5\xce\xb5t (esc) |
|
357 | - l\xce\xb5\xce\xb5t (esc) | |
358 | + babar\xce\xb1 (esc) |
|
358 | + babar\xce\xb1 (esc) | |
359 | ]]> </failure> |
|
359 | ]]> </failure> | |
360 | </testcase> |
|
360 | </testcase> | |
361 | <testcase name="test-failure.t" time="*"> (glob) |
|
361 | <testcase name="test-failure.t" time="*"> (glob) | |
362 | <failure message="output changed" type="output-mismatch"> |
|
362 | <failure message="output changed" type="output-mismatch"> | |
363 | <![CDATA[--- $TESTTMP/test-failure.t |
|
363 | <![CDATA[--- $TESTTMP/test-failure.t | |
364 | +++ $TESTTMP/test-failure.t.err |
|
364 | +++ $TESTTMP/test-failure.t.err | |
365 | @@ -1,5 +1,5 @@ |
|
365 | @@ -1,5 +1,5 @@ | |
366 | $ echo babar |
|
366 | $ echo babar | |
367 | - rataxes |
|
367 | - rataxes | |
368 | + babar |
|
368 | + babar | |
369 | This is a noop statement so that |
|
369 | This is a noop statement so that | |
370 | this test is still more bytes than success. |
|
370 | this test is still more bytes than success. | |
371 | pad pad pad pad............................................................ |
|
371 | pad pad pad pad............................................................ | |
372 | ]]> </failure> |
|
372 | ]]> </failure> | |
373 | </testcase> |
|
373 | </testcase> | |
374 | </testsuite> |
|
374 | </testsuite> | |
375 |
|
375 | |||
376 | $ cat .testtimes |
|
376 | $ cat .testtimes | |
377 | test-failure-unicode.t * (glob) |
|
377 | test-failure-unicode.t * (glob) | |
378 | test-failure.t * (glob) |
|
378 | test-failure.t * (glob) | |
379 | test-success.t * (glob) |
|
379 | test-success.t * (glob) | |
380 |
|
380 | |||
381 | $ rt --list-tests |
|
381 | $ rt --list-tests | |
382 | test-failure-unicode.t |
|
382 | test-failure-unicode.t | |
383 | test-failure.t |
|
383 | test-failure.t | |
384 | test-success.t |
|
384 | test-success.t | |
385 |
|
385 | |||
386 | $ rt --list-tests --json |
|
386 | $ rt --list-tests --json | |
387 | test-failure-unicode.t |
|
387 | test-failure-unicode.t | |
388 | test-failure.t |
|
388 | test-failure.t | |
389 | test-success.t |
|
389 | test-success.t | |
390 | $ cat report.json |
|
390 | $ cat report.json | |
391 | testreport ={ |
|
391 | testreport ={ | |
392 | "test-failure-unicode.t": { |
|
392 | "test-failure-unicode.t": { | |
393 | "result": "success" |
|
393 | "result": "success" | |
394 | }, |
|
394 | }, | |
395 | "test-failure.t": { |
|
395 | "test-failure.t": { | |
396 | "result": "success" |
|
396 | "result": "success" | |
397 | }, |
|
397 | }, | |
398 | "test-success.t": { |
|
398 | "test-success.t": { | |
399 | "result": "success" |
|
399 | "result": "success" | |
400 | } |
|
400 | } | |
401 | } (no-eol) |
|
401 | } (no-eol) | |
402 |
|
402 | |||
403 | $ rt --list-tests --xunit=xunit.xml |
|
403 | $ rt --list-tests --xunit=xunit.xml | |
404 | test-failure-unicode.t |
|
404 | test-failure-unicode.t | |
405 | test-failure.t |
|
405 | test-failure.t | |
406 | test-success.t |
|
406 | test-success.t | |
407 | $ cat xunit.xml |
|
407 | $ cat xunit.xml | |
408 | <?xml version="1.0" encoding="utf-8"?> |
|
408 | <?xml version="1.0" encoding="utf-8"?> | |
409 | <testsuite errors="0" failures="0" name="run-tests" skipped="0" tests="0"> |
|
409 | <testsuite errors="0" failures="0" name="run-tests" skipped="0" tests="0"> | |
410 | <testcase name="test-failure-unicode.t"/> |
|
410 | <testcase name="test-failure-unicode.t"/> | |
411 | <testcase name="test-failure.t"/> |
|
411 | <testcase name="test-failure.t"/> | |
412 | <testcase name="test-success.t"/> |
|
412 | <testcase name="test-success.t"/> | |
413 | </testsuite> |
|
413 | </testsuite> | |
414 |
|
414 | |||
415 | $ rt --list-tests test-failure* --json --xunit=xunit.xml --outputdir output |
|
415 | $ rt --list-tests test-failure* --json --xunit=xunit.xml --outputdir output | |
416 | test-failure-unicode.t |
|
416 | test-failure-unicode.t | |
417 | test-failure.t |
|
417 | test-failure.t | |
418 | $ cat output/report.json |
|
418 | $ cat output/report.json | |
419 | testreport ={ |
|
419 | testreport ={ | |
420 | "test-failure-unicode.t": { |
|
420 | "test-failure-unicode.t": { | |
421 | "result": "success" |
|
421 | "result": "success" | |
422 | }, |
|
422 | }, | |
423 | "test-failure.t": { |
|
423 | "test-failure.t": { | |
424 | "result": "success" |
|
424 | "result": "success" | |
425 | } |
|
425 | } | |
426 | } (no-eol) |
|
426 | } (no-eol) | |
427 | $ cat xunit.xml |
|
427 | $ cat xunit.xml | |
428 | <?xml version="1.0" encoding="utf-8"?> |
|
428 | <?xml version="1.0" encoding="utf-8"?> | |
429 | <testsuite errors="0" failures="0" name="run-tests" skipped="0" tests="0"> |
|
429 | <testsuite errors="0" failures="0" name="run-tests" skipped="0" tests="0"> | |
430 | <testcase name="test-failure-unicode.t"/> |
|
430 | <testcase name="test-failure-unicode.t"/> | |
431 | <testcase name="test-failure.t"/> |
|
431 | <testcase name="test-failure.t"/> | |
432 | </testsuite> |
|
432 | </testsuite> | |
433 |
|
433 | |||
434 | $ rm test-failure-unicode.t |
|
434 | $ rm test-failure-unicode.t | |
435 |
|
435 | |||
436 | test for --retest |
|
436 | test for --retest | |
437 | ==================== |
|
437 | ==================== | |
438 |
|
438 | |||
439 | $ rt --retest |
|
439 | $ rt --retest | |
440 |
|
440 | |||
441 | --- $TESTTMP/test-failure.t |
|
441 | --- $TESTTMP/test-failure.t | |
442 | +++ $TESTTMP/test-failure.t.err |
|
442 | +++ $TESTTMP/test-failure.t.err | |
443 | @@ -1,5 +1,5 @@ |
|
443 | @@ -1,5 +1,5 @@ | |
444 | $ echo babar |
|
444 | $ echo babar | |
445 | - rataxes |
|
445 | - rataxes | |
446 | + babar |
|
446 | + babar | |
447 | This is a noop statement so that |
|
447 | This is a noop statement so that | |
448 | this test is still more bytes than success. |
|
448 | this test is still more bytes than success. | |
449 | pad pad pad pad............................................................ |
|
449 | pad pad pad pad............................................................ | |
450 |
|
450 | |||
451 | ERROR: test-failure.t output changed |
|
451 | ERROR: test-failure.t output changed | |
452 | ! |
|
452 | ! | |
453 | Failed test-failure.t: output changed |
|
453 | Failed test-failure.t: output changed | |
454 | # Ran 2 tests, 1 skipped, 1 failed. |
|
454 | # Ran 2 tests, 1 skipped, 1 failed. | |
455 | python hash seed: * (glob) |
|
455 | python hash seed: * (glob) | |
456 | [1] |
|
456 | [1] | |
457 |
|
457 | |||
458 | --retest works with --outputdir |
|
458 | --retest works with --outputdir | |
459 | $ rm -r output |
|
459 | $ rm -r output | |
460 | $ mkdir output |
|
460 | $ mkdir output | |
461 | $ mv test-failure.t.err output |
|
461 | $ mv test-failure.t.err output | |
462 | $ rt --retest --outputdir output |
|
462 | $ rt --retest --outputdir output | |
463 |
|
463 | |||
464 | --- $TESTTMP/test-failure.t |
|
464 | --- $TESTTMP/test-failure.t | |
465 | +++ $TESTTMP/output/test-failure.t.err |
|
465 | +++ $TESTTMP/output/test-failure.t.err | |
466 | @@ -1,5 +1,5 @@ |
|
466 | @@ -1,5 +1,5 @@ | |
467 | $ echo babar |
|
467 | $ echo babar | |
468 | - rataxes |
|
468 | - rataxes | |
469 | + babar |
|
469 | + babar | |
470 | This is a noop statement so that |
|
470 | This is a noop statement so that | |
471 | this test is still more bytes than success. |
|
471 | this test is still more bytes than success. | |
472 | pad pad pad pad............................................................ |
|
472 | pad pad pad pad............................................................ | |
473 |
|
473 | |||
474 | ERROR: test-failure.t output changed |
|
474 | ERROR: test-failure.t output changed | |
475 | ! |
|
475 | ! | |
476 | Failed test-failure.t: output changed |
|
476 | Failed test-failure.t: output changed | |
477 | # Ran 2 tests, 1 skipped, 1 failed. |
|
477 | # Ran 2 tests, 1 skipped, 1 failed. | |
478 | python hash seed: * (glob) |
|
478 | python hash seed: * (glob) | |
479 | [1] |
|
479 | [1] | |
480 |
|
480 | |||
481 | Selecting Tests To Run |
|
481 | Selecting Tests To Run | |
482 | ====================== |
|
482 | ====================== | |
483 |
|
483 | |||
484 | successful |
|
484 | successful | |
485 |
|
485 | |||
486 | $ rt test-success.t |
|
486 | $ rt test-success.t | |
487 | . |
|
487 | . | |
488 | # Ran 1 tests, 0 skipped, 0 failed. |
|
488 | # Ran 1 tests, 0 skipped, 0 failed. | |
489 |
|
489 | |||
490 | success w/ keyword |
|
490 | success w/ keyword | |
491 | $ rt -k xyzzy |
|
491 | $ rt -k xyzzy | |
492 | . |
|
492 | . | |
493 | # Ran 2 tests, 1 skipped, 0 failed. |
|
493 | # Ran 2 tests, 1 skipped, 0 failed. | |
494 |
|
494 | |||
495 | failed |
|
495 | failed | |
496 |
|
496 | |||
497 | $ rt test-failure.t |
|
497 | $ rt test-failure.t | |
498 |
|
498 | |||
499 | --- $TESTTMP/test-failure.t |
|
499 | --- $TESTTMP/test-failure.t | |
500 | +++ $TESTTMP/test-failure.t.err |
|
500 | +++ $TESTTMP/test-failure.t.err | |
501 | @@ -1,5 +1,5 @@ |
|
501 | @@ -1,5 +1,5 @@ | |
502 | $ echo babar |
|
502 | $ echo babar | |
503 | - rataxes |
|
503 | - rataxes | |
504 | + babar |
|
504 | + babar | |
505 | This is a noop statement so that |
|
505 | This is a noop statement so that | |
506 | this test is still more bytes than success. |
|
506 | this test is still more bytes than success. | |
507 | pad pad pad pad............................................................ |
|
507 | pad pad pad pad............................................................ | |
508 |
|
508 | |||
509 | ERROR: test-failure.t output changed |
|
509 | ERROR: test-failure.t output changed | |
510 | ! |
|
510 | ! | |
511 | Failed test-failure.t: output changed |
|
511 | Failed test-failure.t: output changed | |
512 | # Ran 1 tests, 0 skipped, 1 failed. |
|
512 | # Ran 1 tests, 0 skipped, 1 failed. | |
513 | python hash seed: * (glob) |
|
513 | python hash seed: * (glob) | |
514 | [1] |
|
514 | [1] | |
515 |
|
515 | |||
516 | failure w/ keyword |
|
516 | failure w/ keyword | |
517 | $ rt -k rataxes |
|
517 | $ rt -k rataxes | |
518 |
|
518 | |||
519 | --- $TESTTMP/test-failure.t |
|
519 | --- $TESTTMP/test-failure.t | |
520 | +++ $TESTTMP/test-failure.t.err |
|
520 | +++ $TESTTMP/test-failure.t.err | |
521 | @@ -1,5 +1,5 @@ |
|
521 | @@ -1,5 +1,5 @@ | |
522 | $ echo babar |
|
522 | $ echo babar | |
523 | - rataxes |
|
523 | - rataxes | |
524 | + babar |
|
524 | + babar | |
525 | This is a noop statement so that |
|
525 | This is a noop statement so that | |
526 | this test is still more bytes than success. |
|
526 | this test is still more bytes than success. | |
527 | pad pad pad pad............................................................ |
|
527 | pad pad pad pad............................................................ | |
528 |
|
528 | |||
529 | ERROR: test-failure.t output changed |
|
529 | ERROR: test-failure.t output changed | |
530 | ! |
|
530 | ! | |
531 | Failed test-failure.t: output changed |
|
531 | Failed test-failure.t: output changed | |
532 | # Ran 2 tests, 1 skipped, 1 failed. |
|
532 | # Ran 2 tests, 1 skipped, 1 failed. | |
533 | python hash seed: * (glob) |
|
533 | python hash seed: * (glob) | |
534 | [1] |
|
534 | [1] | |
535 |
|
535 | |||
536 | Verify that when a process fails to start we show a useful message |
|
536 | Verify that when a process fails to start we show a useful message | |
537 | ================================================================== |
|
537 | ================================================================== | |
538 |
|
538 | |||
539 | $ cat > test-serve-fail.t <<EOF |
|
539 | $ cat > test-serve-fail.t <<EOF | |
540 | > $ echo 'abort: child process failed to start blah' |
|
540 | > $ echo 'abort: child process failed to start blah' | |
541 | > EOF |
|
541 | > EOF | |
542 | $ rt test-serve-fail.t |
|
542 | $ rt test-serve-fail.t | |
543 |
|
543 | |||
544 | ERROR: test-serve-fail.t output changed |
|
544 | ERROR: test-serve-fail.t output changed | |
545 | ! |
|
545 | ! | |
546 | Failed test-serve-fail.t: server failed to start (HGPORT=*) (glob) |
|
546 | Failed test-serve-fail.t: server failed to start (HGPORT=*) (glob) | |
547 | # Ran 1 tests, 0 skipped, 1 failed. |
|
547 | # Ran 1 tests, 0 skipped, 1 failed. | |
548 | python hash seed: * (glob) |
|
548 | python hash seed: * (glob) | |
549 | [1] |
|
549 | [1] | |
550 | $ rm test-serve-fail.t |
|
550 | $ rm test-serve-fail.t | |
551 |
|
551 | |||
552 | Verify that we can try other ports |
|
552 | Verify that we can try other ports | |
553 | =================================== |
|
553 | =================================== | |
554 | $ hg init inuse |
|
554 | $ hg init inuse | |
555 | $ hg serve -R inuse -p $HGPORT -d --pid-file=blocks.pid |
|
555 | $ hg serve -R inuse -p $HGPORT -d --pid-file=blocks.pid | |
556 | $ cat blocks.pid >> $DAEMON_PIDS |
|
556 | $ cat blocks.pid >> $DAEMON_PIDS | |
557 | $ cat > test-serve-inuse.t <<EOF |
|
557 | $ cat > test-serve-inuse.t <<EOF | |
558 | > $ hg serve -R `pwd`/inuse -p \$HGPORT -d --pid-file=hg.pid |
|
558 | > $ hg serve -R `pwd`/inuse -p \$HGPORT -d --pid-file=hg.pid | |
559 | > $ cat hg.pid >> \$DAEMON_PIDS |
|
559 | > $ cat hg.pid >> \$DAEMON_PIDS | |
560 | > EOF |
|
560 | > EOF | |
561 | $ rt test-serve-inuse.t |
|
561 | $ rt test-serve-inuse.t | |
562 | . |
|
562 | . | |
563 | # Ran 1 tests, 0 skipped, 0 failed. |
|
563 | # Ran 1 tests, 0 skipped, 0 failed. | |
564 | $ rm test-serve-inuse.t |
|
564 | $ rm test-serve-inuse.t | |
565 | $ killdaemons.py $DAEMON_PIDS |
|
565 | $ killdaemons.py $DAEMON_PIDS | |
566 | $ rm $DAEMON_PIDS |
|
566 | $ rm $DAEMON_PIDS | |
567 |
|
567 | |||
568 | Running In Debug Mode |
|
568 | Running In Debug Mode | |
569 | ====================== |
|
569 | ====================== | |
570 |
|
570 | |||
571 | $ rt --debug 2>&1 | grep -v pwd |
|
571 | $ rt --debug 2>&1 | grep -v pwd | |
572 | + echo *SALT* 0 0 (glob) |
|
572 | + echo *SALT* 0 0 (glob) | |
573 | *SALT* 0 0 (glob) |
|
573 | *SALT* 0 0 (glob) | |
574 | + echo babar |
|
574 | + echo babar | |
575 | babar |
|
575 | babar | |
576 | + echo *SALT* 10 0 (glob) |
|
576 | + echo *SALT* 10 0 (glob) | |
577 | *SALT* 10 0 (glob) |
|
577 | *SALT* 10 0 (glob) | |
578 | *+ echo *SALT* 0 0 (glob) |
|
578 | *+ echo *SALT* 0 0 (glob) | |
579 | *SALT* 0 0 (glob) |
|
579 | *SALT* 0 0 (glob) | |
580 | + echo babar |
|
580 | + echo babar | |
581 | babar |
|
581 | babar | |
582 | + echo *SALT* 2 0 (glob) |
|
582 | + echo *SALT* 2 0 (glob) | |
583 | *SALT* 2 0 (glob) |
|
583 | *SALT* 2 0 (glob) | |
584 | + echo xyzzy |
|
584 | + echo xyzzy | |
585 | xyzzy |
|
585 | xyzzy | |
586 | + echo *SALT* 9 0 (glob) |
|
586 | + echo *SALT* 9 0 (glob) | |
587 | *SALT* 9 0 (glob) |
|
587 | *SALT* 9 0 (glob) | |
588 | + printf *abc\ndef\nxyz\n* (glob) |
|
588 | + printf *abc\ndef\nxyz\n* (glob) | |
589 | abc |
|
589 | abc | |
590 | def |
|
590 | def | |
591 | xyz |
|
591 | xyz | |
592 | + echo *SALT* 15 0 (glob) |
|
592 | + echo *SALT* 15 0 (glob) | |
593 | *SALT* 15 0 (glob) |
|
593 | *SALT* 15 0 (glob) | |
594 | + printf *zyx\nwvu\ntsr\n* (glob) |
|
594 | + printf *zyx\nwvu\ntsr\n* (glob) | |
595 | zyx |
|
595 | zyx | |
596 | wvu |
|
596 | wvu | |
597 | tsr |
|
597 | tsr | |
598 | + echo *SALT* 22 0 (glob) |
|
598 | + echo *SALT* 22 0 (glob) | |
599 | *SALT* 22 0 (glob) |
|
599 | *SALT* 22 0 (glob) | |
600 | . |
|
600 | . | |
601 | # Ran 2 tests, 0 skipped, 0 failed. |
|
601 | # Ran 2 tests, 0 skipped, 0 failed. | |
602 |
|
602 | |||
603 | Parallel runs |
|
603 | Parallel runs | |
604 | ============== |
|
604 | ============== | |
605 |
|
605 | |||
606 | (duplicate the failing test to get predictable output) |
|
606 | (duplicate the failing test to get predictable output) | |
607 | $ cp test-failure.t test-failure-copy.t |
|
607 | $ cp test-failure.t test-failure-copy.t | |
608 |
|
608 | |||
609 | $ rt --jobs 2 test-failure*.t -n |
|
609 | $ rt --jobs 2 test-failure*.t -n | |
610 | !! |
|
610 | !! | |
611 | Failed test-failure*.t: output changed (glob) |
|
611 | Failed test-failure*.t: output changed (glob) | |
612 | Failed test-failure*.t: output changed (glob) |
|
612 | Failed test-failure*.t: output changed (glob) | |
613 | # Ran 2 tests, 0 skipped, 2 failed. |
|
613 | # Ran 2 tests, 0 skipped, 2 failed. | |
614 | python hash seed: * (glob) |
|
614 | python hash seed: * (glob) | |
615 | [1] |
|
615 | [1] | |
616 |
|
616 | |||
617 | failures in parallel with --first should only print one failure |
|
617 | failures in parallel with --first should only print one failure | |
618 | $ rt --jobs 2 --first test-failure*.t |
|
618 | $ rt --jobs 2 --first test-failure*.t | |
619 |
|
619 | |||
620 | --- $TESTTMP/test-failure*.t (glob) |
|
620 | --- $TESTTMP/test-failure*.t (glob) | |
621 | +++ $TESTTMP/test-failure*.t.err (glob) |
|
621 | +++ $TESTTMP/test-failure*.t.err (glob) | |
622 | @@ -1,5 +1,5 @@ |
|
622 | @@ -1,5 +1,5 @@ | |
623 | $ echo babar |
|
623 | $ echo babar | |
624 | - rataxes |
|
624 | - rataxes | |
625 | + babar |
|
625 | + babar | |
626 | This is a noop statement so that |
|
626 | This is a noop statement so that | |
627 | this test is still more bytes than success. |
|
627 | this test is still more bytes than success. | |
628 | pad pad pad pad............................................................ |
|
628 | pad pad pad pad............................................................ | |
629 |
|
629 | |||
630 | Failed test-failure*.t: output changed (glob) |
|
630 | Failed test-failure*.t: output changed (glob) | |
631 | Failed test-failure*.t: output changed (glob) |
|
631 | Failed test-failure*.t: output changed (glob) | |
632 | # Ran 2 tests, 0 skipped, 2 failed. |
|
632 | # Ran 2 tests, 0 skipped, 2 failed. | |
633 | python hash seed: * (glob) |
|
633 | python hash seed: * (glob) | |
634 | [1] |
|
634 | [1] | |
635 |
|
635 | |||
636 |
|
636 | |||
637 | (delete the duplicated test file) |
|
637 | (delete the duplicated test file) | |
638 | $ rm test-failure-copy.t |
|
638 | $ rm test-failure-copy.t | |
639 |
|
639 | |||
640 |
|
640 | |||
641 | Interactive run |
|
641 | Interactive run | |
642 | =============== |
|
642 | =============== | |
643 |
|
643 | |||
644 | (backup the failing test) |
|
644 | (backup the failing test) | |
645 | $ cp test-failure.t backup |
|
645 | $ cp test-failure.t backup | |
646 |
|
646 | |||
647 | Refuse the fix |
|
647 | Refuse the fix | |
648 |
|
648 | |||
649 | $ echo 'n' | rt -i |
|
649 | $ echo 'n' | rt -i | |
650 |
|
650 | |||
651 | --- $TESTTMP/test-failure.t |
|
651 | --- $TESTTMP/test-failure.t | |
652 | +++ $TESTTMP/test-failure.t.err |
|
652 | +++ $TESTTMP/test-failure.t.err | |
653 | @@ -1,5 +1,5 @@ |
|
653 | @@ -1,5 +1,5 @@ | |
654 | $ echo babar |
|
654 | $ echo babar | |
655 | - rataxes |
|
655 | - rataxes | |
656 | + babar |
|
656 | + babar | |
657 | This is a noop statement so that |
|
657 | This is a noop statement so that | |
658 | this test is still more bytes than success. |
|
658 | this test is still more bytes than success. | |
659 | pad pad pad pad............................................................ |
|
659 | pad pad pad pad............................................................ | |
660 | Accept this change? [n] |
|
660 | Accept this change? [n] | |
661 | ERROR: test-failure.t output changed |
|
661 | ERROR: test-failure.t output changed | |
662 | !. |
|
662 | !. | |
663 | Failed test-failure.t: output changed |
|
663 | Failed test-failure.t: output changed | |
664 | # Ran 2 tests, 0 skipped, 1 failed. |
|
664 | # Ran 2 tests, 0 skipped, 1 failed. | |
665 | python hash seed: * (glob) |
|
665 | python hash seed: * (glob) | |
666 | [1] |
|
666 | [1] | |
667 |
|
667 | |||
668 | $ cat test-failure.t |
|
668 | $ cat test-failure.t | |
669 | $ echo babar |
|
669 | $ echo babar | |
670 | rataxes |
|
670 | rataxes | |
671 | This is a noop statement so that |
|
671 | This is a noop statement so that | |
672 | this test is still more bytes than success. |
|
672 | this test is still more bytes than success. | |
673 | pad pad pad pad............................................................ |
|
673 | pad pad pad pad............................................................ | |
674 | pad pad pad pad............................................................ |
|
674 | pad pad pad pad............................................................ | |
675 | pad pad pad pad............................................................ |
|
675 | pad pad pad pad............................................................ | |
676 | pad pad pad pad............................................................ |
|
676 | pad pad pad pad............................................................ | |
677 | pad pad pad pad............................................................ |
|
677 | pad pad pad pad............................................................ | |
678 | pad pad pad pad............................................................ |
|
678 | pad pad pad pad............................................................ | |
679 |
|
679 | |||
680 | Interactive with custom view |
|
680 | Interactive with custom view | |
681 |
|
681 | |||
682 | $ echo 'n' | rt -i --view echo |
|
682 | $ echo 'n' | rt -i --view echo | |
683 | $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob) |
|
683 | $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob) | |
684 | Accept this change? [n]* (glob) |
|
684 | Accept this change? [n]* (glob) | |
685 | ERROR: test-failure.t output changed |
|
685 | ERROR: test-failure.t output changed | |
686 | !. |
|
686 | !. | |
687 | Failed test-failure.t: output changed |
|
687 | Failed test-failure.t: output changed | |
688 | # Ran 2 tests, 0 skipped, 1 failed. |
|
688 | # Ran 2 tests, 0 skipped, 1 failed. | |
689 | python hash seed: * (glob) |
|
689 | python hash seed: * (glob) | |
690 | [1] |
|
690 | [1] | |
691 |
|
691 | |||
692 | View the fix |
|
692 | View the fix | |
693 |
|
693 | |||
694 | $ echo 'y' | rt --view echo |
|
694 | $ echo 'y' | rt --view echo | |
695 | $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob) |
|
695 | $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob) | |
696 |
|
696 | |||
697 | ERROR: test-failure.t output changed |
|
697 | ERROR: test-failure.t output changed | |
698 | !. |
|
698 | !. | |
699 | Failed test-failure.t: output changed |
|
699 | Failed test-failure.t: output changed | |
700 | # Ran 2 tests, 0 skipped, 1 failed. |
|
700 | # Ran 2 tests, 0 skipped, 1 failed. | |
701 | python hash seed: * (glob) |
|
701 | python hash seed: * (glob) | |
702 | [1] |
|
702 | [1] | |
703 |
|
703 | |||
704 | Accept the fix |
|
704 | Accept the fix | |
705 |
|
705 | |||
706 | $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t |
|
706 | $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t | |
707 | $ echo " saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t |
|
707 | $ echo " saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t | |
708 | $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t |
|
708 | $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t | |
709 |
$ echo " saved backup bundle to \$TESTTMP |
|
709 | $ echo " saved backup bundle to \$TESTTMP\\foo.hg" >> test-failure.t | |
710 | $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t |
|
710 | $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t | |
711 | $ echo " saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t |
|
711 | $ echo " saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t | |
712 | $ echo 'y' | rt -i 2>&1 |
|
712 | $ echo 'y' | rt -i 2>&1 | |
713 |
|
713 | |||
714 | --- $TESTTMP/test-failure.t |
|
714 | --- $TESTTMP/test-failure.t | |
715 | +++ $TESTTMP/test-failure.t.err |
|
715 | +++ $TESTTMP/test-failure.t.err | |
716 | @@ -1,5 +1,5 @@ |
|
716 | @@ -1,5 +1,5 @@ | |
717 | $ echo babar |
|
717 | $ echo babar | |
718 | - rataxes |
|
718 | - rataxes | |
719 | + babar |
|
719 | + babar | |
720 | This is a noop statement so that |
|
720 | This is a noop statement so that | |
721 | this test is still more bytes than success. |
|
721 | this test is still more bytes than success. | |
722 | pad pad pad pad............................................................ |
|
722 | pad pad pad pad............................................................ | |
723 |
@@ - |
|
723 | @@ -11,6 +11,6 @@ | |
724 | pad pad pad pad............................................................ |
|
724 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' | |
725 | pad pad pad pad............................................................ |
|
725 | saved backup bundle to $TESTTMP/foo.hg | |
726 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' |
|
726 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' | |
727 |
- saved backup bundle to $TESTTMP |
|
727 | - saved backup bundle to $TESTTMP\foo.hg | |
728 |
+ saved backup bundle to $TESTTMP/foo.hg |
|
728 | + saved backup bundle to $TESTTMP/foo.hg | |
729 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' |
|
729 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' | |
730 |
saved backup bundle to $TESTTMP/ |
|
730 | saved backup bundle to $TESTTMP/*.hg (glob) | |
731 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' |
|
|||
732 | Accept this change? [n] .. |
|
731 | Accept this change? [n] .. | |
733 | # Ran 2 tests, 0 skipped, 0 failed. |
|
732 | # Ran 2 tests, 0 skipped, 0 failed. | |
734 |
|
733 | |||
735 | $ sed -e 's,(glob)$,&<,g' test-failure.t |
|
734 | $ sed -e 's,(glob)$,&<,g' test-failure.t | |
736 | $ echo babar |
|
735 | $ echo babar | |
737 | babar |
|
736 | babar | |
738 | This is a noop statement so that |
|
737 | This is a noop statement so that | |
739 | this test is still more bytes than success. |
|
738 | this test is still more bytes than success. | |
740 | pad pad pad pad............................................................ |
|
739 | pad pad pad pad............................................................ | |
741 | pad pad pad pad............................................................ |
|
740 | pad pad pad pad............................................................ | |
742 | pad pad pad pad............................................................ |
|
741 | pad pad pad pad............................................................ | |
743 | pad pad pad pad............................................................ |
|
742 | pad pad pad pad............................................................ | |
744 | pad pad pad pad............................................................ |
|
743 | pad pad pad pad............................................................ | |
745 | pad pad pad pad............................................................ |
|
744 | pad pad pad pad............................................................ | |
746 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' |
|
745 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' | |
747 |
saved backup bundle to $TESTTMP/foo.hg |
|
746 | saved backup bundle to $TESTTMP/foo.hg | |
748 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' |
|
747 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' | |
749 |
saved backup bundle to $TESTTMP/foo.hg |
|
748 | saved backup bundle to $TESTTMP/foo.hg | |
750 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' |
|
749 | $ echo 'saved backup bundle to $TESTTMP/foo.hg' | |
751 | saved backup bundle to $TESTTMP/*.hg (glob)< |
|
750 | saved backup bundle to $TESTTMP/*.hg (glob)< | |
752 |
|
751 | |||
753 | Race condition - test file was modified when test is running |
|
752 | Race condition - test file was modified when test is running | |
754 |
|
753 | |||
755 | $ TESTRACEDIR=`pwd` |
|
754 | $ TESTRACEDIR=`pwd` | |
756 | $ export TESTRACEDIR |
|
755 | $ export TESTRACEDIR | |
757 | $ cat > test-race.t <<EOF |
|
756 | $ cat > test-race.t <<EOF | |
758 | > $ echo 1 |
|
757 | > $ echo 1 | |
759 | > $ echo "# a new line" >> $TESTRACEDIR/test-race.t |
|
758 | > $ echo "# a new line" >> $TESTRACEDIR/test-race.t | |
760 | > EOF |
|
759 | > EOF | |
761 |
|
760 | |||
762 | $ rt -i test-race.t |
|
761 | $ rt -i test-race.t | |
763 |
|
762 | |||
764 | --- $TESTTMP/test-race.t |
|
763 | --- $TESTTMP/test-race.t | |
765 | +++ $TESTTMP/test-race.t.err |
|
764 | +++ $TESTTMP/test-race.t.err | |
766 | @@ -1,2 +1,3 @@ |
|
765 | @@ -1,2 +1,3 @@ | |
767 | $ echo 1 |
|
766 | $ echo 1 | |
768 | + 1 |
|
767 | + 1 | |
769 | $ echo "# a new line" >> $TESTTMP/test-race.t |
|
768 | $ echo "# a new line" >> $TESTTMP/test-race.t | |
770 | Reference output has changed (run again to prompt changes) |
|
769 | Reference output has changed (run again to prompt changes) | |
771 | ERROR: test-race.t output changed |
|
770 | ERROR: test-race.t output changed | |
772 | ! |
|
771 | ! | |
773 | Failed test-race.t: output changed |
|
772 | Failed test-race.t: output changed | |
774 | # Ran 1 tests, 0 skipped, 1 failed. |
|
773 | # Ran 1 tests, 0 skipped, 1 failed. | |
775 | python hash seed: * (glob) |
|
774 | python hash seed: * (glob) | |
776 | [1] |
|
775 | [1] | |
777 |
|
776 | |||
778 | $ rm test-race.t |
|
777 | $ rm test-race.t | |
779 |
|
778 | |||
780 | When "#testcases" is used in .t files |
|
779 | When "#testcases" is used in .t files | |
781 |
|
780 | |||
782 | $ cat >> test-cases.t <<EOF |
|
781 | $ cat >> test-cases.t <<EOF | |
783 | > #testcases a b |
|
782 | > #testcases a b | |
784 | > #if a |
|
783 | > #if a | |
785 | > $ echo 1 |
|
784 | > $ echo 1 | |
786 | > #endif |
|
785 | > #endif | |
787 | > #if b |
|
786 | > #if b | |
788 | > $ echo 2 |
|
787 | > $ echo 2 | |
789 | > #endif |
|
788 | > #endif | |
790 | > EOF |
|
789 | > EOF | |
791 |
|
790 | |||
792 | $ cat <<EOF | rt -i test-cases.t 2>&1 |
|
791 | $ cat <<EOF | rt -i test-cases.t 2>&1 | |
793 | > y |
|
792 | > y | |
794 | > y |
|
793 | > y | |
795 | > EOF |
|
794 | > EOF | |
796 |
|
795 | |||
797 | --- $TESTTMP/test-cases.t |
|
796 | --- $TESTTMP/test-cases.t | |
798 | +++ $TESTTMP/test-cases.t.a.err |
|
797 | +++ $TESTTMP/test-cases.t.a.err | |
799 | @@ -1,6 +1,7 @@ |
|
798 | @@ -1,6 +1,7 @@ | |
800 | #testcases a b |
|
799 | #testcases a b | |
801 | #if a |
|
800 | #if a | |
802 | $ echo 1 |
|
801 | $ echo 1 | |
803 | + 1 |
|
802 | + 1 | |
804 | #endif |
|
803 | #endif | |
805 | #if b |
|
804 | #if b | |
806 | $ echo 2 |
|
805 | $ echo 2 | |
807 | Accept this change? [n] . |
|
806 | Accept this change? [n] . | |
808 | --- $TESTTMP/test-cases.t |
|
807 | --- $TESTTMP/test-cases.t | |
809 | +++ $TESTTMP/test-cases.t.b.err |
|
808 | +++ $TESTTMP/test-cases.t.b.err | |
810 | @@ -5,4 +5,5 @@ |
|
809 | @@ -5,4 +5,5 @@ | |
811 | #endif |
|
810 | #endif | |
812 | #if b |
|
811 | #if b | |
813 | $ echo 2 |
|
812 | $ echo 2 | |
814 | + 2 |
|
813 | + 2 | |
815 | #endif |
|
814 | #endif | |
816 | Accept this change? [n] . |
|
815 | Accept this change? [n] . | |
817 | # Ran 2 tests, 0 skipped, 0 failed. |
|
816 | # Ran 2 tests, 0 skipped, 0 failed. | |
818 |
|
817 | |||
819 | $ cat test-cases.t |
|
818 | $ cat test-cases.t | |
820 | #testcases a b |
|
819 | #testcases a b | |
821 | #if a |
|
820 | #if a | |
822 | $ echo 1 |
|
821 | $ echo 1 | |
823 | 1 |
|
822 | 1 | |
824 | #endif |
|
823 | #endif | |
825 | #if b |
|
824 | #if b | |
826 | $ echo 2 |
|
825 | $ echo 2 | |
827 | 2 |
|
826 | 2 | |
828 | #endif |
|
827 | #endif | |
829 |
|
828 | |||
830 | $ cat >> test-cases.t <<'EOF' |
|
829 | $ cat >> test-cases.t <<'EOF' | |
831 | > #if a |
|
830 | > #if a | |
832 | > $ NAME=A |
|
831 | > $ NAME=A | |
833 | > #else |
|
832 | > #else | |
834 | > $ NAME=B |
|
833 | > $ NAME=B | |
835 | > #endif |
|
834 | > #endif | |
836 | > $ echo $NAME |
|
835 | > $ echo $NAME | |
837 | > A (a !) |
|
836 | > A (a !) | |
838 | > B (b !) |
|
837 | > B (b !) | |
839 | > EOF |
|
838 | > EOF | |
840 | $ rt test-cases.t |
|
839 | $ rt test-cases.t | |
841 | .. |
|
840 | .. | |
842 | # Ran 2 tests, 0 skipped, 0 failed. |
|
841 | # Ran 2 tests, 0 skipped, 0 failed. | |
843 |
|
842 | |||
844 | $ rm test-cases.t |
|
843 | $ rm test-cases.t | |
845 |
|
844 | |||
846 | (reinstall) |
|
845 | (reinstall) | |
847 | $ mv backup test-failure.t |
|
846 | $ mv backup test-failure.t | |
848 |
|
847 | |||
849 | No Diff |
|
848 | No Diff | |
850 | =============== |
|
849 | =============== | |
851 |
|
850 | |||
852 | $ rt --nodiff |
|
851 | $ rt --nodiff | |
853 | !. |
|
852 | !. | |
854 | Failed test-failure.t: output changed |
|
853 | Failed test-failure.t: output changed | |
855 | # Ran 2 tests, 0 skipped, 1 failed. |
|
854 | # Ran 2 tests, 0 skipped, 1 failed. | |
856 | python hash seed: * (glob) |
|
855 | python hash seed: * (glob) | |
857 | [1] |
|
856 | [1] | |
858 |
|
857 | |||
859 | test --tmpdir support |
|
858 | test --tmpdir support | |
860 | $ rt --tmpdir=$TESTTMP/keep test-success.t |
|
859 | $ rt --tmpdir=$TESTTMP/keep test-success.t | |
861 |
|
860 | |||
862 | Keeping testtmp dir: $TESTTMP/keep/child1/test-success.t (glob) |
|
861 | Keeping testtmp dir: $TESTTMP/keep/child1/test-success.t (glob) | |
863 | Keeping threadtmp dir: $TESTTMP/keep/child1 (glob) |
|
862 | Keeping threadtmp dir: $TESTTMP/keep/child1 (glob) | |
864 | . |
|
863 | . | |
865 | # Ran 1 tests, 0 skipped, 0 failed. |
|
864 | # Ran 1 tests, 0 skipped, 0 failed. | |
866 |
|
865 | |||
867 | timeouts |
|
866 | timeouts | |
868 | ======== |
|
867 | ======== | |
869 | $ cat > test-timeout.t <<EOF |
|
868 | $ cat > test-timeout.t <<EOF | |
870 | > $ sleep 2 |
|
869 | > $ sleep 2 | |
871 | > $ echo pass |
|
870 | > $ echo pass | |
872 | > pass |
|
871 | > pass | |
873 | > EOF |
|
872 | > EOF | |
874 | > echo '#require slow' > test-slow-timeout.t |
|
873 | > echo '#require slow' > test-slow-timeout.t | |
875 | > cat test-timeout.t >> test-slow-timeout.t |
|
874 | > cat test-timeout.t >> test-slow-timeout.t | |
876 | $ rt --timeout=1 --slowtimeout=3 test-timeout.t test-slow-timeout.t |
|
875 | $ rt --timeout=1 --slowtimeout=3 test-timeout.t test-slow-timeout.t | |
877 | st |
|
876 | st | |
878 | Skipped test-slow-timeout.t: missing feature: allow slow tests (use --allow-slow-tests) |
|
877 | Skipped test-slow-timeout.t: missing feature: allow slow tests (use --allow-slow-tests) | |
879 | Failed test-timeout.t: timed out |
|
878 | Failed test-timeout.t: timed out | |
880 | # Ran 1 tests, 1 skipped, 1 failed. |
|
879 | # Ran 1 tests, 1 skipped, 1 failed. | |
881 | python hash seed: * (glob) |
|
880 | python hash seed: * (glob) | |
882 | [1] |
|
881 | [1] | |
883 | $ rt --timeout=1 --slowtimeout=3 \ |
|
882 | $ rt --timeout=1 --slowtimeout=3 \ | |
884 | > test-timeout.t test-slow-timeout.t --allow-slow-tests |
|
883 | > test-timeout.t test-slow-timeout.t --allow-slow-tests | |
885 | .t |
|
884 | .t | |
886 | Failed test-timeout.t: timed out |
|
885 | Failed test-timeout.t: timed out | |
887 | # Ran 2 tests, 0 skipped, 1 failed. |
|
886 | # Ran 2 tests, 0 skipped, 1 failed. | |
888 | python hash seed: * (glob) |
|
887 | python hash seed: * (glob) | |
889 | [1] |
|
888 | [1] | |
890 | $ rm test-timeout.t test-slow-timeout.t |
|
889 | $ rm test-timeout.t test-slow-timeout.t | |
891 |
|
890 | |||
892 | test for --time |
|
891 | test for --time | |
893 | ================== |
|
892 | ================== | |
894 |
|
893 | |||
895 | $ rt test-success.t --time |
|
894 | $ rt test-success.t --time | |
896 | . |
|
895 | . | |
897 | # Ran 1 tests, 0 skipped, 0 failed. |
|
896 | # Ran 1 tests, 0 skipped, 0 failed. | |
898 | # Producing time report |
|
897 | # Producing time report | |
899 | start end cuser csys real Test |
|
898 | start end cuser csys real Test | |
900 | \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re) |
|
899 | \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re) | |
901 |
|
900 | |||
902 | test for --time with --job enabled |
|
901 | test for --time with --job enabled | |
903 | ==================================== |
|
902 | ==================================== | |
904 |
|
903 | |||
905 | $ rt test-success.t --time --jobs 2 |
|
904 | $ rt test-success.t --time --jobs 2 | |
906 | . |
|
905 | . | |
907 | # Ran 1 tests, 0 skipped, 0 failed. |
|
906 | # Ran 1 tests, 0 skipped, 0 failed. | |
908 | # Producing time report |
|
907 | # Producing time report | |
909 | start end cuser csys real Test |
|
908 | start end cuser csys real Test | |
910 | \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re) |
|
909 | \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re) | |
911 |
|
910 | |||
912 | Skips |
|
911 | Skips | |
913 | ================ |
|
912 | ================ | |
914 | $ cat > test-skip.t <<EOF |
|
913 | $ cat > test-skip.t <<EOF | |
915 | > $ echo xyzzy |
|
914 | > $ echo xyzzy | |
916 | > #require false |
|
915 | > #require false | |
917 | > EOF |
|
916 | > EOF | |
918 | $ rt --nodiff |
|
917 | $ rt --nodiff | |
919 | !.s |
|
918 | !.s | |
920 | Skipped test-skip.t: missing feature: nail clipper |
|
919 | Skipped test-skip.t: missing feature: nail clipper | |
921 | Failed test-failure.t: output changed |
|
920 | Failed test-failure.t: output changed | |
922 | # Ran 2 tests, 1 skipped, 1 failed. |
|
921 | # Ran 2 tests, 1 skipped, 1 failed. | |
923 | python hash seed: * (glob) |
|
922 | python hash seed: * (glob) | |
924 | [1] |
|
923 | [1] | |
925 |
|
924 | |||
926 | $ rt --keyword xyzzy |
|
925 | $ rt --keyword xyzzy | |
927 | .s |
|
926 | .s | |
928 | Skipped test-skip.t: missing feature: nail clipper |
|
927 | Skipped test-skip.t: missing feature: nail clipper | |
929 | # Ran 2 tests, 2 skipped, 0 failed. |
|
928 | # Ran 2 tests, 2 skipped, 0 failed. | |
930 |
|
929 | |||
931 | Skips with xml |
|
930 | Skips with xml | |
932 | $ rt --keyword xyzzy \ |
|
931 | $ rt --keyword xyzzy \ | |
933 | > --xunit=xunit.xml |
|
932 | > --xunit=xunit.xml | |
934 | .s |
|
933 | .s | |
935 | Skipped test-skip.t: missing feature: nail clipper |
|
934 | Skipped test-skip.t: missing feature: nail clipper | |
936 | # Ran 2 tests, 2 skipped, 0 failed. |
|
935 | # Ran 2 tests, 2 skipped, 0 failed. | |
937 | $ cat xunit.xml |
|
936 | $ cat xunit.xml | |
938 | <?xml version="1.0" encoding="utf-8"?> |
|
937 | <?xml version="1.0" encoding="utf-8"?> | |
939 | <testsuite errors="0" failures="0" name="run-tests" skipped="2" tests="2"> |
|
938 | <testsuite errors="0" failures="0" name="run-tests" skipped="2" tests="2"> | |
940 | <testcase name="test-success.t" time="*"/> (glob) |
|
939 | <testcase name="test-success.t" time="*"/> (glob) | |
941 | <testcase name="test-skip.t"> |
|
940 | <testcase name="test-skip.t"> | |
942 | <skipped> |
|
941 | <skipped> | |
943 | <![CDATA[missing feature: nail clipper]]> </skipped> |
|
942 | <![CDATA[missing feature: nail clipper]]> </skipped> | |
944 | </testcase> |
|
943 | </testcase> | |
945 | </testsuite> |
|
944 | </testsuite> | |
946 |
|
945 | |||
947 | Missing skips or blacklisted skips don't count as executed: |
|
946 | Missing skips or blacklisted skips don't count as executed: | |
948 | $ echo test-failure.t > blacklist |
|
947 | $ echo test-failure.t > blacklist | |
949 | $ rt --blacklist=blacklist --json\ |
|
948 | $ rt --blacklist=blacklist --json\ | |
950 | > test-failure.t test-bogus.t |
|
949 | > test-failure.t test-bogus.t | |
951 | ss |
|
950 | ss | |
952 | Skipped test-bogus.t: Doesn't exist |
|
951 | Skipped test-bogus.t: Doesn't exist | |
953 | Skipped test-failure.t: blacklisted |
|
952 | Skipped test-failure.t: blacklisted | |
954 | # Ran 0 tests, 2 skipped, 0 failed. |
|
953 | # Ran 0 tests, 2 skipped, 0 failed. | |
955 | $ cat report.json |
|
954 | $ cat report.json | |
956 | testreport ={ |
|
955 | testreport ={ | |
957 | "test-bogus.t": { |
|
956 | "test-bogus.t": { | |
958 | "result": "skip" |
|
957 | "result": "skip" | |
959 | }, |
|
958 | }, | |
960 | "test-failure.t": { |
|
959 | "test-failure.t": { | |
961 | "result": "skip" |
|
960 | "result": "skip" | |
962 | } |
|
961 | } | |
963 | } (no-eol) |
|
962 | } (no-eol) | |
964 |
|
963 | |||
965 | Whitelist trumps blacklist |
|
964 | Whitelist trumps blacklist | |
966 | $ echo test-failure.t > whitelist |
|
965 | $ echo test-failure.t > whitelist | |
967 | $ rt --blacklist=blacklist --whitelist=whitelist --json\ |
|
966 | $ rt --blacklist=blacklist --whitelist=whitelist --json\ | |
968 | > test-failure.t test-bogus.t |
|
967 | > test-failure.t test-bogus.t | |
969 | s |
|
968 | s | |
970 | --- $TESTTMP/test-failure.t |
|
969 | --- $TESTTMP/test-failure.t | |
971 | +++ $TESTTMP/test-failure.t.err |
|
970 | +++ $TESTTMP/test-failure.t.err | |
972 | @@ -1,5 +1,5 @@ |
|
971 | @@ -1,5 +1,5 @@ | |
973 | $ echo babar |
|
972 | $ echo babar | |
974 | - rataxes |
|
973 | - rataxes | |
975 | + babar |
|
974 | + babar | |
976 | This is a noop statement so that |
|
975 | This is a noop statement so that | |
977 | this test is still more bytes than success. |
|
976 | this test is still more bytes than success. | |
978 | pad pad pad pad............................................................ |
|
977 | pad pad pad pad............................................................ | |
979 |
|
978 | |||
980 | ERROR: test-failure.t output changed |
|
979 | ERROR: test-failure.t output changed | |
981 | ! |
|
980 | ! | |
982 | Skipped test-bogus.t: Doesn't exist |
|
981 | Skipped test-bogus.t: Doesn't exist | |
983 | Failed test-failure.t: output changed |
|
982 | Failed test-failure.t: output changed | |
984 | # Ran 1 tests, 1 skipped, 1 failed. |
|
983 | # Ran 1 tests, 1 skipped, 1 failed. | |
985 | python hash seed: * (glob) |
|
984 | python hash seed: * (glob) | |
986 | [1] |
|
985 | [1] | |
987 |
|
986 | |||
988 | Ensure that --test-list causes only the tests listed in that file to |
|
987 | Ensure that --test-list causes only the tests listed in that file to | |
989 | be executed. |
|
988 | be executed. | |
990 | $ echo test-success.t >> onlytest |
|
989 | $ echo test-success.t >> onlytest | |
991 | $ rt --test-list=onlytest |
|
990 | $ rt --test-list=onlytest | |
992 | . |
|
991 | . | |
993 | # Ran 1 tests, 0 skipped, 0 failed. |
|
992 | # Ran 1 tests, 0 skipped, 0 failed. | |
994 | $ echo test-bogus.t >> anothertest |
|
993 | $ echo test-bogus.t >> anothertest | |
995 | $ rt --test-list=onlytest --test-list=anothertest |
|
994 | $ rt --test-list=onlytest --test-list=anothertest | |
996 | s. |
|
995 | s. | |
997 | Skipped test-bogus.t: Doesn't exist |
|
996 | Skipped test-bogus.t: Doesn't exist | |
998 | # Ran 1 tests, 1 skipped, 0 failed. |
|
997 | # Ran 1 tests, 1 skipped, 0 failed. | |
999 | $ rm onlytest anothertest |
|
998 | $ rm onlytest anothertest | |
1000 |
|
999 | |||
1001 | test for --json |
|
1000 | test for --json | |
1002 | ================== |
|
1001 | ================== | |
1003 |
|
1002 | |||
1004 | $ rt --json |
|
1003 | $ rt --json | |
1005 |
|
1004 | |||
1006 | --- $TESTTMP/test-failure.t |
|
1005 | --- $TESTTMP/test-failure.t | |
1007 | +++ $TESTTMP/test-failure.t.err |
|
1006 | +++ $TESTTMP/test-failure.t.err | |
1008 | @@ -1,5 +1,5 @@ |
|
1007 | @@ -1,5 +1,5 @@ | |
1009 | $ echo babar |
|
1008 | $ echo babar | |
1010 | - rataxes |
|
1009 | - rataxes | |
1011 | + babar |
|
1010 | + babar | |
1012 | This is a noop statement so that |
|
1011 | This is a noop statement so that | |
1013 | this test is still more bytes than success. |
|
1012 | this test is still more bytes than success. | |
1014 | pad pad pad pad............................................................ |
|
1013 | pad pad pad pad............................................................ | |
1015 |
|
1014 | |||
1016 | ERROR: test-failure.t output changed |
|
1015 | ERROR: test-failure.t output changed | |
1017 | !.s |
|
1016 | !.s | |
1018 | Skipped test-skip.t: missing feature: nail clipper |
|
1017 | Skipped test-skip.t: missing feature: nail clipper | |
1019 | Failed test-failure.t: output changed |
|
1018 | Failed test-failure.t: output changed | |
1020 | # Ran 2 tests, 1 skipped, 1 failed. |
|
1019 | # Ran 2 tests, 1 skipped, 1 failed. | |
1021 | python hash seed: * (glob) |
|
1020 | python hash seed: * (glob) | |
1022 | [1] |
|
1021 | [1] | |
1023 |
|
1022 | |||
1024 | $ cat report.json |
|
1023 | $ cat report.json | |
1025 | testreport ={ |
|
1024 | testreport ={ | |
1026 | "test-failure.t": [\{] (re) |
|
1025 | "test-failure.t": [\{] (re) | |
1027 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1026 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1028 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1027 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1029 | "diff": "---.+\+\+\+.+", ? (re) |
|
1028 | "diff": "---.+\+\+\+.+", ? (re) | |
1030 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1029 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1031 | "result": "failure", ? (re) |
|
1030 | "result": "failure", ? (re) | |
1032 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1031 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1033 | "time": "\s*[\d\.]{4,5}" (re) |
|
1032 | "time": "\s*[\d\.]{4,5}" (re) | |
1034 | }, ? (re) |
|
1033 | }, ? (re) | |
1035 | "test-skip.t": { |
|
1034 | "test-skip.t": { | |
1036 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1035 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1037 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1036 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1038 | "diff": "", ? (re) |
|
1037 | "diff": "", ? (re) | |
1039 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1038 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1040 | "result": "skip", ? (re) |
|
1039 | "result": "skip", ? (re) | |
1041 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1040 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1042 | "time": "\s*[\d\.]{4,5}" (re) |
|
1041 | "time": "\s*[\d\.]{4,5}" (re) | |
1043 | }, ? (re) |
|
1042 | }, ? (re) | |
1044 | "test-success.t": [\{] (re) |
|
1043 | "test-success.t": [\{] (re) | |
1045 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1044 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1046 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1045 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1047 | "diff": "", ? (re) |
|
1046 | "diff": "", ? (re) | |
1048 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1047 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1049 | "result": "success", ? (re) |
|
1048 | "result": "success", ? (re) | |
1050 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1049 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1051 | "time": "\s*[\d\.]{4,5}" (re) |
|
1050 | "time": "\s*[\d\.]{4,5}" (re) | |
1052 | } |
|
1051 | } | |
1053 | } (no-eol) |
|
1052 | } (no-eol) | |
1054 | --json with --outputdir |
|
1053 | --json with --outputdir | |
1055 |
|
1054 | |||
1056 | $ rm report.json |
|
1055 | $ rm report.json | |
1057 | $ rm -r output |
|
1056 | $ rm -r output | |
1058 | $ mkdir output |
|
1057 | $ mkdir output | |
1059 | $ rt --json --outputdir output |
|
1058 | $ rt --json --outputdir output | |
1060 |
|
1059 | |||
1061 | --- $TESTTMP/test-failure.t |
|
1060 | --- $TESTTMP/test-failure.t | |
1062 | +++ $TESTTMP/output/test-failure.t.err |
|
1061 | +++ $TESTTMP/output/test-failure.t.err | |
1063 | @@ -1,5 +1,5 @@ |
|
1062 | @@ -1,5 +1,5 @@ | |
1064 | $ echo babar |
|
1063 | $ echo babar | |
1065 | - rataxes |
|
1064 | - rataxes | |
1066 | + babar |
|
1065 | + babar | |
1067 | This is a noop statement so that |
|
1066 | This is a noop statement so that | |
1068 | this test is still more bytes than success. |
|
1067 | this test is still more bytes than success. | |
1069 | pad pad pad pad............................................................ |
|
1068 | pad pad pad pad............................................................ | |
1070 |
|
1069 | |||
1071 | ERROR: test-failure.t output changed |
|
1070 | ERROR: test-failure.t output changed | |
1072 | !.s |
|
1071 | !.s | |
1073 | Skipped test-skip.t: missing feature: nail clipper |
|
1072 | Skipped test-skip.t: missing feature: nail clipper | |
1074 | Failed test-failure.t: output changed |
|
1073 | Failed test-failure.t: output changed | |
1075 | # Ran 2 tests, 1 skipped, 1 failed. |
|
1074 | # Ran 2 tests, 1 skipped, 1 failed. | |
1076 | python hash seed: * (glob) |
|
1075 | python hash seed: * (glob) | |
1077 | [1] |
|
1076 | [1] | |
1078 | $ f report.json |
|
1077 | $ f report.json | |
1079 | report.json: file not found |
|
1078 | report.json: file not found | |
1080 | $ cat output/report.json |
|
1079 | $ cat output/report.json | |
1081 | testreport ={ |
|
1080 | testreport ={ | |
1082 | "test-failure.t": [\{] (re) |
|
1081 | "test-failure.t": [\{] (re) | |
1083 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1082 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1084 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1083 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1085 | "diff": "---.+\+\+\+.+", ? (re) |
|
1084 | "diff": "---.+\+\+\+.+", ? (re) | |
1086 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1085 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1087 | "result": "failure", ? (re) |
|
1086 | "result": "failure", ? (re) | |
1088 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1087 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1089 | "time": "\s*[\d\.]{4,5}" (re) |
|
1088 | "time": "\s*[\d\.]{4,5}" (re) | |
1090 | }, ? (re) |
|
1089 | }, ? (re) | |
1091 | "test-skip.t": { |
|
1090 | "test-skip.t": { | |
1092 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1091 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1093 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1092 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1094 | "diff": "", ? (re) |
|
1093 | "diff": "", ? (re) | |
1095 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1094 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1096 | "result": "skip", ? (re) |
|
1095 | "result": "skip", ? (re) | |
1097 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1096 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1098 | "time": "\s*[\d\.]{4,5}" (re) |
|
1097 | "time": "\s*[\d\.]{4,5}" (re) | |
1099 | }, ? (re) |
|
1098 | }, ? (re) | |
1100 | "test-success.t": [\{] (re) |
|
1099 | "test-success.t": [\{] (re) | |
1101 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1100 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1102 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1101 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1103 | "diff": "", ? (re) |
|
1102 | "diff": "", ? (re) | |
1104 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1103 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1105 | "result": "success", ? (re) |
|
1104 | "result": "success", ? (re) | |
1106 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1105 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1107 | "time": "\s*[\d\.]{4,5}" (re) |
|
1106 | "time": "\s*[\d\.]{4,5}" (re) | |
1108 | } |
|
1107 | } | |
1109 | } (no-eol) |
|
1108 | } (no-eol) | |
1110 | $ ls -a output |
|
1109 | $ ls -a output | |
1111 | . |
|
1110 | . | |
1112 | .. |
|
1111 | .. | |
1113 | .testtimes |
|
1112 | .testtimes | |
1114 | report.json |
|
1113 | report.json | |
1115 | test-failure.t.err |
|
1114 | test-failure.t.err | |
1116 |
|
1115 | |||
1117 | Test that failed test accepted through interactive are properly reported: |
|
1116 | Test that failed test accepted through interactive are properly reported: | |
1118 |
|
1117 | |||
1119 | $ cp test-failure.t backup |
|
1118 | $ cp test-failure.t backup | |
1120 | $ echo y | rt --json -i |
|
1119 | $ echo y | rt --json -i | |
1121 |
|
1120 | |||
1122 | --- $TESTTMP/test-failure.t |
|
1121 | --- $TESTTMP/test-failure.t | |
1123 | +++ $TESTTMP/test-failure.t.err |
|
1122 | +++ $TESTTMP/test-failure.t.err | |
1124 | @@ -1,5 +1,5 @@ |
|
1123 | @@ -1,5 +1,5 @@ | |
1125 | $ echo babar |
|
1124 | $ echo babar | |
1126 | - rataxes |
|
1125 | - rataxes | |
1127 | + babar |
|
1126 | + babar | |
1128 | This is a noop statement so that |
|
1127 | This is a noop statement so that | |
1129 | this test is still more bytes than success. |
|
1128 | this test is still more bytes than success. | |
1130 | pad pad pad pad............................................................ |
|
1129 | pad pad pad pad............................................................ | |
1131 | Accept this change? [n] ..s |
|
1130 | Accept this change? [n] ..s | |
1132 | Skipped test-skip.t: missing feature: nail clipper |
|
1131 | Skipped test-skip.t: missing feature: nail clipper | |
1133 | # Ran 2 tests, 1 skipped, 0 failed. |
|
1132 | # Ran 2 tests, 1 skipped, 0 failed. | |
1134 |
|
1133 | |||
1135 | $ cat report.json |
|
1134 | $ cat report.json | |
1136 | testreport ={ |
|
1135 | testreport ={ | |
1137 | "test-failure.t": [\{] (re) |
|
1136 | "test-failure.t": [\{] (re) | |
1138 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1137 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1139 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1138 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1140 | "diff": "", ? (re) |
|
1139 | "diff": "", ? (re) | |
1141 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1140 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1142 | "result": "success", ? (re) |
|
1141 | "result": "success", ? (re) | |
1143 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1142 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1144 | "time": "\s*[\d\.]{4,5}" (re) |
|
1143 | "time": "\s*[\d\.]{4,5}" (re) | |
1145 | }, ? (re) |
|
1144 | }, ? (re) | |
1146 | "test-skip.t": { |
|
1145 | "test-skip.t": { | |
1147 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1146 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1148 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1147 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1149 | "diff": "", ? (re) |
|
1148 | "diff": "", ? (re) | |
1150 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1149 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1151 | "result": "skip", ? (re) |
|
1150 | "result": "skip", ? (re) | |
1152 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1151 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1153 | "time": "\s*[\d\.]{4,5}" (re) |
|
1152 | "time": "\s*[\d\.]{4,5}" (re) | |
1154 | }, ? (re) |
|
1153 | }, ? (re) | |
1155 | "test-success.t": [\{] (re) |
|
1154 | "test-success.t": [\{] (re) | |
1156 | "csys": "\s*[\d\.]{4,5}", ? (re) |
|
1155 | "csys": "\s*[\d\.]{4,5}", ? (re) | |
1157 | "cuser": "\s*[\d\.]{4,5}", ? (re) |
|
1156 | "cuser": "\s*[\d\.]{4,5}", ? (re) | |
1158 | "diff": "", ? (re) |
|
1157 | "diff": "", ? (re) | |
1159 | "end": "\s*[\d\.]{4,5}", ? (re) |
|
1158 | "end": "\s*[\d\.]{4,5}", ? (re) | |
1160 | "result": "success", ? (re) |
|
1159 | "result": "success", ? (re) | |
1161 | "start": "\s*[\d\.]{4,5}", ? (re) |
|
1160 | "start": "\s*[\d\.]{4,5}", ? (re) | |
1162 | "time": "\s*[\d\.]{4,5}" (re) |
|
1161 | "time": "\s*[\d\.]{4,5}" (re) | |
1163 | } |
|
1162 | } | |
1164 | } (no-eol) |
|
1163 | } (no-eol) | |
1165 | $ mv backup test-failure.t |
|
1164 | $ mv backup test-failure.t | |
1166 |
|
1165 | |||
1167 | backslash on end of line with glob matching is handled properly |
|
1166 | backslash on end of line with glob matching is handled properly | |
1168 |
|
1167 | |||
1169 | $ cat > test-glob-backslash.t << EOF |
|
1168 | $ cat > test-glob-backslash.t << EOF | |
1170 | > $ echo 'foo bar \\' |
|
1169 | > $ echo 'foo bar \\' | |
1171 | > foo * \ (glob) |
|
1170 | > foo * \ (glob) | |
1172 | > EOF |
|
1171 | > EOF | |
1173 |
|
1172 | |||
1174 | $ rt test-glob-backslash.t |
|
1173 | $ rt test-glob-backslash.t | |
1175 | . |
|
1174 | . | |
1176 | # Ran 1 tests, 0 skipped, 0 failed. |
|
1175 | # Ran 1 tests, 0 skipped, 0 failed. | |
1177 |
|
1176 | |||
1178 | $ rm -f test-glob-backslash.t |
|
1177 | $ rm -f test-glob-backslash.t | |
1179 |
|
1178 | |||
1180 | Test globbing of local IP addresses |
|
1179 | Test globbing of local IP addresses | |
1181 | $ echo 172.16.18.1 |
|
1180 | $ echo 172.16.18.1 | |
1182 | $LOCALIP (glob) |
|
1181 | $LOCALIP (glob) | |
1183 | $ echo dead:beef::1 |
|
1182 | $ echo dead:beef::1 | |
1184 | $LOCALIP (glob) |
|
1183 | $LOCALIP (glob) | |
1185 |
|
1184 | |||
1186 | Test reusability for third party tools |
|
1185 | Test reusability for third party tools | |
1187 | ====================================== |
|
1186 | ====================================== | |
1188 |
|
1187 | |||
1189 | $ mkdir "$TESTTMP"/anothertests |
|
1188 | $ mkdir "$TESTTMP"/anothertests | |
1190 | $ cd "$TESTTMP"/anothertests |
|
1189 | $ cd "$TESTTMP"/anothertests | |
1191 |
|
1190 | |||
1192 | test that `run-tests.py` can execute hghave, even if it runs not in |
|
1191 | test that `run-tests.py` can execute hghave, even if it runs not in | |
1193 | Mercurial source tree. |
|
1192 | Mercurial source tree. | |
1194 |
|
1193 | |||
1195 | $ cat > test-hghave.t <<EOF |
|
1194 | $ cat > test-hghave.t <<EOF | |
1196 | > #require true |
|
1195 | > #require true | |
1197 | > $ echo foo |
|
1196 | > $ echo foo | |
1198 | > foo |
|
1197 | > foo | |
1199 | > EOF |
|
1198 | > EOF | |
1200 | $ rt test-hghave.t |
|
1199 | $ rt test-hghave.t | |
1201 | . |
|
1200 | . | |
1202 | # Ran 1 tests, 0 skipped, 0 failed. |
|
1201 | # Ran 1 tests, 0 skipped, 0 failed. | |
1203 |
|
1202 | |||
1204 | test that RUNTESTDIR refers the directory, in which `run-tests.py` now |
|
1203 | test that RUNTESTDIR refers the directory, in which `run-tests.py` now | |
1205 | running is placed. |
|
1204 | running is placed. | |
1206 |
|
1205 | |||
1207 | $ cat > test-runtestdir.t <<EOF |
|
1206 | $ cat > test-runtestdir.t <<EOF | |
1208 | > - $TESTDIR, in which test-run-tests.t is placed |
|
1207 | > - $TESTDIR, in which test-run-tests.t is placed | |
1209 | > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime) |
|
1208 | > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime) | |
1210 | > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime) |
|
1209 | > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime) | |
1211 | > |
|
1210 | > | |
1212 | > #if windows |
|
1211 | > #if windows | |
1213 | > $ test "\$TESTDIR" = "$TESTTMP\anothertests" |
|
1212 | > $ test "\$TESTDIR" = "$TESTTMP\anothertests" | |
1214 | > #else |
|
1213 | > #else | |
1215 | > $ test "\$TESTDIR" = "$TESTTMP"/anothertests |
|
1214 | > $ test "\$TESTDIR" = "$TESTTMP"/anothertests | |
1216 | > #endif |
|
1215 | > #endif | |
1217 | > If this prints a path, that means RUNTESTDIR didn't equal |
|
1216 | > If this prints a path, that means RUNTESTDIR didn't equal | |
1218 | > TESTDIR as it should have. |
|
1217 | > TESTDIR as it should have. | |
1219 | > $ test "\$RUNTESTDIR" = "$TESTDIR" || echo "\$RUNTESTDIR" |
|
1218 | > $ test "\$RUNTESTDIR" = "$TESTDIR" || echo "\$RUNTESTDIR" | |
1220 | > This should print the start of check-code. If this passes but the |
|
1219 | > This should print the start of check-code. If this passes but the | |
1221 | > previous check failed, that means we found a copy of check-code at whatever |
|
1220 | > previous check failed, that means we found a copy of check-code at whatever | |
1222 | > RUNTESTSDIR ended up containing, even though it doesn't match TESTDIR. |
|
1221 | > RUNTESTSDIR ended up containing, even though it doesn't match TESTDIR. | |
1223 | > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python@#!USRBINENVPY@' |
|
1222 | > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python@#!USRBINENVPY@' | |
1224 | > #!USRBINENVPY |
|
1223 | > #!USRBINENVPY | |
1225 | > # |
|
1224 | > # | |
1226 | > # check-code - a style and portability checker for Mercurial |
|
1225 | > # check-code - a style and portability checker for Mercurial | |
1227 | > EOF |
|
1226 | > EOF | |
1228 | $ rt test-runtestdir.t |
|
1227 | $ rt test-runtestdir.t | |
1229 | . |
|
1228 | . | |
1230 | # Ran 1 tests, 0 skipped, 0 failed. |
|
1229 | # Ran 1 tests, 0 skipped, 0 failed. | |
1231 |
|
1230 | |||
1232 | #if execbit |
|
1231 | #if execbit | |
1233 |
|
1232 | |||
1234 | test that TESTDIR is referred in PATH |
|
1233 | test that TESTDIR is referred in PATH | |
1235 |
|
1234 | |||
1236 | $ cat > custom-command.sh <<EOF |
|
1235 | $ cat > custom-command.sh <<EOF | |
1237 | > #!/bin/sh |
|
1236 | > #!/bin/sh | |
1238 | > echo "hello world" |
|
1237 | > echo "hello world" | |
1239 | > EOF |
|
1238 | > EOF | |
1240 | $ chmod +x custom-command.sh |
|
1239 | $ chmod +x custom-command.sh | |
1241 | $ cat > test-testdir-path.t <<EOF |
|
1240 | $ cat > test-testdir-path.t <<EOF | |
1242 | > $ custom-command.sh |
|
1241 | > $ custom-command.sh | |
1243 | > hello world |
|
1242 | > hello world | |
1244 | > EOF |
|
1243 | > EOF | |
1245 | $ rt test-testdir-path.t |
|
1244 | $ rt test-testdir-path.t | |
1246 | . |
|
1245 | . | |
1247 | # Ran 1 tests, 0 skipped, 0 failed. |
|
1246 | # Ran 1 tests, 0 skipped, 0 failed. | |
1248 |
|
1247 | |||
1249 | #endif |
|
1248 | #endif | |
1250 |
|
1249 | |||
1251 | test support for --allow-slow-tests |
|
1250 | test support for --allow-slow-tests | |
1252 | $ cat > test-very-slow-test.t <<EOF |
|
1251 | $ cat > test-very-slow-test.t <<EOF | |
1253 | > #require slow |
|
1252 | > #require slow | |
1254 | > $ echo pass |
|
1253 | > $ echo pass | |
1255 | > pass |
|
1254 | > pass | |
1256 | > EOF |
|
1255 | > EOF | |
1257 | $ rt test-very-slow-test.t |
|
1256 | $ rt test-very-slow-test.t | |
1258 | s |
|
1257 | s | |
1259 | Skipped test-very-slow-test.t: missing feature: allow slow tests (use --allow-slow-tests) |
|
1258 | Skipped test-very-slow-test.t: missing feature: allow slow tests (use --allow-slow-tests) | |
1260 | # Ran 0 tests, 1 skipped, 0 failed. |
|
1259 | # Ran 0 tests, 1 skipped, 0 failed. | |
1261 | $ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t |
|
1260 | $ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t | |
1262 | . |
|
1261 | . | |
1263 | # Ran 1 tests, 0 skipped, 0 failed. |
|
1262 | # Ran 1 tests, 0 skipped, 0 failed. | |
1264 |
|
1263 | |||
1265 | support for running a test outside the current directory |
|
1264 | support for running a test outside the current directory | |
1266 | $ mkdir nonlocal |
|
1265 | $ mkdir nonlocal | |
1267 | $ cat > nonlocal/test-is-not-here.t << EOF |
|
1266 | $ cat > nonlocal/test-is-not-here.t << EOF | |
1268 | > $ echo pass |
|
1267 | > $ echo pass | |
1269 | > pass |
|
1268 | > pass | |
1270 | > EOF |
|
1269 | > EOF | |
1271 | $ rt nonlocal/test-is-not-here.t |
|
1270 | $ rt nonlocal/test-is-not-here.t | |
1272 | . |
|
1271 | . | |
1273 | # Ran 1 tests, 0 skipped, 0 failed. |
|
1272 | # Ran 1 tests, 0 skipped, 0 failed. | |
1274 |
|
1273 | |||
1275 | support for automatically discovering test if arg is a folder |
|
1274 | support for automatically discovering test if arg is a folder | |
1276 | $ mkdir tmp && cd tmp |
|
1275 | $ mkdir tmp && cd tmp | |
1277 |
|
1276 | |||
1278 | $ cat > test-uno.t << EOF |
|
1277 | $ cat > test-uno.t << EOF | |
1279 | > $ echo line |
|
1278 | > $ echo line | |
1280 | > line |
|
1279 | > line | |
1281 | > EOF |
|
1280 | > EOF | |
1282 |
|
1281 | |||
1283 | $ cp test-uno.t test-dos.t |
|
1282 | $ cp test-uno.t test-dos.t | |
1284 | $ cd .. |
|
1283 | $ cd .. | |
1285 | $ cp -R tmp tmpp |
|
1284 | $ cp -R tmp tmpp | |
1286 | $ cp tmp/test-uno.t test-solo.t |
|
1285 | $ cp tmp/test-uno.t test-solo.t | |
1287 |
|
1286 | |||
1288 | $ rt tmp/ test-solo.t tmpp |
|
1287 | $ rt tmp/ test-solo.t tmpp | |
1289 | ..... |
|
1288 | ..... | |
1290 | # Ran 5 tests, 0 skipped, 0 failed. |
|
1289 | # Ran 5 tests, 0 skipped, 0 failed. | |
1291 | $ rm -rf tmp tmpp |
|
1290 | $ rm -rf tmp tmpp | |
1292 |
|
1291 | |||
1293 | support for running run-tests.py from another directory |
|
1292 | support for running run-tests.py from another directory | |
1294 | $ mkdir tmp && cd tmp |
|
1293 | $ mkdir tmp && cd tmp | |
1295 |
|
1294 | |||
1296 | $ cat > useful-file.sh << EOF |
|
1295 | $ cat > useful-file.sh << EOF | |
1297 | > important command |
|
1296 | > important command | |
1298 | > EOF |
|
1297 | > EOF | |
1299 |
|
1298 | |||
1300 | $ cat > test-folder.t << EOF |
|
1299 | $ cat > test-folder.t << EOF | |
1301 | > $ cat \$TESTDIR/useful-file.sh |
|
1300 | > $ cat \$TESTDIR/useful-file.sh | |
1302 | > important command |
|
1301 | > important command | |
1303 | > EOF |
|
1302 | > EOF | |
1304 |
|
1303 | |||
1305 | $ cat > test-folder-fail.t << EOF |
|
1304 | $ cat > test-folder-fail.t << EOF | |
1306 | > $ cat \$TESTDIR/useful-file.sh |
|
1305 | > $ cat \$TESTDIR/useful-file.sh | |
1307 | > important commando |
|
1306 | > important commando | |
1308 | > EOF |
|
1307 | > EOF | |
1309 |
|
1308 | |||
1310 | $ cd .. |
|
1309 | $ cd .. | |
1311 | $ rt tmp/test-*.t |
|
1310 | $ rt tmp/test-*.t | |
1312 |
|
1311 | |||
1313 | --- $TESTTMP/anothertests/tmp/test-folder-fail.t |
|
1312 | --- $TESTTMP/anothertests/tmp/test-folder-fail.t | |
1314 | +++ $TESTTMP/anothertests/tmp/test-folder-fail.t.err |
|
1313 | +++ $TESTTMP/anothertests/tmp/test-folder-fail.t.err | |
1315 | @@ -1,2 +1,2 @@ |
|
1314 | @@ -1,2 +1,2 @@ | |
1316 | $ cat $TESTDIR/useful-file.sh |
|
1315 | $ cat $TESTDIR/useful-file.sh | |
1317 | - important commando |
|
1316 | - important commando | |
1318 | + important command |
|
1317 | + important command | |
1319 |
|
1318 | |||
1320 | ERROR: test-folder-fail.t output changed |
|
1319 | ERROR: test-folder-fail.t output changed | |
1321 | !. |
|
1320 | !. | |
1322 | Failed test-folder-fail.t: output changed |
|
1321 | Failed test-folder-fail.t: output changed | |
1323 | # Ran 2 tests, 0 skipped, 1 failed. |
|
1322 | # Ran 2 tests, 0 skipped, 1 failed. | |
1324 | python hash seed: * (glob) |
|
1323 | python hash seed: * (glob) | |
1325 | [1] |
|
1324 | [1] | |
1326 |
|
1325 | |||
1327 | support for bisecting failed tests automatically |
|
1326 | support for bisecting failed tests automatically | |
1328 | $ hg init bisect |
|
1327 | $ hg init bisect | |
1329 | $ cd bisect |
|
1328 | $ cd bisect | |
1330 | $ cat >> test-bisect.t <<EOF |
|
1329 | $ cat >> test-bisect.t <<EOF | |
1331 | > $ echo pass |
|
1330 | > $ echo pass | |
1332 | > pass |
|
1331 | > pass | |
1333 | > EOF |
|
1332 | > EOF | |
1334 | $ hg add test-bisect.t |
|
1333 | $ hg add test-bisect.t | |
1335 | $ hg ci -m 'good' |
|
1334 | $ hg ci -m 'good' | |
1336 | $ cat >> test-bisect.t <<EOF |
|
1335 | $ cat >> test-bisect.t <<EOF | |
1337 | > $ echo pass |
|
1336 | > $ echo pass | |
1338 | > fail |
|
1337 | > fail | |
1339 | > EOF |
|
1338 | > EOF | |
1340 | $ hg ci -m 'bad' |
|
1339 | $ hg ci -m 'bad' | |
1341 | $ rt --known-good-rev=0 test-bisect.t |
|
1340 | $ rt --known-good-rev=0 test-bisect.t | |
1342 |
|
1341 | |||
1343 | --- $TESTTMP/anothertests/bisect/test-bisect.t |
|
1342 | --- $TESTTMP/anothertests/bisect/test-bisect.t | |
1344 | +++ $TESTTMP/anothertests/bisect/test-bisect.t.err |
|
1343 | +++ $TESTTMP/anothertests/bisect/test-bisect.t.err | |
1345 | @@ -1,4 +1,4 @@ |
|
1344 | @@ -1,4 +1,4 @@ | |
1346 | $ echo pass |
|
1345 | $ echo pass | |
1347 | pass |
|
1346 | pass | |
1348 | $ echo pass |
|
1347 | $ echo pass | |
1349 | - fail |
|
1348 | - fail | |
1350 | + pass |
|
1349 | + pass | |
1351 |
|
1350 | |||
1352 | ERROR: test-bisect.t output changed |
|
1351 | ERROR: test-bisect.t output changed | |
1353 | ! |
|
1352 | ! | |
1354 | Failed test-bisect.t: output changed |
|
1353 | Failed test-bisect.t: output changed | |
1355 | test-bisect.t broken by 72cbf122d116 (bad) |
|
1354 | test-bisect.t broken by 72cbf122d116 (bad) | |
1356 | # Ran 1 tests, 0 skipped, 1 failed. |
|
1355 | # Ran 1 tests, 0 skipped, 1 failed. | |
1357 | python hash seed: * (glob) |
|
1356 | python hash seed: * (glob) | |
1358 | [1] |
|
1357 | [1] | |
1359 |
|
1358 | |||
1360 | $ cd .. |
|
1359 | $ cd .. | |
1361 |
|
1360 | |||
1362 | support bisecting a separate repo |
|
1361 | support bisecting a separate repo | |
1363 |
|
1362 | |||
1364 | $ hg init bisect-dependent |
|
1363 | $ hg init bisect-dependent | |
1365 | $ cd bisect-dependent |
|
1364 | $ cd bisect-dependent | |
1366 | $ cat > test-bisect-dependent.t <<EOF |
|
1365 | $ cat > test-bisect-dependent.t <<EOF | |
1367 | > $ tail -1 \$TESTDIR/../bisect/test-bisect.t |
|
1366 | > $ tail -1 \$TESTDIR/../bisect/test-bisect.t | |
1368 | > pass |
|
1367 | > pass | |
1369 | > EOF |
|
1368 | > EOF | |
1370 | $ hg commit -Am dependent test-bisect-dependent.t |
|
1369 | $ hg commit -Am dependent test-bisect-dependent.t | |
1371 |
|
1370 | |||
1372 | $ rt --known-good-rev=0 test-bisect-dependent.t |
|
1371 | $ rt --known-good-rev=0 test-bisect-dependent.t | |
1373 |
|
1372 | |||
1374 | --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t |
|
1373 | --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t | |
1375 | +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err |
|
1374 | +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err | |
1376 | @@ -1,2 +1,2 @@ |
|
1375 | @@ -1,2 +1,2 @@ | |
1377 | $ tail -1 $TESTDIR/../bisect/test-bisect.t |
|
1376 | $ tail -1 $TESTDIR/../bisect/test-bisect.t | |
1378 | - pass |
|
1377 | - pass | |
1379 | + fail |
|
1378 | + fail | |
1380 |
|
1379 | |||
1381 | ERROR: test-bisect-dependent.t output changed |
|
1380 | ERROR: test-bisect-dependent.t output changed | |
1382 | ! |
|
1381 | ! | |
1383 | Failed test-bisect-dependent.t: output changed |
|
1382 | Failed test-bisect-dependent.t: output changed | |
1384 | Failed to identify failure point for test-bisect-dependent.t |
|
1383 | Failed to identify failure point for test-bisect-dependent.t | |
1385 | # Ran 1 tests, 0 skipped, 1 failed. |
|
1384 | # Ran 1 tests, 0 skipped, 1 failed. | |
1386 | python hash seed: * (glob) |
|
1385 | python hash seed: * (glob) | |
1387 | [1] |
|
1386 | [1] | |
1388 |
|
1387 | |||
1389 | $ rt --bisect-repo=../test-bisect test-bisect-dependent.t |
|
1388 | $ rt --bisect-repo=../test-bisect test-bisect-dependent.t | |
1390 | usage: run-tests.py [options] [tests] |
|
1389 | usage: run-tests.py [options] [tests] | |
1391 | run-tests.py: error: --bisect-repo cannot be used without --known-good-rev |
|
1390 | run-tests.py: error: --bisect-repo cannot be used without --known-good-rev | |
1392 | [2] |
|
1391 | [2] | |
1393 |
|
1392 | |||
1394 | $ rt --known-good-rev=0 --bisect-repo=../bisect test-bisect-dependent.t |
|
1393 | $ rt --known-good-rev=0 --bisect-repo=../bisect test-bisect-dependent.t | |
1395 |
|
1394 | |||
1396 | --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t |
|
1395 | --- $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t | |
1397 | +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err |
|
1396 | +++ $TESTTMP/anothertests/bisect-dependent/test-bisect-dependent.t.err | |
1398 | @@ -1,2 +1,2 @@ |
|
1397 | @@ -1,2 +1,2 @@ | |
1399 | $ tail -1 $TESTDIR/../bisect/test-bisect.t |
|
1398 | $ tail -1 $TESTDIR/../bisect/test-bisect.t | |
1400 | - pass |
|
1399 | - pass | |
1401 | + fail |
|
1400 | + fail | |
1402 |
|
1401 | |||
1403 | ERROR: test-bisect-dependent.t output changed |
|
1402 | ERROR: test-bisect-dependent.t output changed | |
1404 | ! |
|
1403 | ! | |
1405 | Failed test-bisect-dependent.t: output changed |
|
1404 | Failed test-bisect-dependent.t: output changed | |
1406 | test-bisect-dependent.t broken by 72cbf122d116 (bad) |
|
1405 | test-bisect-dependent.t broken by 72cbf122d116 (bad) | |
1407 | # Ran 1 tests, 0 skipped, 1 failed. |
|
1406 | # Ran 1 tests, 0 skipped, 1 failed. | |
1408 | python hash seed: * (glob) |
|
1407 | python hash seed: * (glob) | |
1409 | [1] |
|
1408 | [1] | |
1410 |
|
1409 | |||
1411 | $ cd .. |
|
1410 | $ cd .. | |
1412 |
|
1411 | |||
1413 | Test a broken #if statement doesn't break run-tests threading. |
|
1412 | Test a broken #if statement doesn't break run-tests threading. | |
1414 | ============================================================== |
|
1413 | ============================================================== | |
1415 | $ mkdir broken |
|
1414 | $ mkdir broken | |
1416 | $ cd broken |
|
1415 | $ cd broken | |
1417 | $ cat > test-broken.t <<EOF |
|
1416 | $ cat > test-broken.t <<EOF | |
1418 | > true |
|
1417 | > true | |
1419 | > #if notarealhghavefeature |
|
1418 | > #if notarealhghavefeature | |
1420 | > $ false |
|
1419 | > $ false | |
1421 | > #endif |
|
1420 | > #endif | |
1422 | > EOF |
|
1421 | > EOF | |
1423 | $ for f in 1 2 3 4 ; do |
|
1422 | $ for f in 1 2 3 4 ; do | |
1424 | > cat > test-works-$f.t <<EOF |
|
1423 | > cat > test-works-$f.t <<EOF | |
1425 | > This is test case $f |
|
1424 | > This is test case $f | |
1426 | > $ sleep 1 |
|
1425 | > $ sleep 1 | |
1427 | > EOF |
|
1426 | > EOF | |
1428 | > done |
|
1427 | > done | |
1429 | $ rt -j 2 |
|
1428 | $ rt -j 2 | |
1430 | .... |
|
1429 | .... | |
1431 | # Ran 5 tests, 0 skipped, 0 failed. |
|
1430 | # Ran 5 tests, 0 skipped, 0 failed. | |
1432 | skipped: unknown feature: notarealhghavefeature |
|
1431 | skipped: unknown feature: notarealhghavefeature | |
1433 |
|
1432 | |||
1434 | $ cd .. |
|
1433 | $ cd .. | |
1435 | $ rm -rf broken |
|
1434 | $ rm -rf broken | |
1436 |
|
1435 | |||
1437 | Test cases in .t files |
|
1436 | Test cases in .t files | |
1438 | ====================== |
|
1437 | ====================== | |
1439 | $ mkdir cases |
|
1438 | $ mkdir cases | |
1440 | $ cd cases |
|
1439 | $ cd cases | |
1441 | $ cat > test-cases-abc.t <<'EOF' |
|
1440 | $ cat > test-cases-abc.t <<'EOF' | |
1442 | > #testcases A B C |
|
1441 | > #testcases A B C | |
1443 | > $ V=B |
|
1442 | > $ V=B | |
1444 | > #if A |
|
1443 | > #if A | |
1445 | > $ V=A |
|
1444 | > $ V=A | |
1446 | > #endif |
|
1445 | > #endif | |
1447 | > #if C |
|
1446 | > #if C | |
1448 | > $ V=C |
|
1447 | > $ V=C | |
1449 | > #endif |
|
1448 | > #endif | |
1450 | > $ echo $V | sed 's/A/C/' |
|
1449 | > $ echo $V | sed 's/A/C/' | |
1451 | > C |
|
1450 | > C | |
1452 | > #if C |
|
1451 | > #if C | |
1453 | > $ [ $V = C ] |
|
1452 | > $ [ $V = C ] | |
1454 | > #endif |
|
1453 | > #endif | |
1455 | > #if A |
|
1454 | > #if A | |
1456 | > $ [ $V = C ] |
|
1455 | > $ [ $V = C ] | |
1457 | > [1] |
|
1456 | > [1] | |
1458 | > #endif |
|
1457 | > #endif | |
1459 | > #if no-C |
|
1458 | > #if no-C | |
1460 | > $ [ $V = C ] |
|
1459 | > $ [ $V = C ] | |
1461 | > [1] |
|
1460 | > [1] | |
1462 | > #endif |
|
1461 | > #endif | |
1463 | > $ [ $V = D ] |
|
1462 | > $ [ $V = D ] | |
1464 | > [1] |
|
1463 | > [1] | |
1465 | > EOF |
|
1464 | > EOF | |
1466 | $ rt |
|
1465 | $ rt | |
1467 | . |
|
1466 | . | |
1468 | --- $TESTTMP/anothertests/cases/test-cases-abc.t |
|
1467 | --- $TESTTMP/anothertests/cases/test-cases-abc.t | |
1469 | +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err |
|
1468 | +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err | |
1470 | @@ -7,7 +7,7 @@ |
|
1469 | @@ -7,7 +7,7 @@ | |
1471 | $ V=C |
|
1470 | $ V=C | |
1472 | #endif |
|
1471 | #endif | |
1473 | $ echo $V | sed 's/A/C/' |
|
1472 | $ echo $V | sed 's/A/C/' | |
1474 | - C |
|
1473 | - C | |
1475 | + B |
|
1474 | + B | |
1476 | #if C |
|
1475 | #if C | |
1477 | $ [ $V = C ] |
|
1476 | $ [ $V = C ] | |
1478 | #endif |
|
1477 | #endif | |
1479 |
|
1478 | |||
1480 | ERROR: test-cases-abc.t (case B) output changed |
|
1479 | ERROR: test-cases-abc.t (case B) output changed | |
1481 | !. |
|
1480 | !. | |
1482 | Failed test-cases-abc.t (case B): output changed |
|
1481 | Failed test-cases-abc.t (case B): output changed | |
1483 | # Ran 3 tests, 0 skipped, 1 failed. |
|
1482 | # Ran 3 tests, 0 skipped, 1 failed. | |
1484 | python hash seed: * (glob) |
|
1483 | python hash seed: * (glob) | |
1485 | [1] |
|
1484 | [1] | |
1486 |
|
1485 | |||
1487 | --restart works |
|
1486 | --restart works | |
1488 |
|
1487 | |||
1489 | $ rt --restart |
|
1488 | $ rt --restart | |
1490 |
|
1489 | |||
1491 | --- $TESTTMP/anothertests/cases/test-cases-abc.t |
|
1490 | --- $TESTTMP/anothertests/cases/test-cases-abc.t | |
1492 | +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err |
|
1491 | +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err | |
1493 | @@ -7,7 +7,7 @@ |
|
1492 | @@ -7,7 +7,7 @@ | |
1494 | $ V=C |
|
1493 | $ V=C | |
1495 | #endif |
|
1494 | #endif | |
1496 | $ echo $V | sed 's/A/C/' |
|
1495 | $ echo $V | sed 's/A/C/' | |
1497 | - C |
|
1496 | - C | |
1498 | + B |
|
1497 | + B | |
1499 | #if C |
|
1498 | #if C | |
1500 | $ [ $V = C ] |
|
1499 | $ [ $V = C ] | |
1501 | #endif |
|
1500 | #endif | |
1502 |
|
1501 | |||
1503 | ERROR: test-cases-abc.t (case B) output changed |
|
1502 | ERROR: test-cases-abc.t (case B) output changed | |
1504 | !. |
|
1503 | !. | |
1505 | Failed test-cases-abc.t (case B): output changed |
|
1504 | Failed test-cases-abc.t (case B): output changed | |
1506 | # Ran 2 tests, 0 skipped, 1 failed. |
|
1505 | # Ran 2 tests, 0 skipped, 1 failed. | |
1507 | python hash seed: * (glob) |
|
1506 | python hash seed: * (glob) | |
1508 | [1] |
|
1507 | [1] | |
1509 |
|
1508 | |||
1510 | --restart works with outputdir |
|
1509 | --restart works with outputdir | |
1511 |
|
1510 | |||
1512 | $ mkdir output |
|
1511 | $ mkdir output | |
1513 | $ mv test-cases-abc.t.B.err output |
|
1512 | $ mv test-cases-abc.t.B.err output | |
1514 | $ rt --restart --outputdir output |
|
1513 | $ rt --restart --outputdir output | |
1515 |
|
1514 | |||
1516 | --- $TESTTMP/anothertests/cases/test-cases-abc.t |
|
1515 | --- $TESTTMP/anothertests/cases/test-cases-abc.t | |
1517 | +++ $TESTTMP/anothertests/cases/output/test-cases-abc.t.B.err |
|
1516 | +++ $TESTTMP/anothertests/cases/output/test-cases-abc.t.B.err | |
1518 | @@ -7,7 +7,7 @@ |
|
1517 | @@ -7,7 +7,7 @@ | |
1519 | $ V=C |
|
1518 | $ V=C | |
1520 | #endif |
|
1519 | #endif | |
1521 | $ echo $V | sed 's/A/C/' |
|
1520 | $ echo $V | sed 's/A/C/' | |
1522 | - C |
|
1521 | - C | |
1523 | + B |
|
1522 | + B | |
1524 | #if C |
|
1523 | #if C | |
1525 | $ [ $V = C ] |
|
1524 | $ [ $V = C ] | |
1526 | #endif |
|
1525 | #endif | |
1527 |
|
1526 | |||
1528 | ERROR: test-cases-abc.t (case B) output changed |
|
1527 | ERROR: test-cases-abc.t (case B) output changed | |
1529 | !. |
|
1528 | !. | |
1530 | Failed test-cases-abc.t (case B): output changed |
|
1529 | Failed test-cases-abc.t (case B): output changed | |
1531 | # Ran 2 tests, 0 skipped, 1 failed. |
|
1530 | # Ran 2 tests, 0 skipped, 1 failed. | |
1532 | python hash seed: * (glob) |
|
1531 | python hash seed: * (glob) | |
1533 | [1] |
|
1532 | [1] | |
1534 |
|
1533 | |||
1535 | Test automatic pattern replacement |
|
1534 | Test automatic pattern replacement | |
1536 |
|
1535 | |||
1537 | $ cat << EOF >> common-pattern.py |
|
1536 | $ cat << EOF >> common-pattern.py | |
1538 | > substitutions = [ |
|
1537 | > substitutions = [ | |
1539 | > (br'foo-(.*)\\b', |
|
1538 | > (br'foo-(.*)\\b', | |
1540 | > br'\$XXX=\\1\$'), |
|
1539 | > br'\$XXX=\\1\$'), | |
1541 | > (br'bar\\n', |
|
1540 | > (br'bar\\n', | |
1542 | > br'\$YYY$\\n'), |
|
1541 | > br'\$YYY$\\n'), | |
1543 | > ] |
|
1542 | > ] | |
1544 | > EOF |
|
1543 | > EOF | |
1545 |
|
1544 | |||
1546 | $ cat << EOF >> test-substitution.t |
|
1545 | $ cat << EOF >> test-substitution.t | |
1547 | > $ echo foo-12 |
|
1546 | > $ echo foo-12 | |
1548 | > \$XXX=12$ |
|
1547 | > \$XXX=12$ | |
1549 | > $ echo foo-42 |
|
1548 | > $ echo foo-42 | |
1550 | > \$XXX=42$ |
|
1549 | > \$XXX=42$ | |
1551 | > $ echo bar prior |
|
1550 | > $ echo bar prior | |
1552 | > bar prior |
|
1551 | > bar prior | |
1553 | > $ echo lastbar |
|
1552 | > $ echo lastbar | |
1554 | > last\$YYY$ |
|
1553 | > last\$YYY$ | |
1555 | > $ echo foo-bar foo-baz |
|
1554 | > $ echo foo-bar foo-baz | |
1556 | > EOF |
|
1555 | > EOF | |
1557 |
|
1556 | |||
1558 | $ rt test-substitution.t |
|
1557 | $ rt test-substitution.t | |
1559 |
|
1558 | |||
1560 | --- $TESTTMP/anothertests/cases/test-substitution.t |
|
1559 | --- $TESTTMP/anothertests/cases/test-substitution.t | |
1561 | +++ $TESTTMP/anothertests/cases/test-substitution.t.err |
|
1560 | +++ $TESTTMP/anothertests/cases/test-substitution.t.err | |
1562 | @@ -7,3 +7,4 @@ |
|
1561 | @@ -7,3 +7,4 @@ | |
1563 | $ echo lastbar |
|
1562 | $ echo lastbar | |
1564 | last$YYY$ |
|
1563 | last$YYY$ | |
1565 | $ echo foo-bar foo-baz |
|
1564 | $ echo foo-bar foo-baz | |
1566 | + $XXX=bar foo-baz$ |
|
1565 | + $XXX=bar foo-baz$ | |
1567 |
|
1566 | |||
1568 | ERROR: test-substitution.t output changed |
|
1567 | ERROR: test-substitution.t output changed | |
1569 | ! |
|
1568 | ! | |
1570 | Failed test-substitution.t: output changed |
|
1569 | Failed test-substitution.t: output changed | |
1571 | # Ran 1 tests, 0 skipped, 1 failed. |
|
1570 | # Ran 1 tests, 0 skipped, 1 failed. | |
1572 | python hash seed: * (glob) |
|
1571 | python hash seed: * (glob) | |
1573 | [1] |
|
1572 | [1] | |
1574 |
|
1573 | |||
1575 | --extra-config-opt works |
|
1574 | --extra-config-opt works | |
1576 |
|
1575 | |||
1577 | $ cat << EOF >> test-config-opt.t |
|
1576 | $ cat << EOF >> test-config-opt.t | |
1578 | > $ hg init test-config-opt |
|
1577 | > $ hg init test-config-opt | |
1579 | > $ hg -R test-config-opt purge |
|
1578 | > $ hg -R test-config-opt purge | |
1580 | > EOF |
|
1579 | > EOF | |
1581 |
|
1580 | |||
1582 | $ rt --extra-config-opt extensions.purge= test-config-opt.t |
|
1581 | $ rt --extra-config-opt extensions.purge= test-config-opt.t | |
1583 | . |
|
1582 | . | |
1584 | # Ran 1 tests, 0 skipped, 0 failed. |
|
1583 | # Ran 1 tests, 0 skipped, 0 failed. |
General Comments 0
You need to be logged in to leave comments.
Login now