##// END OF EJS Templates
tests: hint how to run slow tests when rejecting
Kyle Lippincott -
r32473:c2b7fb58 default
parent child Browse files
Show More
@@ -1,636 +1,636 b''
1 from __future__ import absolute_import
1 from __future__ import absolute_import
2
2
3 import errno
3 import errno
4 import os
4 import os
5 import re
5 import re
6 import socket
6 import socket
7 import stat
7 import stat
8 import subprocess
8 import subprocess
9 import sys
9 import sys
10 import tempfile
10 import tempfile
11
11
12 tempprefix = 'hg-hghave-'
12 tempprefix = 'hg-hghave-'
13
13
14 checks = {
14 checks = {
15 "true": (lambda: True, "yak shaving"),
15 "true": (lambda: True, "yak shaving"),
16 "false": (lambda: False, "nail clipper"),
16 "false": (lambda: False, "nail clipper"),
17 }
17 }
18
18
19 def check(name, desc):
19 def check(name, desc):
20 """Registers a check function for a feature."""
20 """Registers a check function for a feature."""
21 def decorator(func):
21 def decorator(func):
22 checks[name] = (func, desc)
22 checks[name] = (func, desc)
23 return func
23 return func
24 return decorator
24 return decorator
25
25
26 def checkvers(name, desc, vers):
26 def checkvers(name, desc, vers):
27 """Registers a check function for each of a series of versions.
27 """Registers a check function for each of a series of versions.
28
28
29 vers can be a list or an iterator"""
29 vers can be a list or an iterator"""
30 def decorator(func):
30 def decorator(func):
31 def funcv(v):
31 def funcv(v):
32 def f():
32 def f():
33 return func(v)
33 return func(v)
34 return f
34 return f
35 for v in vers:
35 for v in vers:
36 v = str(v)
36 v = str(v)
37 f = funcv(v)
37 f = funcv(v)
38 checks['%s%s' % (name, v.replace('.', ''))] = (f, desc % v)
38 checks['%s%s' % (name, v.replace('.', ''))] = (f, desc % v)
39 return func
39 return func
40 return decorator
40 return decorator
41
41
42 def checkfeatures(features):
42 def checkfeatures(features):
43 result = {
43 result = {
44 'error': [],
44 'error': [],
45 'missing': [],
45 'missing': [],
46 'skipped': [],
46 'skipped': [],
47 }
47 }
48
48
49 for feature in features:
49 for feature in features:
50 negate = feature.startswith('no-')
50 negate = feature.startswith('no-')
51 if negate:
51 if negate:
52 feature = feature[3:]
52 feature = feature[3:]
53
53
54 if feature not in checks:
54 if feature not in checks:
55 result['missing'].append(feature)
55 result['missing'].append(feature)
56 continue
56 continue
57
57
58 check, desc = checks[feature]
58 check, desc = checks[feature]
59 try:
59 try:
60 available = check()
60 available = check()
61 except Exception:
61 except Exception:
62 result['error'].append('hghave check failed: %s' % feature)
62 result['error'].append('hghave check failed: %s' % feature)
63 continue
63 continue
64
64
65 if not negate and not available:
65 if not negate and not available:
66 result['skipped'].append('missing feature: %s' % desc)
66 result['skipped'].append('missing feature: %s' % desc)
67 elif negate and available:
67 elif negate and available:
68 result['skipped'].append('system supports %s' % desc)
68 result['skipped'].append('system supports %s' % desc)
69
69
70 return result
70 return result
71
71
72 def require(features):
72 def require(features):
73 """Require that features are available, exiting if not."""
73 """Require that features are available, exiting if not."""
74 result = checkfeatures(features)
74 result = checkfeatures(features)
75
75
76 for missing in result['missing']:
76 for missing in result['missing']:
77 sys.stderr.write('skipped: unknown feature: %s\n' % missing)
77 sys.stderr.write('skipped: unknown feature: %s\n' % missing)
78 for msg in result['skipped']:
78 for msg in result['skipped']:
79 sys.stderr.write('skipped: %s\n' % msg)
79 sys.stderr.write('skipped: %s\n' % msg)
80 for msg in result['error']:
80 for msg in result['error']:
81 sys.stderr.write('%s\n' % msg)
81 sys.stderr.write('%s\n' % msg)
82
82
83 if result['missing']:
83 if result['missing']:
84 sys.exit(2)
84 sys.exit(2)
85
85
86 if result['skipped'] or result['error']:
86 if result['skipped'] or result['error']:
87 sys.exit(1)
87 sys.exit(1)
88
88
89 def matchoutput(cmd, regexp, ignorestatus=False):
89 def matchoutput(cmd, regexp, ignorestatus=False):
90 """Return the match object if cmd executes successfully and its output
90 """Return the match object if cmd executes successfully and its output
91 is matched by the supplied regular expression.
91 is matched by the supplied regular expression.
92 """
92 """
93 r = re.compile(regexp)
93 r = re.compile(regexp)
94 try:
94 try:
95 p = subprocess.Popen(
95 p = subprocess.Popen(
96 cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
96 cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
97 except OSError as e:
97 except OSError as e:
98 if e.errno != errno.ENOENT:
98 if e.errno != errno.ENOENT:
99 raise
99 raise
100 ret = -1
100 ret = -1
101 ret = p.wait()
101 ret = p.wait()
102 s = p.stdout.read()
102 s = p.stdout.read()
103 return (ignorestatus or not ret) and r.search(s)
103 return (ignorestatus or not ret) and r.search(s)
104
104
105 @check("baz", "GNU Arch baz client")
105 @check("baz", "GNU Arch baz client")
106 def has_baz():
106 def has_baz():
107 return matchoutput('baz --version 2>&1', br'baz Bazaar version')
107 return matchoutput('baz --version 2>&1', br'baz Bazaar version')
108
108
109 @check("bzr", "Canonical's Bazaar client")
109 @check("bzr", "Canonical's Bazaar client")
110 def has_bzr():
110 def has_bzr():
111 try:
111 try:
112 import bzrlib
112 import bzrlib
113 import bzrlib.bzrdir
113 import bzrlib.bzrdir
114 import bzrlib.errors
114 import bzrlib.errors
115 import bzrlib.revision
115 import bzrlib.revision
116 import bzrlib.revisionspec
116 import bzrlib.revisionspec
117 bzrlib.revisionspec.RevisionSpec
117 bzrlib.revisionspec.RevisionSpec
118 return bzrlib.__doc__ is not None
118 return bzrlib.__doc__ is not None
119 except (AttributeError, ImportError):
119 except (AttributeError, ImportError):
120 return False
120 return False
121
121
122 @checkvers("bzr", "Canonical's Bazaar client >= %s", (1.14,))
122 @checkvers("bzr", "Canonical's Bazaar client >= %s", (1.14,))
123 def has_bzr_range(v):
123 def has_bzr_range(v):
124 major, minor = v.split('.')[0:2]
124 major, minor = v.split('.')[0:2]
125 try:
125 try:
126 import bzrlib
126 import bzrlib
127 return (bzrlib.__doc__ is not None
127 return (bzrlib.__doc__ is not None
128 and bzrlib.version_info[:2] >= (int(major), int(minor)))
128 and bzrlib.version_info[:2] >= (int(major), int(minor)))
129 except ImportError:
129 except ImportError:
130 return False
130 return False
131
131
132 @check("chg", "running with chg")
132 @check("chg", "running with chg")
133 def has_chg():
133 def has_chg():
134 return 'CHGHG' in os.environ
134 return 'CHGHG' in os.environ
135
135
136 @check("cvs", "cvs client/server")
136 @check("cvs", "cvs client/server")
137 def has_cvs():
137 def has_cvs():
138 re = br'Concurrent Versions System.*?server'
138 re = br'Concurrent Versions System.*?server'
139 return matchoutput('cvs --version 2>&1', re) and not has_msys()
139 return matchoutput('cvs --version 2>&1', re) and not has_msys()
140
140
141 @check("cvs112", "cvs client/server 1.12.* (not cvsnt)")
141 @check("cvs112", "cvs client/server 1.12.* (not cvsnt)")
142 def has_cvs112():
142 def has_cvs112():
143 re = br'Concurrent Versions System \(CVS\) 1.12.*?server'
143 re = br'Concurrent Versions System \(CVS\) 1.12.*?server'
144 return matchoutput('cvs --version 2>&1', re) and not has_msys()
144 return matchoutput('cvs --version 2>&1', re) and not has_msys()
145
145
146 @check("cvsnt", "cvsnt client/server")
146 @check("cvsnt", "cvsnt client/server")
147 def has_cvsnt():
147 def has_cvsnt():
148 re = br'Concurrent Versions System \(CVSNT\) (\d+).(\d+).*\(client/server\)'
148 re = br'Concurrent Versions System \(CVSNT\) (\d+).(\d+).*\(client/server\)'
149 return matchoutput('cvsnt --version 2>&1', re)
149 return matchoutput('cvsnt --version 2>&1', re)
150
150
151 @check("darcs", "darcs client")
151 @check("darcs", "darcs client")
152 def has_darcs():
152 def has_darcs():
153 return matchoutput('darcs --version', br'\b2\.([2-9]|\d{2})', True)
153 return matchoutput('darcs --version', br'\b2\.([2-9]|\d{2})', True)
154
154
155 @check("mtn", "monotone client (>= 1.0)")
155 @check("mtn", "monotone client (>= 1.0)")
156 def has_mtn():
156 def has_mtn():
157 return matchoutput('mtn --version', br'monotone', True) and not matchoutput(
157 return matchoutput('mtn --version', br'monotone', True) and not matchoutput(
158 'mtn --version', br'monotone 0\.', True)
158 'mtn --version', br'monotone 0\.', True)
159
159
160 @check("eol-in-paths", "end-of-lines in paths")
160 @check("eol-in-paths", "end-of-lines in paths")
161 def has_eol_in_paths():
161 def has_eol_in_paths():
162 try:
162 try:
163 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r')
163 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r')
164 os.close(fd)
164 os.close(fd)
165 os.remove(path)
165 os.remove(path)
166 return True
166 return True
167 except (IOError, OSError):
167 except (IOError, OSError):
168 return False
168 return False
169
169
170 @check("execbit", "executable bit")
170 @check("execbit", "executable bit")
171 def has_executablebit():
171 def has_executablebit():
172 try:
172 try:
173 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
173 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
174 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
174 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
175 try:
175 try:
176 os.close(fh)
176 os.close(fh)
177 m = os.stat(fn).st_mode & 0o777
177 m = os.stat(fn).st_mode & 0o777
178 new_file_has_exec = m & EXECFLAGS
178 new_file_has_exec = m & EXECFLAGS
179 os.chmod(fn, m ^ EXECFLAGS)
179 os.chmod(fn, m ^ EXECFLAGS)
180 exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m)
180 exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m)
181 finally:
181 finally:
182 os.unlink(fn)
182 os.unlink(fn)
183 except (IOError, OSError):
183 except (IOError, OSError):
184 # we don't care, the user probably won't be able to commit anyway
184 # we don't care, the user probably won't be able to commit anyway
185 return False
185 return False
186 return not (new_file_has_exec or exec_flags_cannot_flip)
186 return not (new_file_has_exec or exec_flags_cannot_flip)
187
187
188 @check("icasefs", "case insensitive file system")
188 @check("icasefs", "case insensitive file system")
189 def has_icasefs():
189 def has_icasefs():
190 # Stolen from mercurial.util
190 # Stolen from mercurial.util
191 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
191 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
192 os.close(fd)
192 os.close(fd)
193 try:
193 try:
194 s1 = os.stat(path)
194 s1 = os.stat(path)
195 d, b = os.path.split(path)
195 d, b = os.path.split(path)
196 p2 = os.path.join(d, b.upper())
196 p2 = os.path.join(d, b.upper())
197 if path == p2:
197 if path == p2:
198 p2 = os.path.join(d, b.lower())
198 p2 = os.path.join(d, b.lower())
199 try:
199 try:
200 s2 = os.stat(p2)
200 s2 = os.stat(p2)
201 return s2 == s1
201 return s2 == s1
202 except OSError:
202 except OSError:
203 return False
203 return False
204 finally:
204 finally:
205 os.remove(path)
205 os.remove(path)
206
206
207 @check("fifo", "named pipes")
207 @check("fifo", "named pipes")
208 def has_fifo():
208 def has_fifo():
209 if getattr(os, "mkfifo", None) is None:
209 if getattr(os, "mkfifo", None) is None:
210 return False
210 return False
211 name = tempfile.mktemp(dir='.', prefix=tempprefix)
211 name = tempfile.mktemp(dir='.', prefix=tempprefix)
212 try:
212 try:
213 os.mkfifo(name)
213 os.mkfifo(name)
214 os.unlink(name)
214 os.unlink(name)
215 return True
215 return True
216 except OSError:
216 except OSError:
217 return False
217 return False
218
218
219 @check("killdaemons", 'killdaemons.py support')
219 @check("killdaemons", 'killdaemons.py support')
220 def has_killdaemons():
220 def has_killdaemons():
221 return True
221 return True
222
222
223 @check("cacheable", "cacheable filesystem")
223 @check("cacheable", "cacheable filesystem")
224 def has_cacheable_fs():
224 def has_cacheable_fs():
225 from mercurial import util
225 from mercurial import util
226
226
227 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
227 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
228 os.close(fd)
228 os.close(fd)
229 try:
229 try:
230 return util.cachestat(path).cacheable()
230 return util.cachestat(path).cacheable()
231 finally:
231 finally:
232 os.remove(path)
232 os.remove(path)
233
233
234 @check("lsprof", "python lsprof module")
234 @check("lsprof", "python lsprof module")
235 def has_lsprof():
235 def has_lsprof():
236 try:
236 try:
237 import _lsprof
237 import _lsprof
238 _lsprof.Profiler # silence unused import warning
238 _lsprof.Profiler # silence unused import warning
239 return True
239 return True
240 except ImportError:
240 except ImportError:
241 return False
241 return False
242
242
243 def gethgversion():
243 def gethgversion():
244 m = matchoutput('hg --version --quiet 2>&1', br'(\d+)\.(\d+)')
244 m = matchoutput('hg --version --quiet 2>&1', br'(\d+)\.(\d+)')
245 if not m:
245 if not m:
246 return (0, 0)
246 return (0, 0)
247 return (int(m.group(1)), int(m.group(2)))
247 return (int(m.group(1)), int(m.group(2)))
248
248
249 @checkvers("hg", "Mercurial >= %s",
249 @checkvers("hg", "Mercurial >= %s",
250 list([(1.0 * x) / 10 for x in range(9, 99)]))
250 list([(1.0 * x) / 10 for x in range(9, 99)]))
251 def has_hg_range(v):
251 def has_hg_range(v):
252 major, minor = v.split('.')[0:2]
252 major, minor = v.split('.')[0:2]
253 return gethgversion() >= (int(major), int(minor))
253 return gethgversion() >= (int(major), int(minor))
254
254
255 @check("hg08", "Mercurial >= 0.8")
255 @check("hg08", "Mercurial >= 0.8")
256 def has_hg08():
256 def has_hg08():
257 if checks["hg09"][0]():
257 if checks["hg09"][0]():
258 return True
258 return True
259 return matchoutput('hg help annotate 2>&1', '--date')
259 return matchoutput('hg help annotate 2>&1', '--date')
260
260
261 @check("hg07", "Mercurial >= 0.7")
261 @check("hg07", "Mercurial >= 0.7")
262 def has_hg07():
262 def has_hg07():
263 if checks["hg08"][0]():
263 if checks["hg08"][0]():
264 return True
264 return True
265 return matchoutput('hg --version --quiet 2>&1', 'Mercurial Distributed SCM')
265 return matchoutput('hg --version --quiet 2>&1', 'Mercurial Distributed SCM')
266
266
267 @check("hg06", "Mercurial >= 0.6")
267 @check("hg06", "Mercurial >= 0.6")
268 def has_hg06():
268 def has_hg06():
269 if checks["hg07"][0]():
269 if checks["hg07"][0]():
270 return True
270 return True
271 return matchoutput('hg --version --quiet 2>&1', 'Mercurial version')
271 return matchoutput('hg --version --quiet 2>&1', 'Mercurial version')
272
272
273 @check("gettext", "GNU Gettext (msgfmt)")
273 @check("gettext", "GNU Gettext (msgfmt)")
274 def has_gettext():
274 def has_gettext():
275 return matchoutput('msgfmt --version', br'GNU gettext-tools')
275 return matchoutput('msgfmt --version', br'GNU gettext-tools')
276
276
277 @check("git", "git command line client")
277 @check("git", "git command line client")
278 def has_git():
278 def has_git():
279 return matchoutput('git --version 2>&1', br'^git version')
279 return matchoutput('git --version 2>&1', br'^git version')
280
280
281 @check("docutils", "Docutils text processing library")
281 @check("docutils", "Docutils text processing library")
282 def has_docutils():
282 def has_docutils():
283 try:
283 try:
284 import docutils.core
284 import docutils.core
285 docutils.core.publish_cmdline # silence unused import
285 docutils.core.publish_cmdline # silence unused import
286 return True
286 return True
287 except ImportError:
287 except ImportError:
288 return False
288 return False
289
289
290 def getsvnversion():
290 def getsvnversion():
291 m = matchoutput('svn --version --quiet 2>&1', br'^(\d+)\.(\d+)')
291 m = matchoutput('svn --version --quiet 2>&1', br'^(\d+)\.(\d+)')
292 if not m:
292 if not m:
293 return (0, 0)
293 return (0, 0)
294 return (int(m.group(1)), int(m.group(2)))
294 return (int(m.group(1)), int(m.group(2)))
295
295
296 @checkvers("svn", "subversion client and admin tools >= %s", (1.3, 1.5))
296 @checkvers("svn", "subversion client and admin tools >= %s", (1.3, 1.5))
297 def has_svn_range(v):
297 def has_svn_range(v):
298 major, minor = v.split('.')[0:2]
298 major, minor = v.split('.')[0:2]
299 return getsvnversion() >= (int(major), int(minor))
299 return getsvnversion() >= (int(major), int(minor))
300
300
301 @check("svn", "subversion client and admin tools")
301 @check("svn", "subversion client and admin tools")
302 def has_svn():
302 def has_svn():
303 return matchoutput('svn --version 2>&1', br'^svn, version') and \
303 return matchoutput('svn --version 2>&1', br'^svn, version') and \
304 matchoutput('svnadmin --version 2>&1', br'^svnadmin, version')
304 matchoutput('svnadmin --version 2>&1', br'^svnadmin, version')
305
305
306 @check("svn-bindings", "subversion python bindings")
306 @check("svn-bindings", "subversion python bindings")
307 def has_svn_bindings():
307 def has_svn_bindings():
308 try:
308 try:
309 import svn.core
309 import svn.core
310 version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR
310 version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR
311 if version < (1, 4):
311 if version < (1, 4):
312 return False
312 return False
313 return True
313 return True
314 except ImportError:
314 except ImportError:
315 return False
315 return False
316
316
317 @check("p4", "Perforce server and client")
317 @check("p4", "Perforce server and client")
318 def has_p4():
318 def has_p4():
319 return (matchoutput('p4 -V', br'Rev\. P4/') and
319 return (matchoutput('p4 -V', br'Rev\. P4/') and
320 matchoutput('p4d -V', br'Rev\. P4D/'))
320 matchoutput('p4d -V', br'Rev\. P4D/'))
321
321
322 @check("symlink", "symbolic links")
322 @check("symlink", "symbolic links")
323 def has_symlink():
323 def has_symlink():
324 if getattr(os, "symlink", None) is None:
324 if getattr(os, "symlink", None) is None:
325 return False
325 return False
326 name = tempfile.mktemp(dir='.', prefix=tempprefix)
326 name = tempfile.mktemp(dir='.', prefix=tempprefix)
327 try:
327 try:
328 os.symlink(".", name)
328 os.symlink(".", name)
329 os.unlink(name)
329 os.unlink(name)
330 return True
330 return True
331 except (OSError, AttributeError):
331 except (OSError, AttributeError):
332 return False
332 return False
333
333
334 @check("hardlink", "hardlinks")
334 @check("hardlink", "hardlinks")
335 def has_hardlink():
335 def has_hardlink():
336 from mercurial import util
336 from mercurial import util
337 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
337 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
338 os.close(fh)
338 os.close(fh)
339 name = tempfile.mktemp(dir='.', prefix=tempprefix)
339 name = tempfile.mktemp(dir='.', prefix=tempprefix)
340 try:
340 try:
341 util.oslink(fn, name)
341 util.oslink(fn, name)
342 os.unlink(name)
342 os.unlink(name)
343 return True
343 return True
344 except OSError:
344 except OSError:
345 return False
345 return False
346 finally:
346 finally:
347 os.unlink(fn)
347 os.unlink(fn)
348
348
349 @check("hardlink-whitelisted", "hardlinks on whitelisted filesystems")
349 @check("hardlink-whitelisted", "hardlinks on whitelisted filesystems")
350 def has_hardlink_whitelisted():
350 def has_hardlink_whitelisted():
351 from mercurial import util
351 from mercurial import util
352 try:
352 try:
353 fstype = util.getfstype('.')
353 fstype = util.getfstype('.')
354 except OSError:
354 except OSError:
355 return False
355 return False
356 return fstype in util._hardlinkfswhitelist
356 return fstype in util._hardlinkfswhitelist
357
357
358 @check("rmcwd", "can remove current working directory")
358 @check("rmcwd", "can remove current working directory")
359 def has_rmcwd():
359 def has_rmcwd():
360 ocwd = os.getcwd()
360 ocwd = os.getcwd()
361 temp = tempfile.mkdtemp(dir='.', prefix=tempprefix)
361 temp = tempfile.mkdtemp(dir='.', prefix=tempprefix)
362 try:
362 try:
363 os.chdir(temp)
363 os.chdir(temp)
364 # On Linux, 'rmdir .' isn't allowed, but the other names are okay.
364 # On Linux, 'rmdir .' isn't allowed, but the other names are okay.
365 # On Solaris and Windows, the cwd can't be removed by any names.
365 # On Solaris and Windows, the cwd can't be removed by any names.
366 os.rmdir(os.getcwd())
366 os.rmdir(os.getcwd())
367 return True
367 return True
368 except OSError:
368 except OSError:
369 return False
369 return False
370 finally:
370 finally:
371 os.chdir(ocwd)
371 os.chdir(ocwd)
372 # clean up temp dir on platforms where cwd can't be removed
372 # clean up temp dir on platforms where cwd can't be removed
373 try:
373 try:
374 os.rmdir(temp)
374 os.rmdir(temp)
375 except OSError:
375 except OSError:
376 pass
376 pass
377
377
378 @check("tla", "GNU Arch tla client")
378 @check("tla", "GNU Arch tla client")
379 def has_tla():
379 def has_tla():
380 return matchoutput('tla --version 2>&1', br'The GNU Arch Revision')
380 return matchoutput('tla --version 2>&1', br'The GNU Arch Revision')
381
381
382 @check("gpg", "gpg client")
382 @check("gpg", "gpg client")
383 def has_gpg():
383 def has_gpg():
384 return matchoutput('gpg --version 2>&1', br'GnuPG')
384 return matchoutput('gpg --version 2>&1', br'GnuPG')
385
385
386 @check("gpg2", "gpg client v2")
386 @check("gpg2", "gpg client v2")
387 def has_gpg2():
387 def has_gpg2():
388 return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.')
388 return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.')
389
389
390 @check("gpg21", "gpg client v2.1+")
390 @check("gpg21", "gpg client v2.1+")
391 def has_gpg21():
391 def has_gpg21():
392 return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.(?!0)')
392 return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.(?!0)')
393
393
394 @check("unix-permissions", "unix-style permissions")
394 @check("unix-permissions", "unix-style permissions")
395 def has_unix_permissions():
395 def has_unix_permissions():
396 d = tempfile.mkdtemp(dir='.', prefix=tempprefix)
396 d = tempfile.mkdtemp(dir='.', prefix=tempprefix)
397 try:
397 try:
398 fname = os.path.join(d, 'foo')
398 fname = os.path.join(d, 'foo')
399 for umask in (0o77, 0o07, 0o22):
399 for umask in (0o77, 0o07, 0o22):
400 os.umask(umask)
400 os.umask(umask)
401 f = open(fname, 'w')
401 f = open(fname, 'w')
402 f.close()
402 f.close()
403 mode = os.stat(fname).st_mode
403 mode = os.stat(fname).st_mode
404 os.unlink(fname)
404 os.unlink(fname)
405 if mode & 0o777 != ~umask & 0o666:
405 if mode & 0o777 != ~umask & 0o666:
406 return False
406 return False
407 return True
407 return True
408 finally:
408 finally:
409 os.rmdir(d)
409 os.rmdir(d)
410
410
411 @check("unix-socket", "AF_UNIX socket family")
411 @check("unix-socket", "AF_UNIX socket family")
412 def has_unix_socket():
412 def has_unix_socket():
413 return getattr(socket, 'AF_UNIX', None) is not None
413 return getattr(socket, 'AF_UNIX', None) is not None
414
414
415 @check("root", "root permissions")
415 @check("root", "root permissions")
416 def has_root():
416 def has_root():
417 return getattr(os, 'geteuid', None) and os.geteuid() == 0
417 return getattr(os, 'geteuid', None) and os.geteuid() == 0
418
418
419 @check("pyflakes", "Pyflakes python linter")
419 @check("pyflakes", "Pyflakes python linter")
420 def has_pyflakes():
420 def has_pyflakes():
421 return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"",
421 return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"",
422 br"<stdin>:1: 're' imported but unused",
422 br"<stdin>:1: 're' imported but unused",
423 True)
423 True)
424
424
425 @check("pylint", "Pylint python linter")
425 @check("pylint", "Pylint python linter")
426 def has_pylint():
426 def has_pylint():
427 return matchoutput("pylint --help",
427 return matchoutput("pylint --help",
428 br"Usage: pylint",
428 br"Usage: pylint",
429 True)
429 True)
430
430
431 @check("pygments", "Pygments source highlighting library")
431 @check("pygments", "Pygments source highlighting library")
432 def has_pygments():
432 def has_pygments():
433 try:
433 try:
434 import pygments
434 import pygments
435 pygments.highlight # silence unused import warning
435 pygments.highlight # silence unused import warning
436 return True
436 return True
437 except ImportError:
437 except ImportError:
438 return False
438 return False
439
439
440 @check("outer-repo", "outer repo")
440 @check("outer-repo", "outer repo")
441 def has_outer_repo():
441 def has_outer_repo():
442 # failing for other reasons than 'no repo' imply that there is a repo
442 # failing for other reasons than 'no repo' imply that there is a repo
443 return not matchoutput('hg root 2>&1',
443 return not matchoutput('hg root 2>&1',
444 br'abort: no repository found', True)
444 br'abort: no repository found', True)
445
445
446 @check("ssl", "ssl module available")
446 @check("ssl", "ssl module available")
447 def has_ssl():
447 def has_ssl():
448 try:
448 try:
449 import ssl
449 import ssl
450 ssl.CERT_NONE
450 ssl.CERT_NONE
451 return True
451 return True
452 except ImportError:
452 except ImportError:
453 return False
453 return False
454
454
455 @check("sslcontext", "python >= 2.7.9 ssl")
455 @check("sslcontext", "python >= 2.7.9 ssl")
456 def has_sslcontext():
456 def has_sslcontext():
457 try:
457 try:
458 import ssl
458 import ssl
459 ssl.SSLContext
459 ssl.SSLContext
460 return True
460 return True
461 except (ImportError, AttributeError):
461 except (ImportError, AttributeError):
462 return False
462 return False
463
463
464 @check("defaultcacerts", "can verify SSL certs by system's CA certs store")
464 @check("defaultcacerts", "can verify SSL certs by system's CA certs store")
465 def has_defaultcacerts():
465 def has_defaultcacerts():
466 from mercurial import sslutil, ui as uimod
466 from mercurial import sslutil, ui as uimod
467 ui = uimod.ui.load()
467 ui = uimod.ui.load()
468 return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts
468 return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts
469
469
470 @check("defaultcacertsloaded", "detected presence of loaded system CA certs")
470 @check("defaultcacertsloaded", "detected presence of loaded system CA certs")
471 def has_defaultcacertsloaded():
471 def has_defaultcacertsloaded():
472 import ssl
472 import ssl
473 from mercurial import sslutil, ui as uimod
473 from mercurial import sslutil, ui as uimod
474
474
475 if not has_defaultcacerts():
475 if not has_defaultcacerts():
476 return False
476 return False
477 if not has_sslcontext():
477 if not has_sslcontext():
478 return False
478 return False
479
479
480 ui = uimod.ui.load()
480 ui = uimod.ui.load()
481 cafile = sslutil._defaultcacerts(ui)
481 cafile = sslutil._defaultcacerts(ui)
482 ctx = ssl.create_default_context()
482 ctx = ssl.create_default_context()
483 if cafile:
483 if cafile:
484 ctx.load_verify_locations(cafile=cafile)
484 ctx.load_verify_locations(cafile=cafile)
485 else:
485 else:
486 ctx.load_default_certs()
486 ctx.load_default_certs()
487
487
488 return len(ctx.get_ca_certs()) > 0
488 return len(ctx.get_ca_certs()) > 0
489
489
490 @check("tls1.2", "TLS 1.2 protocol support")
490 @check("tls1.2", "TLS 1.2 protocol support")
491 def has_tls1_2():
491 def has_tls1_2():
492 from mercurial import sslutil
492 from mercurial import sslutil
493 return 'tls1.2' in sslutil.supportedprotocols
493 return 'tls1.2' in sslutil.supportedprotocols
494
494
495 @check("windows", "Windows")
495 @check("windows", "Windows")
496 def has_windows():
496 def has_windows():
497 return os.name == 'nt'
497 return os.name == 'nt'
498
498
499 @check("system-sh", "system() uses sh")
499 @check("system-sh", "system() uses sh")
500 def has_system_sh():
500 def has_system_sh():
501 return os.name != 'nt'
501 return os.name != 'nt'
502
502
503 @check("serve", "platform and python can manage 'hg serve -d'")
503 @check("serve", "platform and python can manage 'hg serve -d'")
504 def has_serve():
504 def has_serve():
505 return os.name != 'nt' # gross approximation
505 return os.name != 'nt' # gross approximation
506
506
507 @check("test-repo", "running tests from repository")
507 @check("test-repo", "running tests from repository")
508 def has_test_repo():
508 def has_test_repo():
509 t = os.environ["TESTDIR"]
509 t = os.environ["TESTDIR"]
510 return os.path.isdir(os.path.join(t, "..", ".hg"))
510 return os.path.isdir(os.path.join(t, "..", ".hg"))
511
511
512 @check("tic", "terminfo compiler and curses module")
512 @check("tic", "terminfo compiler and curses module")
513 def has_tic():
513 def has_tic():
514 try:
514 try:
515 import curses
515 import curses
516 curses.COLOR_BLUE
516 curses.COLOR_BLUE
517 return matchoutput('test -x "`which tic`"', br'')
517 return matchoutput('test -x "`which tic`"', br'')
518 except ImportError:
518 except ImportError:
519 return False
519 return False
520
520
521 @check("msys", "Windows with MSYS")
521 @check("msys", "Windows with MSYS")
522 def has_msys():
522 def has_msys():
523 return os.getenv('MSYSTEM')
523 return os.getenv('MSYSTEM')
524
524
525 @check("aix", "AIX")
525 @check("aix", "AIX")
526 def has_aix():
526 def has_aix():
527 return sys.platform.startswith("aix")
527 return sys.platform.startswith("aix")
528
528
529 @check("osx", "OS X")
529 @check("osx", "OS X")
530 def has_osx():
530 def has_osx():
531 return sys.platform == 'darwin'
531 return sys.platform == 'darwin'
532
532
533 @check("osxpackaging", "OS X packaging tools")
533 @check("osxpackaging", "OS X packaging tools")
534 def has_osxpackaging():
534 def has_osxpackaging():
535 try:
535 try:
536 return (matchoutput('pkgbuild', br'Usage: pkgbuild ', ignorestatus=1)
536 return (matchoutput('pkgbuild', br'Usage: pkgbuild ', ignorestatus=1)
537 and matchoutput(
537 and matchoutput(
538 'productbuild', br'Usage: productbuild ',
538 'productbuild', br'Usage: productbuild ',
539 ignorestatus=1)
539 ignorestatus=1)
540 and matchoutput('lsbom', br'Usage: lsbom', ignorestatus=1)
540 and matchoutput('lsbom', br'Usage: lsbom', ignorestatus=1)
541 and matchoutput(
541 and matchoutput(
542 'xar --help', br'Usage: xar', ignorestatus=1))
542 'xar --help', br'Usage: xar', ignorestatus=1))
543 except ImportError:
543 except ImportError:
544 return False
544 return False
545
545
546 @check("docker", "docker support")
546 @check("docker", "docker support")
547 def has_docker():
547 def has_docker():
548 pat = br'A self-sufficient runtime for'
548 pat = br'A self-sufficient runtime for'
549 if matchoutput('docker --help', pat):
549 if matchoutput('docker --help', pat):
550 if 'linux' not in sys.platform:
550 if 'linux' not in sys.platform:
551 # TODO: in theory we should be able to test docker-based
551 # TODO: in theory we should be able to test docker-based
552 # package creation on non-linux using boot2docker, but in
552 # package creation on non-linux using boot2docker, but in
553 # practice that requires extra coordination to make sure
553 # practice that requires extra coordination to make sure
554 # $TESTTEMP is going to be visible at the same path to the
554 # $TESTTEMP is going to be visible at the same path to the
555 # boot2docker VM. If we figure out how to verify that, we
555 # boot2docker VM. If we figure out how to verify that, we
556 # can use the following instead of just saying False:
556 # can use the following instead of just saying False:
557 # return 'DOCKER_HOST' in os.environ
557 # return 'DOCKER_HOST' in os.environ
558 return False
558 return False
559
559
560 return True
560 return True
561 return False
561 return False
562
562
563 @check("debhelper", "debian packaging tools")
563 @check("debhelper", "debian packaging tools")
564 def has_debhelper():
564 def has_debhelper():
565 dpkg = matchoutput('dpkg --version',
565 dpkg = matchoutput('dpkg --version',
566 br"Debian `dpkg' package management program")
566 br"Debian `dpkg' package management program")
567 dh = matchoutput('dh --help',
567 dh = matchoutput('dh --help',
568 br'dh is a part of debhelper.', ignorestatus=True)
568 br'dh is a part of debhelper.', ignorestatus=True)
569 dh_py2 = matchoutput('dh_python2 --help',
569 dh_py2 = matchoutput('dh_python2 --help',
570 br'other supported Python versions')
570 br'other supported Python versions')
571 return dpkg and dh and dh_py2
571 return dpkg and dh and dh_py2
572
572
573 @check("demandimport", "demandimport enabled")
573 @check("demandimport", "demandimport enabled")
574 def has_demandimport():
574 def has_demandimport():
575 return os.environ.get('HGDEMANDIMPORT') != 'disable'
575 return os.environ.get('HGDEMANDIMPORT') != 'disable'
576
576
577 @check("absimport", "absolute_import in __future__")
577 @check("absimport", "absolute_import in __future__")
578 def has_absimport():
578 def has_absimport():
579 import __future__
579 import __future__
580 from mercurial import util
580 from mercurial import util
581 return util.safehasattr(__future__, "absolute_import")
581 return util.safehasattr(__future__, "absolute_import")
582
582
583 @check("py3k", "running with Python 3.x")
583 @check("py3k", "running with Python 3.x")
584 def has_py3k():
584 def has_py3k():
585 return 3 == sys.version_info[0]
585 return 3 == sys.version_info[0]
586
586
587 @check("py3exe", "a Python 3.x interpreter is available")
587 @check("py3exe", "a Python 3.x interpreter is available")
588 def has_python3exe():
588 def has_python3exe():
589 return 'PYTHON3' in os.environ
589 return 'PYTHON3' in os.environ
590
590
591 @check("py3pygments", "Pygments available on Python 3.x")
591 @check("py3pygments", "Pygments available on Python 3.x")
592 def has_py3pygments():
592 def has_py3pygments():
593 if has_py3k():
593 if has_py3k():
594 return has_pygments()
594 return has_pygments()
595 elif has_python3exe():
595 elif has_python3exe():
596 # just check exit status (ignoring output)
596 # just check exit status (ignoring output)
597 py3 = os.environ['PYTHON3']
597 py3 = os.environ['PYTHON3']
598 return matchoutput('%s -c "import pygments"' % py3, br'')
598 return matchoutput('%s -c "import pygments"' % py3, br'')
599 return False
599 return False
600
600
601 @check("pure", "running with pure Python code")
601 @check("pure", "running with pure Python code")
602 def has_pure():
602 def has_pure():
603 return any([
603 return any([
604 os.environ.get("HGMODULEPOLICY") == "py",
604 os.environ.get("HGMODULEPOLICY") == "py",
605 os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure",
605 os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure",
606 ])
606 ])
607
607
608 @check("slow", "allow slow tests")
608 @check("slow", "allow slow tests (use --allow-slow-tests)")
609 def has_slow():
609 def has_slow():
610 return os.environ.get('HGTEST_SLOW') == 'slow'
610 return os.environ.get('HGTEST_SLOW') == 'slow'
611
611
612 @check("hypothesis", "Hypothesis automated test generation")
612 @check("hypothesis", "Hypothesis automated test generation")
613 def has_hypothesis():
613 def has_hypothesis():
614 try:
614 try:
615 import hypothesis
615 import hypothesis
616 hypothesis.given
616 hypothesis.given
617 return True
617 return True
618 except ImportError:
618 except ImportError:
619 return False
619 return False
620
620
621 @check("unziplinks", "unzip(1) understands and extracts symlinks")
621 @check("unziplinks", "unzip(1) understands and extracts symlinks")
622 def unzip_understands_symlinks():
622 def unzip_understands_symlinks():
623 return matchoutput('unzip --help', br'Info-ZIP')
623 return matchoutput('unzip --help', br'Info-ZIP')
624
624
625 @check("zstd", "zstd Python module available")
625 @check("zstd", "zstd Python module available")
626 def has_zstd():
626 def has_zstd():
627 try:
627 try:
628 import mercurial.zstd
628 import mercurial.zstd
629 mercurial.zstd.__version__
629 mercurial.zstd.__version__
630 return True
630 return True
631 except ImportError:
631 except ImportError:
632 return False
632 return False
633
633
634 @check("devfull", "/dev/full special file")
634 @check("devfull", "/dev/full special file")
635 def has_dev_full():
635 def has_dev_full():
636 return os.path.exists('/dev/full')
636 return os.path.exists('/dev/full')
@@ -1,977 +1,977 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 warned, 0 failed.
12 # Ran 0 tests, 0 skipped, 0 warned, 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 warned, 0 failed.
28 # Ran 0 tests, 0 skipped, 0 warned, 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
36
37 run-tests.py: error: --with-hg must specify an executable hg script
37 run-tests.py: error: --with-hg must specify an executable hg script
38 [2]
38 [2]
39 $ rm hg
39 $ rm hg
40 #endif
40 #endif
41
41
42 Features for testing optional lines
42 Features for testing optional lines
43 ===================================
43 ===================================
44
44
45 $ cat > hghaveaddon.py <<EOF
45 $ cat > hghaveaddon.py <<EOF
46 > import hghave
46 > import hghave
47 > @hghave.check("custom", "custom hghave feature")
47 > @hghave.check("custom", "custom hghave feature")
48 > def has_custom():
48 > def has_custom():
49 > return True
49 > return True
50 > @hghave.check("missing", "missing hghave feature")
50 > @hghave.check("missing", "missing hghave feature")
51 > def has_missing():
51 > def has_missing():
52 > return False
52 > return False
53 > EOF
53 > EOF
54
54
55 an empty test
55 an empty test
56 =======================
56 =======================
57
57
58 $ touch test-empty.t
58 $ touch test-empty.t
59 $ rt
59 $ rt
60 .
60 .
61 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
61 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
62 $ rm test-empty.t
62 $ rm test-empty.t
63
63
64 a succesful test
64 a succesful test
65 =======================
65 =======================
66
66
67 $ cat > test-success.t << EOF
67 $ cat > test-success.t << EOF
68 > $ echo babar
68 > $ echo babar
69 > babar
69 > babar
70 > $ echo xyzzy
70 > $ echo xyzzy
71 > dont_print (?)
71 > dont_print (?)
72 > nothing[42]line (re) (?)
72 > nothing[42]line (re) (?)
73 > never*happens (glob) (?)
73 > never*happens (glob) (?)
74 > more_nothing (?)
74 > more_nothing (?)
75 > xyzzy
75 > xyzzy
76 > nor this (?)
76 > nor this (?)
77 > $ printf 'abc\ndef\nxyz\n'
77 > $ printf 'abc\ndef\nxyz\n'
78 > 123 (?)
78 > 123 (?)
79 > abc
79 > abc
80 > def (?)
80 > def (?)
81 > 456 (?)
81 > 456 (?)
82 > xyz
82 > xyz
83 > $ printf 'zyx\nwvu\ntsr\n'
83 > $ printf 'zyx\nwvu\ntsr\n'
84 > abc (?)
84 > abc (?)
85 > zyx (custom !)
85 > zyx (custom !)
86 > wvu
86 > wvu
87 > no_print (no-custom !)
87 > no_print (no-custom !)
88 > tsr (no-missing !)
88 > tsr (no-missing !)
89 > missing (missing !)
89 > missing (missing !)
90 > EOF
90 > EOF
91
91
92 $ rt
92 $ rt
93 .
93 .
94 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
94 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
95
95
96 failing test
96 failing test
97 ==================
97 ==================
98
98
99 test churn with globs
99 test churn with globs
100 $ cat > test-failure.t <<EOF
100 $ cat > test-failure.t <<EOF
101 > $ echo "bar-baz"; echo "bar-bad"
101 > $ echo "bar-baz"; echo "bar-bad"
102 > bar*bad (glob)
102 > bar*bad (glob)
103 > bar*baz (glob)
103 > bar*baz (glob)
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,3 +1,3 @@
109 @@ -1,3 +1,3 @@
110 $ echo "bar-baz"; echo "bar-bad"
110 $ echo "bar-baz"; echo "bar-bad"
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
114
115 ERROR: test-failure.t output changed
115 ERROR: test-failure.t output changed
116 !
116 !
117 Failed test-failure.t: output changed
117 Failed test-failure.t: output changed
118 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
118 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
119 python hash seed: * (glob)
119 python hash seed: * (glob)
120 [1]
120 [1]
121
121
122 basic failing test
122 basic failing test
123 $ cat > test-failure.t << EOF
123 $ cat > test-failure.t << EOF
124 > $ echo babar
124 > $ echo babar
125 > rataxes
125 > rataxes
126 > This is a noop statement so that
126 > This is a noop statement so that
127 > this test is still more bytes than success.
127 > this test is still more bytes than success.
128 > pad pad pad pad............................................................
128 > pad pad pad pad............................................................
129 > pad pad pad pad............................................................
129 > pad pad pad pad............................................................
130 > pad pad pad pad............................................................
130 > pad pad pad pad............................................................
131 > pad pad pad pad............................................................
131 > pad pad pad pad............................................................
132 > pad pad pad pad............................................................
132 > pad pad pad pad............................................................
133 > pad pad pad pad............................................................
133 > pad pad pad pad............................................................
134 > EOF
134 > EOF
135
135
136 >>> fh = open('test-failure-unicode.t', 'wb')
136 >>> fh = open('test-failure-unicode.t', 'wb')
137 >>> fh.write(u' $ echo babar\u03b1\n'.encode('utf-8')) and None
137 >>> fh.write(u' $ echo babar\u03b1\n'.encode('utf-8')) and None
138 >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8')) and None
138 >>> fh.write(u' l\u03b5\u03b5t\n'.encode('utf-8')) and None
139
139
140 $ rt
140 $ rt
141
141
142 --- $TESTTMP/test-failure.t
142 --- $TESTTMP/test-failure.t
143 +++ $TESTTMP/test-failure.t.err
143 +++ $TESTTMP/test-failure.t.err
144 @@ -1,5 +1,5 @@
144 @@ -1,5 +1,5 @@
145 $ echo babar
145 $ echo babar
146 - rataxes
146 - rataxes
147 + babar
147 + babar
148 This is a noop statement so that
148 This is a noop statement so that
149 this test is still more bytes than success.
149 this test is still more bytes than success.
150 pad pad pad pad............................................................
150 pad pad pad pad............................................................
151
151
152 ERROR: test-failure.t output changed
152 ERROR: test-failure.t output changed
153 !.
153 !.
154 --- $TESTTMP/test-failure-unicode.t
154 --- $TESTTMP/test-failure-unicode.t
155 +++ $TESTTMP/test-failure-unicode.t.err
155 +++ $TESTTMP/test-failure-unicode.t.err
156 @@ -1,2 +1,2 @@
156 @@ -1,2 +1,2 @@
157 $ echo babar\xce\xb1 (esc)
157 $ echo babar\xce\xb1 (esc)
158 - l\xce\xb5\xce\xb5t (esc)
158 - l\xce\xb5\xce\xb5t (esc)
159 + babar\xce\xb1 (esc)
159 + babar\xce\xb1 (esc)
160
160
161 ERROR: test-failure-unicode.t output changed
161 ERROR: test-failure-unicode.t output changed
162 !
162 !
163 Failed test-failure.t: output changed
163 Failed test-failure.t: output changed
164 Failed test-failure-unicode.t: output changed
164 Failed test-failure-unicode.t: output changed
165 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
165 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
166 python hash seed: * (glob)
166 python hash seed: * (glob)
167 [1]
167 [1]
168
168
169 test --xunit support
169 test --xunit support
170 $ rt --xunit=xunit.xml
170 $ rt --xunit=xunit.xml
171
171
172 --- $TESTTMP/test-failure.t
172 --- $TESTTMP/test-failure.t
173 +++ $TESTTMP/test-failure.t.err
173 +++ $TESTTMP/test-failure.t.err
174 @@ -1,5 +1,5 @@
174 @@ -1,5 +1,5 @@
175 $ echo babar
175 $ echo babar
176 - rataxes
176 - rataxes
177 + babar
177 + babar
178 This is a noop statement so that
178 This is a noop statement so that
179 this test is still more bytes than success.
179 this test is still more bytes than success.
180 pad pad pad pad............................................................
180 pad pad pad pad............................................................
181
181
182 ERROR: test-failure.t output changed
182 ERROR: test-failure.t output changed
183 !.
183 !.
184 --- $TESTTMP/test-failure-unicode.t
184 --- $TESTTMP/test-failure-unicode.t
185 +++ $TESTTMP/test-failure-unicode.t.err
185 +++ $TESTTMP/test-failure-unicode.t.err
186 @@ -1,2 +1,2 @@
186 @@ -1,2 +1,2 @@
187 $ echo babar\xce\xb1 (esc)
187 $ echo babar\xce\xb1 (esc)
188 - l\xce\xb5\xce\xb5t (esc)
188 - l\xce\xb5\xce\xb5t (esc)
189 + babar\xce\xb1 (esc)
189 + babar\xce\xb1 (esc)
190
190
191 ERROR: test-failure-unicode.t output changed
191 ERROR: test-failure-unicode.t output changed
192 !
192 !
193 Failed test-failure.t: output changed
193 Failed test-failure.t: output changed
194 Failed test-failure-unicode.t: output changed
194 Failed test-failure-unicode.t: output changed
195 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
195 # Ran 3 tests, 0 skipped, 0 warned, 2 failed.
196 python hash seed: * (glob)
196 python hash seed: * (glob)
197 [1]
197 [1]
198 $ cat xunit.xml
198 $ cat xunit.xml
199 <?xml version="1.0" encoding="utf-8"?>
199 <?xml version="1.0" encoding="utf-8"?>
200 <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3">
200 <testsuite errors="0" failures="2" name="run-tests" skipped="0" tests="3">
201 <testcase name="test-success.t" time="*"/> (glob)
201 <testcase name="test-success.t" time="*"/> (glob)
202 <testcase name="test-failure-unicode.t" time="*"> (glob)
202 <testcase name="test-failure-unicode.t" time="*"> (glob)
203 <![CDATA[--- $TESTTMP/test-failure-unicode.t
203 <![CDATA[--- $TESTTMP/test-failure-unicode.t
204 +++ $TESTTMP/test-failure-unicode.t.err
204 +++ $TESTTMP/test-failure-unicode.t.err
205 @@ -1,2 +1,2 @@
205 @@ -1,2 +1,2 @@
206 $ echo babar\xce\xb1 (esc)
206 $ echo babar\xce\xb1 (esc)
207 - l\xce\xb5\xce\xb5t (esc)
207 - l\xce\xb5\xce\xb5t (esc)
208 + babar\xce\xb1 (esc)
208 + babar\xce\xb1 (esc)
209 ]]> </testcase>
209 ]]> </testcase>
210 <testcase name="test-failure.t" time="*"> (glob)
210 <testcase name="test-failure.t" time="*"> (glob)
211 <![CDATA[--- $TESTTMP/test-failure.t
211 <![CDATA[--- $TESTTMP/test-failure.t
212 +++ $TESTTMP/test-failure.t.err
212 +++ $TESTTMP/test-failure.t.err
213 @@ -1,5 +1,5 @@
213 @@ -1,5 +1,5 @@
214 $ echo babar
214 $ echo babar
215 - rataxes
215 - rataxes
216 + babar
216 + babar
217 This is a noop statement so that
217 This is a noop statement so that
218 this test is still more bytes than success.
218 this test is still more bytes than success.
219 pad pad pad pad............................................................
219 pad pad pad pad............................................................
220 ]]> </testcase>
220 ]]> </testcase>
221 </testsuite>
221 </testsuite>
222
222
223 $ cat .testtimes
223 $ cat .testtimes
224 test-failure-unicode.t * (glob)
224 test-failure-unicode.t * (glob)
225 test-failure.t * (glob)
225 test-failure.t * (glob)
226 test-success.t * (glob)
226 test-success.t * (glob)
227 $ rm test-failure-unicode.t
227 $ rm test-failure-unicode.t
228
228
229 test for --retest
229 test for --retest
230 ====================
230 ====================
231
231
232 $ rt --retest
232 $ rt --retest
233
233
234 --- $TESTTMP/test-failure.t
234 --- $TESTTMP/test-failure.t
235 +++ $TESTTMP/test-failure.t.err
235 +++ $TESTTMP/test-failure.t.err
236 @@ -1,5 +1,5 @@
236 @@ -1,5 +1,5 @@
237 $ echo babar
237 $ echo babar
238 - rataxes
238 - rataxes
239 + babar
239 + babar
240 This is a noop statement so that
240 This is a noop statement so that
241 this test is still more bytes than success.
241 this test is still more bytes than success.
242 pad pad pad pad............................................................
242 pad pad pad pad............................................................
243
243
244 ERROR: test-failure.t output changed
244 ERROR: test-failure.t output changed
245 !
245 !
246 Failed test-failure.t: output changed
246 Failed test-failure.t: output changed
247 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
247 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
248 python hash seed: * (glob)
248 python hash seed: * (glob)
249 [1]
249 [1]
250
250
251 Selecting Tests To Run
251 Selecting Tests To Run
252 ======================
252 ======================
253
253
254 successful
254 successful
255
255
256 $ rt test-success.t
256 $ rt test-success.t
257 .
257 .
258 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
258 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
259
259
260 success w/ keyword
260 success w/ keyword
261 $ rt -k xyzzy
261 $ rt -k xyzzy
262 .
262 .
263 # Ran 2 tests, 1 skipped, 0 warned, 0 failed.
263 # Ran 2 tests, 1 skipped, 0 warned, 0 failed.
264
264
265 failed
265 failed
266
266
267 $ rt test-failure.t
267 $ rt test-failure.t
268
268
269 --- $TESTTMP/test-failure.t
269 --- $TESTTMP/test-failure.t
270 +++ $TESTTMP/test-failure.t.err
270 +++ $TESTTMP/test-failure.t.err
271 @@ -1,5 +1,5 @@
271 @@ -1,5 +1,5 @@
272 $ echo babar
272 $ echo babar
273 - rataxes
273 - rataxes
274 + babar
274 + babar
275 This is a noop statement so that
275 This is a noop statement so that
276 this test is still more bytes than success.
276 this test is still more bytes than success.
277 pad pad pad pad............................................................
277 pad pad pad pad............................................................
278
278
279 ERROR: test-failure.t output changed
279 ERROR: test-failure.t output changed
280 !
280 !
281 Failed test-failure.t: output changed
281 Failed test-failure.t: output changed
282 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
282 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
283 python hash seed: * (glob)
283 python hash seed: * (glob)
284 [1]
284 [1]
285
285
286 failure w/ keyword
286 failure w/ keyword
287 $ rt -k rataxes
287 $ rt -k rataxes
288
288
289 --- $TESTTMP/test-failure.t
289 --- $TESTTMP/test-failure.t
290 +++ $TESTTMP/test-failure.t.err
290 +++ $TESTTMP/test-failure.t.err
291 @@ -1,5 +1,5 @@
291 @@ -1,5 +1,5 @@
292 $ echo babar
292 $ echo babar
293 - rataxes
293 - rataxes
294 + babar
294 + babar
295 This is a noop statement so that
295 This is a noop statement so that
296 this test is still more bytes than success.
296 this test is still more bytes than success.
297 pad pad pad pad............................................................
297 pad pad pad pad............................................................
298
298
299 ERROR: test-failure.t output changed
299 ERROR: test-failure.t output changed
300 !
300 !
301 Failed test-failure.t: output changed
301 Failed test-failure.t: output changed
302 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
302 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
303 python hash seed: * (glob)
303 python hash seed: * (glob)
304 [1]
304 [1]
305
305
306 Verify that when a process fails to start we show a useful message
306 Verify that when a process fails to start we show a useful message
307 ==================================================================
307 ==================================================================
308
308
309 $ cat > test-serve-fail.t <<EOF
309 $ cat > test-serve-fail.t <<EOF
310 > $ echo 'abort: child process failed to start blah'
310 > $ echo 'abort: child process failed to start blah'
311 > EOF
311 > EOF
312 $ rt test-serve-fail.t
312 $ rt test-serve-fail.t
313
313
314 ERROR: test-serve-fail.t output changed
314 ERROR: test-serve-fail.t output changed
315 !
315 !
316 Failed test-serve-fail.t: server failed to start (HGPORT=*) (glob)
316 Failed test-serve-fail.t: server failed to start (HGPORT=*) (glob)
317 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
317 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
318 python hash seed: * (glob)
318 python hash seed: * (glob)
319 [1]
319 [1]
320 $ rm test-serve-fail.t
320 $ rm test-serve-fail.t
321
321
322 Verify that we can try other ports
322 Verify that we can try other ports
323 ===================================
323 ===================================
324 $ hg init inuse
324 $ hg init inuse
325 $ hg serve -R inuse -p $HGPORT -d --pid-file=blocks.pid
325 $ hg serve -R inuse -p $HGPORT -d --pid-file=blocks.pid
326 $ cat blocks.pid >> $DAEMON_PIDS
326 $ cat blocks.pid >> $DAEMON_PIDS
327 $ cat > test-serve-inuse.t <<EOF
327 $ cat > test-serve-inuse.t <<EOF
328 > $ hg serve -R `pwd`/inuse -p \$HGPORT -d --pid-file=hg.pid
328 > $ hg serve -R `pwd`/inuse -p \$HGPORT -d --pid-file=hg.pid
329 > $ cat hg.pid >> \$DAEMON_PIDS
329 > $ cat hg.pid >> \$DAEMON_PIDS
330 > EOF
330 > EOF
331 $ rt test-serve-inuse.t
331 $ rt test-serve-inuse.t
332 .
332 .
333 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
333 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
334 $ rm test-serve-inuse.t
334 $ rm test-serve-inuse.t
335 $ killdaemons.py $DAEMON_PIDS
335 $ killdaemons.py $DAEMON_PIDS
336 $ rm $DAEMON_PIDS
336 $ rm $DAEMON_PIDS
337
337
338 Running In Debug Mode
338 Running In Debug Mode
339 ======================
339 ======================
340
340
341 $ rt --debug 2>&1 | grep -v pwd
341 $ rt --debug 2>&1 | grep -v pwd
342 + echo *SALT* 0 0 (glob)
342 + echo *SALT* 0 0 (glob)
343 *SALT* 0 0 (glob)
343 *SALT* 0 0 (glob)
344 + echo babar
344 + echo babar
345 babar
345 babar
346 + echo *SALT* 10 0 (glob)
346 + echo *SALT* 10 0 (glob)
347 *SALT* 10 0 (glob)
347 *SALT* 10 0 (glob)
348 *+ echo *SALT* 0 0 (glob)
348 *+ echo *SALT* 0 0 (glob)
349 *SALT* 0 0 (glob)
349 *SALT* 0 0 (glob)
350 + echo babar
350 + echo babar
351 babar
351 babar
352 + echo *SALT* 2 0 (glob)
352 + echo *SALT* 2 0 (glob)
353 *SALT* 2 0 (glob)
353 *SALT* 2 0 (glob)
354 + echo xyzzy
354 + echo xyzzy
355 xyzzy
355 xyzzy
356 + echo *SALT* 9 0 (glob)
356 + echo *SALT* 9 0 (glob)
357 *SALT* 9 0 (glob)
357 *SALT* 9 0 (glob)
358 + printf *abc\ndef\nxyz\n* (glob)
358 + printf *abc\ndef\nxyz\n* (glob)
359 abc
359 abc
360 def
360 def
361 xyz
361 xyz
362 + echo *SALT* 15 0 (glob)
362 + echo *SALT* 15 0 (glob)
363 *SALT* 15 0 (glob)
363 *SALT* 15 0 (glob)
364 + printf *zyx\nwvu\ntsr\n* (glob)
364 + printf *zyx\nwvu\ntsr\n* (glob)
365 zyx
365 zyx
366 wvu
366 wvu
367 tsr
367 tsr
368 + echo *SALT* 22 0 (glob)
368 + echo *SALT* 22 0 (glob)
369 *SALT* 22 0 (glob)
369 *SALT* 22 0 (glob)
370 .
370 .
371 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
371 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
372
372
373 Parallel runs
373 Parallel runs
374 ==============
374 ==============
375
375
376 (duplicate the failing test to get predictable output)
376 (duplicate the failing test to get predictable output)
377 $ cp test-failure.t test-failure-copy.t
377 $ cp test-failure.t test-failure-copy.t
378
378
379 $ rt --jobs 2 test-failure*.t -n
379 $ rt --jobs 2 test-failure*.t -n
380 !!
380 !!
381 Failed test-failure*.t: output changed (glob)
381 Failed test-failure*.t: output changed (glob)
382 Failed test-failure*.t: output changed (glob)
382 Failed test-failure*.t: output changed (glob)
383 # Ran 2 tests, 0 skipped, 0 warned, 2 failed.
383 # Ran 2 tests, 0 skipped, 0 warned, 2 failed.
384 python hash seed: * (glob)
384 python hash seed: * (glob)
385 [1]
385 [1]
386
386
387 failures in parallel with --first should only print one failure
387 failures in parallel with --first should only print one failure
388 >>> f = open('test-nothing.t', 'w')
388 >>> f = open('test-nothing.t', 'w')
389 >>> f.write('foo\n' * 1024) and None
389 >>> f.write('foo\n' * 1024) and None
390 >>> f.write(' $ sleep 1') and None
390 >>> f.write(' $ sleep 1') and None
391 $ rt --jobs 2 --first
391 $ rt --jobs 2 --first
392
392
393 --- $TESTTMP/test-failure*.t (glob)
393 --- $TESTTMP/test-failure*.t (glob)
394 +++ $TESTTMP/test-failure*.t.err (glob)
394 +++ $TESTTMP/test-failure*.t.err (glob)
395 @@ -1,5 +1,5 @@
395 @@ -1,5 +1,5 @@
396 $ echo babar
396 $ echo babar
397 - rataxes
397 - rataxes
398 + babar
398 + babar
399 This is a noop statement so that
399 This is a noop statement so that
400 this test is still more bytes than success.
400 this test is still more bytes than success.
401 pad pad pad pad............................................................
401 pad pad pad pad............................................................
402
402
403 Failed test-failure*.t: output changed (glob)
403 Failed test-failure*.t: output changed (glob)
404 Failed test-nothing.t: output changed
404 Failed test-nothing.t: output changed
405 # Ran 2 tests, 0 skipped, 0 warned, 2 failed.
405 # Ran 2 tests, 0 skipped, 0 warned, 2 failed.
406 python hash seed: * (glob)
406 python hash seed: * (glob)
407 [1]
407 [1]
408
408
409
409
410 (delete the duplicated test file)
410 (delete the duplicated test file)
411 $ rm test-failure-copy.t test-nothing.t
411 $ rm test-failure-copy.t test-nothing.t
412
412
413
413
414 Interactive run
414 Interactive run
415 ===============
415 ===============
416
416
417 (backup the failing test)
417 (backup the failing test)
418 $ cp test-failure.t backup
418 $ cp test-failure.t backup
419
419
420 Refuse the fix
420 Refuse the fix
421
421
422 $ echo 'n' | rt -i
422 $ echo 'n' | rt -i
423
423
424 --- $TESTTMP/test-failure.t
424 --- $TESTTMP/test-failure.t
425 +++ $TESTTMP/test-failure.t.err
425 +++ $TESTTMP/test-failure.t.err
426 @@ -1,5 +1,5 @@
426 @@ -1,5 +1,5 @@
427 $ echo babar
427 $ echo babar
428 - rataxes
428 - rataxes
429 + babar
429 + babar
430 This is a noop statement so that
430 This is a noop statement so that
431 this test is still more bytes than success.
431 this test is still more bytes than success.
432 pad pad pad pad............................................................
432 pad pad pad pad............................................................
433 Accept this change? [n]
433 Accept this change? [n]
434 ERROR: test-failure.t output changed
434 ERROR: test-failure.t output changed
435 !.
435 !.
436 Failed test-failure.t: output changed
436 Failed test-failure.t: output changed
437 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
437 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
438 python hash seed: * (glob)
438 python hash seed: * (glob)
439 [1]
439 [1]
440
440
441 $ cat test-failure.t
441 $ cat test-failure.t
442 $ echo babar
442 $ echo babar
443 rataxes
443 rataxes
444 This is a noop statement so that
444 This is a noop statement so that
445 this test is still more bytes than success.
445 this test is still more bytes than success.
446 pad pad pad pad............................................................
446 pad pad pad pad............................................................
447 pad pad pad pad............................................................
447 pad pad pad pad............................................................
448 pad pad pad pad............................................................
448 pad pad pad pad............................................................
449 pad pad pad pad............................................................
449 pad pad pad pad............................................................
450 pad pad pad pad............................................................
450 pad pad pad pad............................................................
451 pad pad pad pad............................................................
451 pad pad pad pad............................................................
452
452
453 Interactive with custom view
453 Interactive with custom view
454
454
455 $ echo 'n' | rt -i --view echo
455 $ echo 'n' | rt -i --view echo
456 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
456 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
457 Accept this change? [n]* (glob)
457 Accept this change? [n]* (glob)
458 ERROR: test-failure.t output changed
458 ERROR: test-failure.t output changed
459 !.
459 !.
460 Failed test-failure.t: output changed
460 Failed test-failure.t: output changed
461 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
461 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
462 python hash seed: * (glob)
462 python hash seed: * (glob)
463 [1]
463 [1]
464
464
465 View the fix
465 View the fix
466
466
467 $ echo 'y' | rt --view echo
467 $ echo 'y' | rt --view echo
468 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
468 $TESTTMP/test-failure.t $TESTTMP/test-failure.t.err (glob)
469
469
470 ERROR: test-failure.t output changed
470 ERROR: test-failure.t output changed
471 !.
471 !.
472 Failed test-failure.t: output changed
472 Failed test-failure.t: output changed
473 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
473 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
474 python hash seed: * (glob)
474 python hash seed: * (glob)
475 [1]
475 [1]
476
476
477 Accept the fix
477 Accept the fix
478
478
479 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
479 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
480 $ echo " saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t
480 $ echo " saved backup bundle to \$TESTTMP/foo.hg" >> test-failure.t
481 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
481 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
482 $ echo " saved backup bundle to \$TESTTMP/foo.hg (glob)" >> test-failure.t
482 $ echo " saved backup bundle to \$TESTTMP/foo.hg (glob)" >> test-failure.t
483 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
483 $ echo " $ echo 'saved backup bundle to \$TESTTMP/foo.hg'" >> test-failure.t
484 $ echo " saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t
484 $ echo " saved backup bundle to \$TESTTMP/*.hg (glob)" >> test-failure.t
485 $ echo 'y' | rt -i 2>&1
485 $ echo 'y' | rt -i 2>&1
486
486
487 --- $TESTTMP/test-failure.t
487 --- $TESTTMP/test-failure.t
488 +++ $TESTTMP/test-failure.t.err
488 +++ $TESTTMP/test-failure.t.err
489 @@ -1,5 +1,5 @@
489 @@ -1,5 +1,5 @@
490 $ echo babar
490 $ echo babar
491 - rataxes
491 - rataxes
492 + babar
492 + babar
493 This is a noop statement so that
493 This is a noop statement so that
494 this test is still more bytes than success.
494 this test is still more bytes than success.
495 pad pad pad pad............................................................
495 pad pad pad pad............................................................
496 @@ -9,7 +9,7 @@
496 @@ -9,7 +9,7 @@
497 pad pad pad pad............................................................
497 pad pad pad pad............................................................
498 pad pad pad pad............................................................
498 pad pad pad pad............................................................
499 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
499 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
500 - saved backup bundle to $TESTTMP/foo.hg
500 - saved backup bundle to $TESTTMP/foo.hg
501 + saved backup bundle to $TESTTMP/foo.hg* (glob)
501 + saved backup bundle to $TESTTMP/foo.hg* (glob)
502 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
502 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
503 saved backup bundle to $TESTTMP/foo.hg* (glob)
503 saved backup bundle to $TESTTMP/foo.hg* (glob)
504 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
504 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
505 Accept this change? [n] ..
505 Accept this change? [n] ..
506 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
506 # Ran 2 tests, 0 skipped, 0 warned, 0 failed.
507
507
508 $ sed -e 's,(glob)$,&<,g' test-failure.t
508 $ sed -e 's,(glob)$,&<,g' test-failure.t
509 $ echo babar
509 $ echo babar
510 babar
510 babar
511 This is a noop statement so that
511 This is a noop statement so that
512 this test is still more bytes than success.
512 this test is still more bytes than success.
513 pad pad pad pad............................................................
513 pad pad pad pad............................................................
514 pad pad pad pad............................................................
514 pad pad pad pad............................................................
515 pad pad pad pad............................................................
515 pad pad pad pad............................................................
516 pad pad pad pad............................................................
516 pad pad pad pad............................................................
517 pad pad pad pad............................................................
517 pad pad pad pad............................................................
518 pad pad pad pad............................................................
518 pad pad pad pad............................................................
519 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
519 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
520 saved backup bundle to $TESTTMP/foo.hg (glob)<
520 saved backup bundle to $TESTTMP/foo.hg (glob)<
521 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
521 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
522 saved backup bundle to $TESTTMP/foo.hg (glob)<
522 saved backup bundle to $TESTTMP/foo.hg (glob)<
523 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
523 $ echo 'saved backup bundle to $TESTTMP/foo.hg'
524 saved backup bundle to $TESTTMP/*.hg (glob)<
524 saved backup bundle to $TESTTMP/*.hg (glob)<
525
525
526 (reinstall)
526 (reinstall)
527 $ mv backup test-failure.t
527 $ mv backup test-failure.t
528
528
529 No Diff
529 No Diff
530 ===============
530 ===============
531
531
532 $ rt --nodiff
532 $ rt --nodiff
533 !.
533 !.
534 Failed test-failure.t: output changed
534 Failed test-failure.t: output changed
535 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
535 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
536 python hash seed: * (glob)
536 python hash seed: * (glob)
537 [1]
537 [1]
538
538
539 test --tmpdir support
539 test --tmpdir support
540 $ rt --tmpdir=$TESTTMP/keep test-success.t
540 $ rt --tmpdir=$TESTTMP/keep test-success.t
541
541
542 Keeping testtmp dir: $TESTTMP/keep/child1/test-success.t (glob)
542 Keeping testtmp dir: $TESTTMP/keep/child1/test-success.t (glob)
543 Keeping threadtmp dir: $TESTTMP/keep/child1 (glob)
543 Keeping threadtmp dir: $TESTTMP/keep/child1 (glob)
544 .
544 .
545 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
545 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
546
546
547 timeouts
547 timeouts
548 ========
548 ========
549 $ cat > test-timeout.t <<EOF
549 $ cat > test-timeout.t <<EOF
550 > $ sleep 2
550 > $ sleep 2
551 > $ echo pass
551 > $ echo pass
552 > pass
552 > pass
553 > EOF
553 > EOF
554 > echo '#require slow' > test-slow-timeout.t
554 > echo '#require slow' > test-slow-timeout.t
555 > cat test-timeout.t >> test-slow-timeout.t
555 > cat test-timeout.t >> test-slow-timeout.t
556 $ rt --timeout=1 --slowtimeout=3 test-timeout.t test-slow-timeout.t
556 $ rt --timeout=1 --slowtimeout=3 test-timeout.t test-slow-timeout.t
557 st
557 st
558 Skipped test-slow-timeout.t: missing feature: allow slow tests
558 Skipped test-slow-timeout.t: missing feature: allow slow tests (use --allow-slow-tests)
559 Failed test-timeout.t: timed out
559 Failed test-timeout.t: timed out
560 # Ran 1 tests, 1 skipped, 0 warned, 1 failed.
560 # Ran 1 tests, 1 skipped, 0 warned, 1 failed.
561 python hash seed: * (glob)
561 python hash seed: * (glob)
562 [1]
562 [1]
563 $ rt --timeout=1 --slowtimeout=3 \
563 $ rt --timeout=1 --slowtimeout=3 \
564 > test-timeout.t test-slow-timeout.t --allow-slow-tests
564 > test-timeout.t test-slow-timeout.t --allow-slow-tests
565 .t
565 .t
566 Failed test-timeout.t: timed out
566 Failed test-timeout.t: timed out
567 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
567 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
568 python hash seed: * (glob)
568 python hash seed: * (glob)
569 [1]
569 [1]
570 $ rm test-timeout.t test-slow-timeout.t
570 $ rm test-timeout.t test-slow-timeout.t
571
571
572 test for --time
572 test for --time
573 ==================
573 ==================
574
574
575 $ rt test-success.t --time
575 $ rt test-success.t --time
576 .
576 .
577 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
577 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
578 # Producing time report
578 # Producing time report
579 start end cuser csys real Test
579 start end cuser csys real Test
580 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
580 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
581
581
582 test for --time with --job enabled
582 test for --time with --job enabled
583 ====================================
583 ====================================
584
584
585 $ rt test-success.t --time --jobs 2
585 $ rt test-success.t --time --jobs 2
586 .
586 .
587 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
587 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
588 # Producing time report
588 # Producing time report
589 start end cuser csys real Test
589 start end cuser csys real Test
590 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
590 \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} \s*[\d\.]{5} test-success.t (re)
591
591
592 Skips
592 Skips
593 ================
593 ================
594 $ cat > test-skip.t <<EOF
594 $ cat > test-skip.t <<EOF
595 > $ echo xyzzy
595 > $ echo xyzzy
596 > #require false
596 > #require false
597 > EOF
597 > EOF
598 $ rt --nodiff
598 $ rt --nodiff
599 !.s
599 !.s
600 Skipped test-skip.t: missing feature: nail clipper
600 Skipped test-skip.t: missing feature: nail clipper
601 Failed test-failure.t: output changed
601 Failed test-failure.t: output changed
602 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
602 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
603 python hash seed: * (glob)
603 python hash seed: * (glob)
604 [1]
604 [1]
605
605
606 $ rt --keyword xyzzy
606 $ rt --keyword xyzzy
607 .s
607 .s
608 Skipped test-skip.t: missing feature: nail clipper
608 Skipped test-skip.t: missing feature: nail clipper
609 # Ran 2 tests, 2 skipped, 0 warned, 0 failed.
609 # Ran 2 tests, 2 skipped, 0 warned, 0 failed.
610
610
611 Skips with xml
611 Skips with xml
612 $ rt --keyword xyzzy \
612 $ rt --keyword xyzzy \
613 > --xunit=xunit.xml
613 > --xunit=xunit.xml
614 .s
614 .s
615 Skipped test-skip.t: missing feature: nail clipper
615 Skipped test-skip.t: missing feature: nail clipper
616 # Ran 2 tests, 2 skipped, 0 warned, 0 failed.
616 # Ran 2 tests, 2 skipped, 0 warned, 0 failed.
617 $ cat xunit.xml
617 $ cat xunit.xml
618 <?xml version="1.0" encoding="utf-8"?>
618 <?xml version="1.0" encoding="utf-8"?>
619 <testsuite errors="0" failures="0" name="run-tests" skipped="2" tests="2">
619 <testsuite errors="0" failures="0" name="run-tests" skipped="2" tests="2">
620 <testcase name="test-success.t" time="*"/> (glob)
620 <testcase name="test-success.t" time="*"/> (glob)
621 </testsuite>
621 </testsuite>
622
622
623 Missing skips or blacklisted skips don't count as executed:
623 Missing skips or blacklisted skips don't count as executed:
624 $ echo test-failure.t > blacklist
624 $ echo test-failure.t > blacklist
625 $ rt --blacklist=blacklist --json\
625 $ rt --blacklist=blacklist --json\
626 > test-failure.t test-bogus.t
626 > test-failure.t test-bogus.t
627 ss
627 ss
628 Skipped test-bogus.t: Doesn't exist
628 Skipped test-bogus.t: Doesn't exist
629 Skipped test-failure.t: blacklisted
629 Skipped test-failure.t: blacklisted
630 # Ran 0 tests, 2 skipped, 0 warned, 0 failed.
630 # Ran 0 tests, 2 skipped, 0 warned, 0 failed.
631 $ cat report.json
631 $ cat report.json
632 testreport ={
632 testreport ={
633 "test-bogus.t": {
633 "test-bogus.t": {
634 "result": "skip"
634 "result": "skip"
635 },
635 },
636 "test-failure.t": {
636 "test-failure.t": {
637 "result": "skip"
637 "result": "skip"
638 }
638 }
639 } (no-eol)
639 } (no-eol)
640
640
641 Whitelist trumps blacklist
641 Whitelist trumps blacklist
642 $ echo test-failure.t > whitelist
642 $ echo test-failure.t > whitelist
643 $ rt --blacklist=blacklist --whitelist=whitelist --json\
643 $ rt --blacklist=blacklist --whitelist=whitelist --json\
644 > test-failure.t test-bogus.t
644 > test-failure.t test-bogus.t
645 s
645 s
646 --- $TESTTMP/test-failure.t
646 --- $TESTTMP/test-failure.t
647 +++ $TESTTMP/test-failure.t.err
647 +++ $TESTTMP/test-failure.t.err
648 @@ -1,5 +1,5 @@
648 @@ -1,5 +1,5 @@
649 $ echo babar
649 $ echo babar
650 - rataxes
650 - rataxes
651 + babar
651 + babar
652 This is a noop statement so that
652 This is a noop statement so that
653 this test is still more bytes than success.
653 this test is still more bytes than success.
654 pad pad pad pad............................................................
654 pad pad pad pad............................................................
655
655
656 ERROR: test-failure.t output changed
656 ERROR: test-failure.t output changed
657 !
657 !
658 Skipped test-bogus.t: Doesn't exist
658 Skipped test-bogus.t: Doesn't exist
659 Failed test-failure.t: output changed
659 Failed test-failure.t: output changed
660 # Ran 1 tests, 1 skipped, 0 warned, 1 failed.
660 # Ran 1 tests, 1 skipped, 0 warned, 1 failed.
661 python hash seed: * (glob)
661 python hash seed: * (glob)
662 [1]
662 [1]
663
663
664 test for --json
664 test for --json
665 ==================
665 ==================
666
666
667 $ rt --json
667 $ rt --json
668
668
669 --- $TESTTMP/test-failure.t
669 --- $TESTTMP/test-failure.t
670 +++ $TESTTMP/test-failure.t.err
670 +++ $TESTTMP/test-failure.t.err
671 @@ -1,5 +1,5 @@
671 @@ -1,5 +1,5 @@
672 $ echo babar
672 $ echo babar
673 - rataxes
673 - rataxes
674 + babar
674 + babar
675 This is a noop statement so that
675 This is a noop statement so that
676 this test is still more bytes than success.
676 this test is still more bytes than success.
677 pad pad pad pad............................................................
677 pad pad pad pad............................................................
678
678
679 ERROR: test-failure.t output changed
679 ERROR: test-failure.t output changed
680 !.s
680 !.s
681 Skipped test-skip.t: missing feature: nail clipper
681 Skipped test-skip.t: missing feature: nail clipper
682 Failed test-failure.t: output changed
682 Failed test-failure.t: output changed
683 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
683 # Ran 2 tests, 1 skipped, 0 warned, 1 failed.
684 python hash seed: * (glob)
684 python hash seed: * (glob)
685 [1]
685 [1]
686
686
687 $ cat report.json
687 $ cat report.json
688 testreport ={
688 testreport ={
689 "test-failure.t": [\{] (re)
689 "test-failure.t": [\{] (re)
690 "csys": "\s*[\d\.]{4,5}", ? (re)
690 "csys": "\s*[\d\.]{4,5}", ? (re)
691 "cuser": "\s*[\d\.]{4,5}", ? (re)
691 "cuser": "\s*[\d\.]{4,5}", ? (re)
692 "diff": "---.+\+\+\+.+", ? (re)
692 "diff": "---.+\+\+\+.+", ? (re)
693 "end": "\s*[\d\.]{4,5}", ? (re)
693 "end": "\s*[\d\.]{4,5}", ? (re)
694 "result": "failure", ? (re)
694 "result": "failure", ? (re)
695 "start": "\s*[\d\.]{4,5}", ? (re)
695 "start": "\s*[\d\.]{4,5}", ? (re)
696 "time": "\s*[\d\.]{4,5}" (re)
696 "time": "\s*[\d\.]{4,5}" (re)
697 }, ? (re)
697 }, ? (re)
698 "test-skip.t": {
698 "test-skip.t": {
699 "csys": "\s*[\d\.]{4,5}", ? (re)
699 "csys": "\s*[\d\.]{4,5}", ? (re)
700 "cuser": "\s*[\d\.]{4,5}", ? (re)
700 "cuser": "\s*[\d\.]{4,5}", ? (re)
701 "diff": "", ? (re)
701 "diff": "", ? (re)
702 "end": "\s*[\d\.]{4,5}", ? (re)
702 "end": "\s*[\d\.]{4,5}", ? (re)
703 "result": "skip", ? (re)
703 "result": "skip", ? (re)
704 "start": "\s*[\d\.]{4,5}", ? (re)
704 "start": "\s*[\d\.]{4,5}", ? (re)
705 "time": "\s*[\d\.]{4,5}" (re)
705 "time": "\s*[\d\.]{4,5}" (re)
706 }, ? (re)
706 }, ? (re)
707 "test-success.t": [\{] (re)
707 "test-success.t": [\{] (re)
708 "csys": "\s*[\d\.]{4,5}", ? (re)
708 "csys": "\s*[\d\.]{4,5}", ? (re)
709 "cuser": "\s*[\d\.]{4,5}", ? (re)
709 "cuser": "\s*[\d\.]{4,5}", ? (re)
710 "diff": "", ? (re)
710 "diff": "", ? (re)
711 "end": "\s*[\d\.]{4,5}", ? (re)
711 "end": "\s*[\d\.]{4,5}", ? (re)
712 "result": "success", ? (re)
712 "result": "success", ? (re)
713 "start": "\s*[\d\.]{4,5}", ? (re)
713 "start": "\s*[\d\.]{4,5}", ? (re)
714 "time": "\s*[\d\.]{4,5}" (re)
714 "time": "\s*[\d\.]{4,5}" (re)
715 }
715 }
716 } (no-eol)
716 } (no-eol)
717
717
718 Test that failed test accepted through interactive are properly reported:
718 Test that failed test accepted through interactive are properly reported:
719
719
720 $ cp test-failure.t backup
720 $ cp test-failure.t backup
721 $ echo y | rt --json -i
721 $ echo y | rt --json -i
722
722
723 --- $TESTTMP/test-failure.t
723 --- $TESTTMP/test-failure.t
724 +++ $TESTTMP/test-failure.t.err
724 +++ $TESTTMP/test-failure.t.err
725 @@ -1,5 +1,5 @@
725 @@ -1,5 +1,5 @@
726 $ echo babar
726 $ echo babar
727 - rataxes
727 - rataxes
728 + babar
728 + babar
729 This is a noop statement so that
729 This is a noop statement so that
730 this test is still more bytes than success.
730 this test is still more bytes than success.
731 pad pad pad pad............................................................
731 pad pad pad pad............................................................
732 Accept this change? [n] ..s
732 Accept this change? [n] ..s
733 Skipped test-skip.t: missing feature: nail clipper
733 Skipped test-skip.t: missing feature: nail clipper
734 # Ran 2 tests, 1 skipped, 0 warned, 0 failed.
734 # Ran 2 tests, 1 skipped, 0 warned, 0 failed.
735
735
736 $ cat report.json
736 $ cat report.json
737 testreport ={
737 testreport ={
738 "test-failure.t": [\{] (re)
738 "test-failure.t": [\{] (re)
739 "csys": "\s*[\d\.]{4,5}", ? (re)
739 "csys": "\s*[\d\.]{4,5}", ? (re)
740 "cuser": "\s*[\d\.]{4,5}", ? (re)
740 "cuser": "\s*[\d\.]{4,5}", ? (re)
741 "diff": "", ? (re)
741 "diff": "", ? (re)
742 "end": "\s*[\d\.]{4,5}", ? (re)
742 "end": "\s*[\d\.]{4,5}", ? (re)
743 "result": "success", ? (re)
743 "result": "success", ? (re)
744 "start": "\s*[\d\.]{4,5}", ? (re)
744 "start": "\s*[\d\.]{4,5}", ? (re)
745 "time": "\s*[\d\.]{4,5}" (re)
745 "time": "\s*[\d\.]{4,5}" (re)
746 }, ? (re)
746 }, ? (re)
747 "test-skip.t": {
747 "test-skip.t": {
748 "csys": "\s*[\d\.]{4,5}", ? (re)
748 "csys": "\s*[\d\.]{4,5}", ? (re)
749 "cuser": "\s*[\d\.]{4,5}", ? (re)
749 "cuser": "\s*[\d\.]{4,5}", ? (re)
750 "diff": "", ? (re)
750 "diff": "", ? (re)
751 "end": "\s*[\d\.]{4,5}", ? (re)
751 "end": "\s*[\d\.]{4,5}", ? (re)
752 "result": "skip", ? (re)
752 "result": "skip", ? (re)
753 "start": "\s*[\d\.]{4,5}", ? (re)
753 "start": "\s*[\d\.]{4,5}", ? (re)
754 "time": "\s*[\d\.]{4,5}" (re)
754 "time": "\s*[\d\.]{4,5}" (re)
755 }, ? (re)
755 }, ? (re)
756 "test-success.t": [\{] (re)
756 "test-success.t": [\{] (re)
757 "csys": "\s*[\d\.]{4,5}", ? (re)
757 "csys": "\s*[\d\.]{4,5}", ? (re)
758 "cuser": "\s*[\d\.]{4,5}", ? (re)
758 "cuser": "\s*[\d\.]{4,5}", ? (re)
759 "diff": "", ? (re)
759 "diff": "", ? (re)
760 "end": "\s*[\d\.]{4,5}", ? (re)
760 "end": "\s*[\d\.]{4,5}", ? (re)
761 "result": "success", ? (re)
761 "result": "success", ? (re)
762 "start": "\s*[\d\.]{4,5}", ? (re)
762 "start": "\s*[\d\.]{4,5}", ? (re)
763 "time": "\s*[\d\.]{4,5}" (re)
763 "time": "\s*[\d\.]{4,5}" (re)
764 }
764 }
765 } (no-eol)
765 } (no-eol)
766 $ mv backup test-failure.t
766 $ mv backup test-failure.t
767
767
768 backslash on end of line with glob matching is handled properly
768 backslash on end of line with glob matching is handled properly
769
769
770 $ cat > test-glob-backslash.t << EOF
770 $ cat > test-glob-backslash.t << EOF
771 > $ echo 'foo bar \\'
771 > $ echo 'foo bar \\'
772 > foo * \ (glob)
772 > foo * \ (glob)
773 > EOF
773 > EOF
774
774
775 $ rt test-glob-backslash.t
775 $ rt test-glob-backslash.t
776 .
776 .
777 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
777 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
778
778
779 $ rm -f test-glob-backslash.t
779 $ rm -f test-glob-backslash.t
780
780
781 Test globbing of local IP addresses
781 Test globbing of local IP addresses
782 $ echo 172.16.18.1
782 $ echo 172.16.18.1
783 $LOCALIP (glob)
783 $LOCALIP (glob)
784 $ echo dead:beef::1
784 $ echo dead:beef::1
785 $LOCALIP (glob)
785 $LOCALIP (glob)
786
786
787 Test reusability for third party tools
787 Test reusability for third party tools
788 ======================================
788 ======================================
789
789
790 $ mkdir "$TESTTMP"/anothertests
790 $ mkdir "$TESTTMP"/anothertests
791 $ cd "$TESTTMP"/anothertests
791 $ cd "$TESTTMP"/anothertests
792
792
793 test that `run-tests.py` can execute hghave, even if it runs not in
793 test that `run-tests.py` can execute hghave, even if it runs not in
794 Mercurial source tree.
794 Mercurial source tree.
795
795
796 $ cat > test-hghave.t <<EOF
796 $ cat > test-hghave.t <<EOF
797 > #require true
797 > #require true
798 > $ echo foo
798 > $ echo foo
799 > foo
799 > foo
800 > EOF
800 > EOF
801 $ rt test-hghave.t
801 $ rt test-hghave.t
802 .
802 .
803 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
803 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
804
804
805 test that RUNTESTDIR refers the directory, in which `run-tests.py` now
805 test that RUNTESTDIR refers the directory, in which `run-tests.py` now
806 running is placed.
806 running is placed.
807
807
808 $ cat > test-runtestdir.t <<EOF
808 $ cat > test-runtestdir.t <<EOF
809 > - $TESTDIR, in which test-run-tests.t is placed
809 > - $TESTDIR, in which test-run-tests.t is placed
810 > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime)
810 > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime)
811 > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime)
811 > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime)
812 >
812 >
813 > #if windows
813 > #if windows
814 > $ test "\$TESTDIR" = "$TESTTMP\anothertests"
814 > $ test "\$TESTDIR" = "$TESTTMP\anothertests"
815 > #else
815 > #else
816 > $ test "\$TESTDIR" = "$TESTTMP"/anothertests
816 > $ test "\$TESTDIR" = "$TESTTMP"/anothertests
817 > #endif
817 > #endif
818 > $ test "\$RUNTESTDIR" = "$TESTDIR"
818 > $ test "\$RUNTESTDIR" = "$TESTDIR"
819 > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py
819 > $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py
820 > #!/usr/bin/env python
820 > #!/usr/bin/env python
821 > #
821 > #
822 > # check-code - a style and portability checker for Mercurial
822 > # check-code - a style and portability checker for Mercurial
823 > EOF
823 > EOF
824 $ rt test-runtestdir.t
824 $ rt test-runtestdir.t
825 .
825 .
826 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
826 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
827
827
828 #if execbit
828 #if execbit
829
829
830 test that TESTDIR is referred in PATH
830 test that TESTDIR is referred in PATH
831
831
832 $ cat > custom-command.sh <<EOF
832 $ cat > custom-command.sh <<EOF
833 > #!/bin/sh
833 > #!/bin/sh
834 > echo "hello world"
834 > echo "hello world"
835 > EOF
835 > EOF
836 $ chmod +x custom-command.sh
836 $ chmod +x custom-command.sh
837 $ cat > test-testdir-path.t <<EOF
837 $ cat > test-testdir-path.t <<EOF
838 > $ custom-command.sh
838 > $ custom-command.sh
839 > hello world
839 > hello world
840 > EOF
840 > EOF
841 $ rt test-testdir-path.t
841 $ rt test-testdir-path.t
842 .
842 .
843 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
843 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
844
844
845 #endif
845 #endif
846
846
847 test support for --allow-slow-tests
847 test support for --allow-slow-tests
848 $ cat > test-very-slow-test.t <<EOF
848 $ cat > test-very-slow-test.t <<EOF
849 > #require slow
849 > #require slow
850 > $ echo pass
850 > $ echo pass
851 > pass
851 > pass
852 > EOF
852 > EOF
853 $ rt test-very-slow-test.t
853 $ rt test-very-slow-test.t
854 s
854 s
855 Skipped test-very-slow-test.t: missing feature: allow slow tests
855 Skipped test-very-slow-test.t: missing feature: allow slow tests (use --allow-slow-tests)
856 # Ran 0 tests, 1 skipped, 0 warned, 0 failed.
856 # Ran 0 tests, 1 skipped, 0 warned, 0 failed.
857 $ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t
857 $ rt $HGTEST_RUN_TESTS_PURE --allow-slow-tests test-very-slow-test.t
858 .
858 .
859 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
859 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
860
860
861 support for running a test outside the current directory
861 support for running a test outside the current directory
862 $ mkdir nonlocal
862 $ mkdir nonlocal
863 $ cat > nonlocal/test-is-not-here.t << EOF
863 $ cat > nonlocal/test-is-not-here.t << EOF
864 > $ echo pass
864 > $ echo pass
865 > pass
865 > pass
866 > EOF
866 > EOF
867 $ rt nonlocal/test-is-not-here.t
867 $ rt nonlocal/test-is-not-here.t
868 .
868 .
869 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
869 # Ran 1 tests, 0 skipped, 0 warned, 0 failed.
870
870
871 support for bisecting failed tests automatically
871 support for bisecting failed tests automatically
872 $ hg init bisect
872 $ hg init bisect
873 $ cd bisect
873 $ cd bisect
874 $ cat >> test-bisect.t <<EOF
874 $ cat >> test-bisect.t <<EOF
875 > $ echo pass
875 > $ echo pass
876 > pass
876 > pass
877 > EOF
877 > EOF
878 $ hg add test-bisect.t
878 $ hg add test-bisect.t
879 $ hg ci -m 'good'
879 $ hg ci -m 'good'
880 $ cat >> test-bisect.t <<EOF
880 $ cat >> test-bisect.t <<EOF
881 > $ echo pass
881 > $ echo pass
882 > fail
882 > fail
883 > EOF
883 > EOF
884 $ hg ci -m 'bad'
884 $ hg ci -m 'bad'
885 $ rt --known-good-rev=0 test-bisect.t
885 $ rt --known-good-rev=0 test-bisect.t
886
886
887 --- $TESTTMP/anothertests/bisect/test-bisect.t
887 --- $TESTTMP/anothertests/bisect/test-bisect.t
888 +++ $TESTTMP/anothertests/bisect/test-bisect.t.err
888 +++ $TESTTMP/anothertests/bisect/test-bisect.t.err
889 @@ -1,4 +1,4 @@
889 @@ -1,4 +1,4 @@
890 $ echo pass
890 $ echo pass
891 pass
891 pass
892 $ echo pass
892 $ echo pass
893 - fail
893 - fail
894 + pass
894 + pass
895
895
896 ERROR: test-bisect.t output changed
896 ERROR: test-bisect.t output changed
897 !
897 !
898 Failed test-bisect.t: output changed
898 Failed test-bisect.t: output changed
899 test-bisect.t broken by 72cbf122d116 (bad)
899 test-bisect.t broken by 72cbf122d116 (bad)
900 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
900 # Ran 1 tests, 0 skipped, 0 warned, 1 failed.
901 python hash seed: * (glob)
901 python hash seed: * (glob)
902 [1]
902 [1]
903
903
904 $ cd ..
904 $ cd ..
905
905
906 Test cases in .t files
906 Test cases in .t files
907 ======================
907 ======================
908 $ mkdir cases
908 $ mkdir cases
909 $ cd cases
909 $ cd cases
910 $ cat > test-cases-abc.t <<'EOF'
910 $ cat > test-cases-abc.t <<'EOF'
911 > #testcases A B C
911 > #testcases A B C
912 > $ V=B
912 > $ V=B
913 > #if A
913 > #if A
914 > $ V=A
914 > $ V=A
915 > #endif
915 > #endif
916 > #if C
916 > #if C
917 > $ V=C
917 > $ V=C
918 > #endif
918 > #endif
919 > $ echo $V | sed 's/A/C/'
919 > $ echo $V | sed 's/A/C/'
920 > C
920 > C
921 > #if C
921 > #if C
922 > $ [ $V = C ]
922 > $ [ $V = C ]
923 > #endif
923 > #endif
924 > #if A
924 > #if A
925 > $ [ $V = C ]
925 > $ [ $V = C ]
926 > [1]
926 > [1]
927 > #endif
927 > #endif
928 > #if no-C
928 > #if no-C
929 > $ [ $V = C ]
929 > $ [ $V = C ]
930 > [1]
930 > [1]
931 > #endif
931 > #endif
932 > $ [ $V = D ]
932 > $ [ $V = D ]
933 > [1]
933 > [1]
934 > EOF
934 > EOF
935 $ rt
935 $ rt
936 .
936 .
937 --- $TESTTMP/anothertests/cases/test-cases-abc.t
937 --- $TESTTMP/anothertests/cases/test-cases-abc.t
938 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
938 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
939 @@ -7,7 +7,7 @@
939 @@ -7,7 +7,7 @@
940 $ V=C
940 $ V=C
941 #endif
941 #endif
942 $ echo $V | sed 's/A/C/'
942 $ echo $V | sed 's/A/C/'
943 - C
943 - C
944 + B
944 + B
945 #if C
945 #if C
946 $ [ $V = C ]
946 $ [ $V = C ]
947 #endif
947 #endif
948
948
949 ERROR: test-cases-abc.t (case B) output changed
949 ERROR: test-cases-abc.t (case B) output changed
950 !.
950 !.
951 Failed test-cases-abc.t (case B): output changed
951 Failed test-cases-abc.t (case B): output changed
952 # Ran 3 tests, 0 skipped, 0 warned, 1 failed.
952 # Ran 3 tests, 0 skipped, 0 warned, 1 failed.
953 python hash seed: * (glob)
953 python hash seed: * (glob)
954 [1]
954 [1]
955
955
956 --restart works
956 --restart works
957
957
958 $ rt --restart
958 $ rt --restart
959
959
960 --- $TESTTMP/anothertests/cases/test-cases-abc.t
960 --- $TESTTMP/anothertests/cases/test-cases-abc.t
961 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
961 +++ $TESTTMP/anothertests/cases/test-cases-abc.t.B.err
962 @@ -7,7 +7,7 @@
962 @@ -7,7 +7,7 @@
963 $ V=C
963 $ V=C
964 #endif
964 #endif
965 $ echo $V | sed 's/A/C/'
965 $ echo $V | sed 's/A/C/'
966 - C
966 - C
967 + B
967 + B
968 #if C
968 #if C
969 $ [ $V = C ]
969 $ [ $V = C ]
970 #endif
970 #endif
971
971
972 ERROR: test-cases-abc.t (case B) output changed
972 ERROR: test-cases-abc.t (case B) output changed
973 !.
973 !.
974 Failed test-cases-abc.t (case B): output changed
974 Failed test-cases-abc.t (case B): output changed
975 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
975 # Ran 2 tests, 0 skipped, 0 warned, 1 failed.
976 python hash seed: * (glob)
976 python hash seed: * (glob)
977 [1]
977 [1]
General Comments 0
You need to be logged in to leave comments. Login now