author | Gregory Szorc <gregory.szorc@gmail.com> |
Tue, 28 Aug 2018 18:05:48 -0700 | |
changeset 39447 | 5f4a9ada5ab5 |
parent 39402 | ecbab8be7470 |
child 39648 | e37a0fcd82c0 |
permissions | -rw-r--r-- |
27298
e1f55b50edcb
tests: use absolute_import in hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27114
diff
changeset
|
1 |
from __future__ import absolute_import |
e1f55b50edcb
tests: use absolute_import in hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27114
diff
changeset
|
2 |
|
26137
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
3 |
import errno |
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
4 |
import os |
5252
c0281c6b40b0
hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents:
5218
diff
changeset
|
5 |
import re |
22994
840be5ca03e1
cmdserver: add service that listens on unix domain socket and forks process
Yuya Nishihara <yuya@tcha.org>
parents:
22579
diff
changeset
|
6 |
import socket |
26137
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
7 |
import stat |
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
8 |
import subprocess |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
9 |
import sys |
5072
7e2385a31933
hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents:
5070
diff
changeset
|
10 |
import tempfile |
4881
c51c9bc4579d
Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
11 |
|
5090
bf60e4bd6672
hghave: prefix temporary files with "hg-hghave-"
Patrick Mezard <pmezard@gmail.com>
parents:
5084
diff
changeset
|
12 |
tempprefix = 'hg-hghave-' |
bf60e4bd6672
hghave: prefix temporary files with "hg-hghave-"
Patrick Mezard <pmezard@gmail.com>
parents:
5084
diff
changeset
|
13 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
14 |
checks = { |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
15 |
"true": (lambda: True, "yak shaving"), |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
16 |
"false": (lambda: False, "nail clipper"), |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
17 |
} |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
18 |
|
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
19 |
def check(name, desc): |
28757
93bf61913f33
hghave: add docstring for check
timeless <timeless@mozdev.org>
parents:
28756
diff
changeset
|
20 |
"""Registers a check function for a feature.""" |
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
21 |
def decorator(func): |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
22 |
checks[name] = (func, desc) |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
23 |
return func |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
24 |
return decorator |
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
25 |
|
28758
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
26 |
def checkvers(name, desc, vers): |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
27 |
"""Registers a check function for each of a series of versions. |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
28 |
|
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
29 |
vers can be a list or an iterator""" |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
30 |
def decorator(func): |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
31 |
def funcv(v): |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
32 |
def f(): |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
33 |
return func(v) |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
34 |
return f |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
35 |
for v in vers: |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
36 |
v = str(v) |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
37 |
f = funcv(v) |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
38 |
checks['%s%s' % (name, v.replace('.', ''))] = (f, desc % v) |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
39 |
return func |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
40 |
return decorator |
44e076a12bd3
hghave: add checkvers function
timeless <timeless@mozdev.org>
parents:
28757
diff
changeset
|
41 |
|
26067
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
42 |
def checkfeatures(features): |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
43 |
result = { |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
44 |
'error': [], |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
45 |
'missing': [], |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
46 |
'skipped': [], |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
47 |
} |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
48 |
|
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
49 |
for feature in features: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
50 |
negate = feature.startswith('no-') |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
51 |
if negate: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
52 |
feature = feature[3:] |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
53 |
|
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
54 |
if feature not in checks: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
55 |
result['missing'].append(feature) |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
56 |
continue |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
57 |
|
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
58 |
check, desc = checks[feature] |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
59 |
try: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
60 |
available = check() |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
61 |
except Exception: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
62 |
result['error'].append('hghave check failed: %s' % feature) |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
63 |
continue |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
64 |
|
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
65 |
if not negate and not available: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
66 |
result['skipped'].append('missing feature: %s' % desc) |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
67 |
elif negate and available: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
68 |
result['skipped'].append('system supports %s' % desc) |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
69 |
|
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
70 |
return result |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
71 |
|
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
72 |
def require(features): |
26067
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
73 |
"""Require that features are available, exiting if not.""" |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
74 |
result = checkfeatures(features) |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
75 |
|
26068
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
76 |
for missing in result['missing']: |
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
77 |
sys.stderr.write('skipped: unknown feature: %s\n' % missing) |
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
78 |
for msg in result['skipped']: |
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
79 |
sys.stderr.write('skipped: %s\n' % msg) |
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
80 |
for msg in result['error']: |
05e7f57c74ac
hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26067
diff
changeset
|
81 |
sys.stderr.write('%s\n' % msg) |
26067
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
82 |
|
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
83 |
if result['missing']: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
84 |
sys.exit(2) |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
85 |
|
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
86 |
if result['skipped'] or result['error']: |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
87 |
sys.exit(1) |
8107c308ff22
hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25859
diff
changeset
|
88 |
|
5302
961876838de0
hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents:
5252
diff
changeset
|
89 |
def matchoutput(cmd, regexp, ignorestatus=False): |
27114
a636a46f5094
hghave.py: fix matchoutput documentation
timeless <timeless@mozdev.org>
parents:
26842
diff
changeset
|
90 |
"""Return the match object if cmd executes successfully and its output |
5252
c0281c6b40b0
hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents:
5218
diff
changeset
|
91 |
is matched by the supplied regular expression. |
c0281c6b40b0
hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents:
5218
diff
changeset
|
92 |
""" |
c0281c6b40b0
hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents:
5218
diff
changeset
|
93 |
r = re.compile(regexp) |
8213
ac9c4049fd29
hghave: handle Windows raising on popen() failure
Patrick Mezard <pmezard@gmail.com>
parents:
8127
diff
changeset
|
94 |
try: |
26137
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
95 |
p = subprocess.Popen( |
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
96 |
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
97 |
except OSError as e: |
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
98 |
if e.errno != errno.ENOENT: |
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
99 |
raise |
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
100 |
ret = -1 |
38179
6fb76897e066
hghave: avoid a deadlock reading the child process's output
Matt Harbison <matt_harbison@yahoo.com>
parents:
37415
diff
changeset
|
101 |
s = p.communicate()[0] |
6fb76897e066
hghave: avoid a deadlock reading the child process's output
Matt Harbison <matt_harbison@yahoo.com>
parents:
37415
diff
changeset
|
102 |
ret = p.returncode |
26137
99e8a9ff1f5f
hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents:
26111
diff
changeset
|
103 |
return (ignorestatus or not ret) and r.search(s) |
5252
c0281c6b40b0
hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents:
5218
diff
changeset
|
104 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
105 |
@check("baz", "GNU Arch baz client") |
6078
ebc23d34102f
convert: added gnu arch (baz) tests
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6063
diff
changeset
|
106 |
def has_baz(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
107 |
return matchoutput('baz --version 2>&1', br'baz Bazaar version') |
6078
ebc23d34102f
convert: added gnu arch (baz) tests
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6063
diff
changeset
|
108 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
109 |
@check("bzr", "Canonical's Bazaar client") |
7053
209ef5f3534c
convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
6998
diff
changeset
|
110 |
def has_bzr(): |
7061
8b874f8cd29f
tests: check for bzr support by importing bzrlib
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7053
diff
changeset
|
111 |
try: |
8b874f8cd29f
tests: check for bzr support by importing bzrlib
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7053
diff
changeset
|
112 |
import bzrlib |
29866
a5ce381a8da0
hghave: make bzr checks stricter
timeless <timeless@mozdev.org>
parents:
29843
diff
changeset
|
113 |
import bzrlib.bzrdir |
a5ce381a8da0
hghave: make bzr checks stricter
timeless <timeless@mozdev.org>
parents:
29843
diff
changeset
|
114 |
import bzrlib.errors |
a5ce381a8da0
hghave: make bzr checks stricter
timeless <timeless@mozdev.org>
parents:
29843
diff
changeset
|
115 |
import bzrlib.revision |
29903
fe81c953f369
hghave: fix has_bzr() to not try to import RevisionSpec as module
Yuya Nishihara <yuya@tcha.org>
parents:
29873
diff
changeset
|
116 |
import bzrlib.revisionspec |
fe81c953f369
hghave: fix has_bzr() to not try to import RevisionSpec as module
Yuya Nishihara <yuya@tcha.org>
parents:
29873
diff
changeset
|
117 |
bzrlib.revisionspec.RevisionSpec |
16684
e617876fe82d
cleanup: "x != None" -> "x is not None"
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
118 |
return bzrlib.__doc__ is not None |
29903
fe81c953f369
hghave: fix has_bzr() to not try to import RevisionSpec as module
Yuya Nishihara <yuya@tcha.org>
parents:
29873
diff
changeset
|
119 |
except (AttributeError, ImportError): |
7061
8b874f8cd29f
tests: check for bzr support by importing bzrlib
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7053
diff
changeset
|
120 |
return False |
7053
209ef5f3534c
convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents:
6998
diff
changeset
|
121 |
|
28760
cef86c3c82d2
hghave: use checkvers for bzr114
timeless <timeless@mozdev.org>
parents:
28759
diff
changeset
|
122 |
@checkvers("bzr", "Canonical's Bazaar client >= %s", (1.14,)) |
cef86c3c82d2
hghave: use checkvers for bzr114
timeless <timeless@mozdev.org>
parents:
28759
diff
changeset
|
123 |
def has_bzr_range(v): |
cef86c3c82d2
hghave: use checkvers for bzr114
timeless <timeless@mozdev.org>
parents:
28759
diff
changeset
|
124 |
major, minor = v.split('.')[0:2] |
8126
13b36eb14324
convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents:
7823
diff
changeset
|
125 |
try: |
13b36eb14324
convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents:
7823
diff
changeset
|
126 |
import bzrlib |
16684
e617876fe82d
cleanup: "x != None" -> "x is not None"
Brodie Rao <brodie@sf.io>
parents:
16683
diff
changeset
|
127 |
return (bzrlib.__doc__ is not None |
28760
cef86c3c82d2
hghave: use checkvers for bzr114
timeless <timeless@mozdev.org>
parents:
28759
diff
changeset
|
128 |
and bzrlib.version_info[:2] >= (int(major), int(minor))) |
8126
13b36eb14324
convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents:
7823
diff
changeset
|
129 |
except ImportError: |
13b36eb14324
convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents:
7823
diff
changeset
|
130 |
return False |
13b36eb14324
convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents:
7823
diff
changeset
|
131 |
|
28880
f74eed3115fd
hghave: add "chg" flag to skip tests that can't be compatible with chg
Yuya Nishihara <yuya@tcha.org>
parents:
28796
diff
changeset
|
132 |
@check("chg", "running with chg") |
f74eed3115fd
hghave: add "chg" flag to skip tests that can't be compatible with chg
Yuya Nishihara <yuya@tcha.org>
parents:
28796
diff
changeset
|
133 |
def has_chg(): |
f74eed3115fd
hghave: add "chg" flag to skip tests that can't be compatible with chg
Yuya Nishihara <yuya@tcha.org>
parents:
28796
diff
changeset
|
134 |
return 'CHGHG' in os.environ |
f74eed3115fd
hghave: add "chg" flag to skip tests that can't be compatible with chg
Yuya Nishihara <yuya@tcha.org>
parents:
28796
diff
changeset
|
135 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
136 |
@check("cvs", "cvs client/server") |
5302
961876838de0
hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents:
5252
diff
changeset
|
137 |
def has_cvs(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
138 |
re = br'Concurrent Versions System.*?server' |
15568
08635f4e44be
tests: skip cvs tests with msys on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
15567
diff
changeset
|
139 |
return matchoutput('cvs --version 2>&1', re) and not has_msys() |
5302
961876838de0
hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents:
5252
diff
changeset
|
140 |
|
28756
45954a251a40
hghave: update cvs112 description
timeless <timeless@mozdev.org>
parents:
28591
diff
changeset
|
141 |
@check("cvs112", "cvs client/server 1.12.* (not cvsnt)") |
18285
9589227657bc
hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents:
17707
diff
changeset
|
142 |
def has_cvs112(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
143 |
re = br'Concurrent Versions System \(CVS\) 1.12.*?server' |
18285
9589227657bc
hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents:
17707
diff
changeset
|
144 |
return matchoutput('cvs --version 2>&1', re) and not has_msys() |
9589227657bc
hghave: introduce a test (unused) for cvs >= 1.12
Bryan O'Sullivan <bryano@fb.com>
parents:
17707
diff
changeset
|
145 |
|
28796 | 146 |
@check("cvsnt", "cvsnt client/server") |
147 |
def has_cvsnt(): |
|
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
148 |
re = br'Concurrent Versions System \(CVSNT\) (\d+).(\d+).*\(client/server\)' |
28796 | 149 |
return matchoutput('cvsnt --version 2>&1', re) |
150 |
||
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
151 |
@check("darcs", "darcs client") |
5410
2daecf3d2582
hghave: detect darcs client
Patrick Mezard <pmezard@gmail.com>
parents:
5409
diff
changeset
|
152 |
def has_darcs(): |
30297
d4db88a26ad5
hghave: check darcs version more strictly
Yuya Nishihara <yuya@tcha.org>
parents:
30242
diff
changeset
|
153 |
return matchoutput('darcs --version', br'\b2\.([2-9]|\d{2})', True) |
5410
2daecf3d2582
hghave: detect darcs client
Patrick Mezard <pmezard@gmail.com>
parents:
5409
diff
changeset
|
154 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
155 |
@check("mtn", "monotone client (>= 1.0)") |
6372
8f79820443a4
Add a test for monotone conversion
Patrick Mezard <pmezard@gmail.com>
parents:
6355
diff
changeset
|
156 |
def has_mtn(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
157 |
return matchoutput('mtn --version', br'monotone', True) and not matchoutput( |
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
158 |
'mtn --version', br'monotone 0\.', True) |
6372
8f79820443a4
Add a test for monotone conversion
Patrick Mezard <pmezard@gmail.com>
parents:
6355
diff
changeset
|
159 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
160 |
@check("eol-in-paths", "end-of-lines in paths") |
5409
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
161 |
def has_eol_in_paths(): |
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
162 |
try: |
16968
456f457e376d
tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents:
16966
diff
changeset
|
163 |
fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix, suffix='\n\r') |
5409
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
164 |
os.close(fd) |
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
165 |
os.remove(path) |
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
166 |
return True |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16685
diff
changeset
|
167 |
except (IOError, OSError): |
5409
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
168 |
return False |
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
169 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
170 |
@check("execbit", "executable bit") |
5072
7e2385a31933
hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents:
5070
diff
changeset
|
171 |
def has_executablebit(): |
7e2385a31933
hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents:
5070
diff
changeset
|
172 |
try: |
16320
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
173 |
EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
16968
456f457e376d
tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents:
16966
diff
changeset
|
174 |
fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
16320
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
175 |
try: |
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
176 |
os.close(fh) |
25658
e93036747902
global: mass rewrite to use modern octal syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25413
diff
changeset
|
177 |
m = os.stat(fn).st_mode & 0o777 |
16320
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
178 |
new_file_has_exec = m & EXECFLAGS |
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
179 |
os.chmod(fn, m ^ EXECFLAGS) |
25658
e93036747902
global: mass rewrite to use modern octal syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25413
diff
changeset
|
180 |
exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0o777) == m) |
16320
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
181 |
finally: |
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
182 |
os.unlink(fn) |
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
183 |
except (IOError, OSError): |
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
184 |
# we don't care, the user probably won't be able to commit anyway |
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
185 |
return False |
e11ab387e89c
tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents:
16319
diff
changeset
|
186 |
return not (new_file_has_exec or exec_flags_cannot_flip) |
5072
7e2385a31933
hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents:
5070
diff
changeset
|
187 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
188 |
@check("icasefs", "case insensitive file system") |
6806
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
189 |
def has_icasefs(): |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
190 |
# Stolen from mercurial.util |
16968
456f457e376d
tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents:
16966
diff
changeset
|
191 |
fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
6806
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
192 |
os.close(fd) |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
193 |
try: |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
194 |
s1 = os.stat(path) |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
195 |
d, b = os.path.split(path) |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
196 |
p2 = os.path.join(d, b.upper()) |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
197 |
if path == p2: |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
198 |
p2 = os.path.join(d, b.lower()) |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
199 |
try: |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
200 |
s2 = os.stat(p2) |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
201 |
return s2 == s1 |
16688
cfb6682961b8
cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents:
16685
diff
changeset
|
202 |
except OSError: |
6806
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
203 |
return False |
2134d6c09432
Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents:
6626
diff
changeset
|
204 |
finally: |
6998 | 205 |
os.remove(path) |
206 |
||
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
207 |
@check("fifo", "named pipes") |
5409
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
208 |
def has_fifo(): |
16969
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
209 |
if getattr(os, "mkfifo", None) is None: |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
210 |
return False |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
211 |
name = tempfile.mktemp(dir='.', prefix=tempprefix) |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
212 |
try: |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
213 |
os.mkfifo(name) |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
214 |
os.unlink(name) |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
215 |
return True |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
216 |
except OSError: |
6d1673107143
tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents:
16968
diff
changeset
|
217 |
return False |
5074
e86788af599a
hghave: detect support for EOL in paths.
Patrick Mezard <pmezard@gmail.com>
parents:
5072
diff
changeset
|
218 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
219 |
@check("killdaemons", 'killdaemons.py support') |
17467
448d0c452140
test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents:
17016
diff
changeset
|
220 |
def has_killdaemons(): |
448d0c452140
test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents:
17016
diff
changeset
|
221 |
return True |
448d0c452140
test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents:
17016
diff
changeset
|
222 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
223 |
@check("cacheable", "cacheable filesystem") |
14927
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
224 |
def has_cacheable_fs(): |
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
225 |
from mercurial import util |
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
226 |
|
16968
456f457e376d
tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents:
16966
diff
changeset
|
227 |
fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix) |
14927
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
228 |
os.close(fd) |
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
229 |
try: |
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
230 |
return util.cachestat(path).cacheable() |
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
231 |
finally: |
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
232 |
os.remove(path) |
2aa3e07b2f07
posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents:
14550
diff
changeset
|
233 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
234 |
@check("lsprof", "python lsprof module") |
5099
105d4cf7ec24
Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
5092
diff
changeset
|
235 |
def has_lsprof(): |
105d4cf7ec24
Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
5092
diff
changeset
|
236 |
try: |
105d4cf7ec24
Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
5092
diff
changeset
|
237 |
import _lsprof |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
22093
diff
changeset
|
238 |
_lsprof.Profiler # silence unused import warning |
5099
105d4cf7ec24
Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
5092
diff
changeset
|
239 |
return True |
105d4cf7ec24
Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
5092
diff
changeset
|
240 |
except ImportError: |
105d4cf7ec24
Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
5092
diff
changeset
|
241 |
return False |
105d4cf7ec24
Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents:
5092
diff
changeset
|
242 |
|
28761 | 243 |
def gethgversion(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
244 |
m = matchoutput('hg --version --quiet 2>&1', br'(\d+)\.(\d+)') |
28761 | 245 |
if not m: |
246 |
return (0, 0) |
|
247 |
return (int(m.group(1)), int(m.group(2))) |
|
248 |
||
249 |
@checkvers("hg", "Mercurial >= %s", |
|
32206
5bdceec6387d
hghave: prefill more version of Mercurial
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
31964
diff
changeset
|
250 |
list([(1.0 * x) / 10 for x in range(9, 99)])) |
28761 | 251 |
def has_hg_range(v): |
252 |
major, minor = v.split('.')[0:2] |
|
253 |
return gethgversion() >= (int(major), int(minor)) |
|
254 |
||
255 |
@check("hg08", "Mercurial >= 0.8") |
|
256 |
def has_hg08(): |
|
257 |
if checks["hg09"][0](): |
|
258 |
return True |
|
259 |
return matchoutput('hg help annotate 2>&1', '--date') |
|
260 |
||
261 |
@check("hg07", "Mercurial >= 0.7") |
|
262 |
def has_hg07(): |
|
263 |
if checks["hg08"][0](): |
|
264 |
return True |
|
265 |
return matchoutput('hg --version --quiet 2>&1', 'Mercurial Distributed SCM') |
|
266 |
||
267 |
@check("hg06", "Mercurial >= 0.6") |
|
268 |
def has_hg06(): |
|
269 |
if checks["hg07"][0](): |
|
270 |
return True |
|
271 |
return matchoutput('hg --version --quiet 2>&1', 'Mercurial version') |
|
272 |
||
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
273 |
@check("gettext", "GNU Gettext (msgfmt)") |
13442
bb107a31820e
test-i18n: make test conditional on msgfmt availability
Martin Geisler <mg@lazybytes.net>
parents:
13418
diff
changeset
|
274 |
def has_gettext(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
275 |
return matchoutput('msgfmt --version', br'GNU gettext-tools') |
13442
bb107a31820e
test-i18n: make test conditional on msgfmt availability
Martin Geisler <mg@lazybytes.net>
parents:
13418
diff
changeset
|
276 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
277 |
@check("git", "git command line client") |
5218
4fa0f2dff643
hghave: detect git availability
Patrick Mezard <pmezard@gmail.com>
parents:
5103
diff
changeset
|
278 |
def has_git(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
279 |
return matchoutput('git --version 2>&1', br'^git version') |
5218
4fa0f2dff643
hghave: detect git availability
Patrick Mezard <pmezard@gmail.com>
parents:
5103
diff
changeset
|
280 |
|
32901
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
281 |
def getgitversion(): |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
282 |
m = matchoutput('git --version 2>&1', br'git version (\d+)\.(\d+)') |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
283 |
if not m: |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
284 |
return (0, 0) |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
285 |
return (int(m.group(1)), int(m.group(2))) |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
286 |
|
35139
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
287 |
# https://github.com/git-lfs/lfs-test-server |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
288 |
@check("lfs-test-server", "git-lfs test server") |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
289 |
def has_lfsserver(): |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
290 |
exe = 'lfs-test-server' |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
291 |
if has_windows(): |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
292 |
exe = 'lfs-test-server.exe' |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
293 |
return any( |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
294 |
os.access(os.path.join(path, exe), os.X_OK) |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
295 |
for path in os.environ["PATH"].split(os.pathsep) |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
296 |
) |
a2e927ded455
hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents:
35043
diff
changeset
|
297 |
|
32901
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
298 |
@checkvers("git", "git client (with ext::sh support) version >= %s", (1.9,)) |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
299 |
def has_git_range(v): |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
300 |
major, minor = v.split('.')[0:2] |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
301 |
return getgitversion() >= (int(major), int(minor)) |
559db66dead5
hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents:
32856
diff
changeset
|
302 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
303 |
@check("docutils", "Docutils text processing library") |
10971
cbe400a8e217
doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents:
9819
diff
changeset
|
304 |
def has_docutils(): |
cbe400a8e217
doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents:
9819
diff
changeset
|
305 |
try: |
28779
0970ebec29b4
hghave: replace relative import of docutils.core
Yuya Nishihara <yuya@tcha.org>
parents:
28761
diff
changeset
|
306 |
import docutils.core |
0970ebec29b4
hghave: replace relative import of docutils.core
Yuya Nishihara <yuya@tcha.org>
parents:
28761
diff
changeset
|
307 |
docutils.core.publish_cmdline # silence unused import |
10971
cbe400a8e217
doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents:
9819
diff
changeset
|
308 |
return True |
cbe400a8e217
doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents:
9819
diff
changeset
|
309 |
except ImportError: |
cbe400a8e217
doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents:
9819
diff
changeset
|
310 |
return False |
9446
57d682d7d2da
test-gendoc: test documentation generation
Martin Geisler <mg@lazybytes.net>
parents:
9395
diff
changeset
|
311 |
|
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
13543
diff
changeset
|
312 |
def getsvnversion(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
313 |
m = matchoutput('svn --version --quiet 2>&1', br'^(\d+)\.(\d+)') |
14050
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
13543
diff
changeset
|
314 |
if not m: |
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
13543
diff
changeset
|
315 |
return (0, 0) |
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
13543
diff
changeset
|
316 |
return (int(m.group(1)), int(m.group(2))) |
9e8a9d45945c
subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents:
13543
diff
changeset
|
317 |
|
28759
2348ca49aaee
hghave: replace has_svn13/has_svn15 with checkvers
timeless <timeless@mozdev.org>
parents:
28758
diff
changeset
|
318 |
@checkvers("svn", "subversion client and admin tools >= %s", (1.3, 1.5)) |
2348ca49aaee
hghave: replace has_svn13/has_svn15 with checkvers
timeless <timeless@mozdev.org>
parents:
28758
diff
changeset
|
319 |
def has_svn_range(v): |
2348ca49aaee
hghave: replace has_svn13/has_svn15 with checkvers
timeless <timeless@mozdev.org>
parents:
28758
diff
changeset
|
320 |
major, minor = v.split('.')[0:2] |
2348ca49aaee
hghave: replace has_svn13/has_svn15 with checkvers
timeless <timeless@mozdev.org>
parents:
28758
diff
changeset
|
321 |
return getsvnversion() >= (int(major), int(minor)) |
15346
53f37b24f26a
tests: check for svn >= 1.3 and >= 1.5 in tests that require those versions
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14927
diff
changeset
|
322 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
323 |
@check("svn", "subversion client and admin tools") |
5253
d82ebcdf20e1
hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents:
5252
diff
changeset
|
324 |
def has_svn(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
325 |
return matchoutput('svn --version 2>&1', br'^svn, version') and \ |
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
326 |
matchoutput('svnadmin --version 2>&1', br'^svnadmin, version') |
5253
d82ebcdf20e1
hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents:
5252
diff
changeset
|
327 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
328 |
@check("svn-bindings", "subversion python bindings") |
5254
d61e98a82cee
hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents:
5253
diff
changeset
|
329 |
def has_svn_bindings(): |
d61e98a82cee
hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents:
5253
diff
changeset
|
330 |
try: |
d61e98a82cee
hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents:
5253
diff
changeset
|
331 |
import svn.core |
7315
408cf9eb9e5d
tests: run svn tests only with svn bindings >1.3
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7061
diff
changeset
|
332 |
version = svn.core.SVN_VER_MAJOR, svn.core.SVN_VER_MINOR |
408cf9eb9e5d
tests: run svn tests only with svn bindings >1.3
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7061
diff
changeset
|
333 |
if version < (1, 4): |
408cf9eb9e5d
tests: run svn tests only with svn bindings >1.3
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7061
diff
changeset
|
334 |
return False |
5254
d61e98a82cee
hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents:
5253
diff
changeset
|
335 |
return True |
d61e98a82cee
hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents:
5253
diff
changeset
|
336 |
except ImportError: |
d61e98a82cee
hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents:
5253
diff
changeset
|
337 |
return False |
d61e98a82cee
hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents:
5253
diff
changeset
|
338 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
339 |
@check("p4", "Perforce server and client") |
7823
11efa41037e2
convert: Perforce source for conversion to Mercurial
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7773
diff
changeset
|
340 |
def has_p4(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
341 |
return (matchoutput('p4 -V', br'Rev\. P4/') and |
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
342 |
matchoutput('p4d -V', br'Rev\. P4D/')) |
7823
11efa41037e2
convert: Perforce source for conversion to Mercurial
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents:
7773
diff
changeset
|
343 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
344 |
@check("symlink", "symbolic links") |
5409
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
345 |
def has_symlink(): |
16685
43d55088415a
cleanup: replace hasattr() usage with getattr() in hghave
Brodie Rao <brodie@sf.io>
parents:
16684
diff
changeset
|
346 |
if getattr(os, "symlink", None) is None: |
16319
ac0da5caebec
tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents:
15568
diff
changeset
|
347 |
return False |
16968
456f457e376d
tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents:
16966
diff
changeset
|
348 |
name = tempfile.mktemp(dir='.', prefix=tempprefix) |
16319
ac0da5caebec
tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents:
15568
diff
changeset
|
349 |
try: |
ac0da5caebec
tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents:
15568
diff
changeset
|
350 |
os.symlink(".", name) |
ac0da5caebec
tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents:
15568
diff
changeset
|
351 |
os.unlink(name) |
ac0da5caebec
tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents:
15568
diff
changeset
|
352 |
return True |
ac0da5caebec
tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents:
15568
diff
changeset
|
353 |
except (OSError, AttributeError): |
ac0da5caebec
tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents:
15568
diff
changeset
|
354 |
return False |
5409
190c234c8fa0
hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents:
5308
diff
changeset
|
355 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
356 |
@check("hardlink", "hardlinks") |
16971
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
357 |
def has_hardlink(): |
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
358 |
from mercurial import util |
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
359 |
fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix) |
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
360 |
os.close(fh) |
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
361 |
name = tempfile.mktemp(dir='.', prefix=tempprefix) |
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
362 |
try: |
25090
252412e24551
hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24290
diff
changeset
|
363 |
util.oslink(fn, name) |
252412e24551
hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24290
diff
changeset
|
364 |
os.unlink(name) |
252412e24551
hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24290
diff
changeset
|
365 |
return True |
252412e24551
hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24290
diff
changeset
|
366 |
except OSError: |
252412e24551
hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents:
24290
diff
changeset
|
367 |
return False |
16971
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
368 |
finally: |
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
369 |
os.unlink(fn) |
8aeb2f1ae94c
tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents:
16970
diff
changeset
|
370 |
|
31576
07f0cddb0594
hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents:
31413
diff
changeset
|
371 |
@check("hardlink-whitelisted", "hardlinks on whitelisted filesystems") |
07f0cddb0594
hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents:
31413
diff
changeset
|
372 |
def has_hardlink_whitelisted(): |
31674
b33e352c365c
hghave: use util.getfstype
Yuya Nishihara <yuya@tcha.org>
parents:
31576
diff
changeset
|
373 |
from mercurial import util |
31678
1ed57a7dd904
statfs: make getfstype() raise OSError
Yuya Nishihara <yuya@tcha.org>
parents:
31674
diff
changeset
|
374 |
try: |
36942
bf73012877a4
hghave: fix hardlink-whitelisted check on Python 3
Augie Fackler <augie@google.com>
parents:
36941
diff
changeset
|
375 |
fstype = util.getfstype(b'.') |
31678
1ed57a7dd904
statfs: make getfstype() raise OSError
Yuya Nishihara <yuya@tcha.org>
parents:
31674
diff
changeset
|
376 |
except OSError: |
1ed57a7dd904
statfs: make getfstype() raise OSError
Yuya Nishihara <yuya@tcha.org>
parents:
31674
diff
changeset
|
377 |
return False |
31576
07f0cddb0594
hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents:
31413
diff
changeset
|
378 |
return fstype in util._hardlinkfswhitelist |
07f0cddb0594
hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents:
31413
diff
changeset
|
379 |
|
30230
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
380 |
@check("rmcwd", "can remove current working directory") |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
381 |
def has_rmcwd(): |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
382 |
ocwd = os.getcwd() |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
383 |
temp = tempfile.mkdtemp(dir='.', prefix=tempprefix) |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
384 |
try: |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
385 |
os.chdir(temp) |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
386 |
# On Linux, 'rmdir .' isn't allowed, but the other names are okay. |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
387 |
# On Solaris and Windows, the cwd can't be removed by any names. |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
388 |
os.rmdir(os.getcwd()) |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
389 |
return True |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
390 |
except OSError: |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
391 |
return False |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
392 |
finally: |
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
393 |
os.chdir(ocwd) |
30242
389cbfe63586
hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents:
30230
diff
changeset
|
394 |
# clean up temp dir on platforms where cwd can't be removed |
389cbfe63586
hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents:
30230
diff
changeset
|
395 |
try: |
389cbfe63586
hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents:
30230
diff
changeset
|
396 |
os.rmdir(temp) |
389cbfe63586
hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents:
30230
diff
changeset
|
397 |
except OSError: |
389cbfe63586
hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents:
30230
diff
changeset
|
398 |
pass |
30230
46a0203dfb89
tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents:
29903
diff
changeset
|
399 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
400 |
@check("tla", "GNU Arch tla client") |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
401 |
def has_tla(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
402 |
return matchoutput('tla --version 2>&1', br'The GNU Arch Revision') |
6079
ea34059b89de
convert: added GNU Arch (tla) tests and related fixes
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
6078
diff
changeset
|
403 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
404 |
@check("gpg", "gpg client") |
8809 | 405 |
def has_gpg(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
406 |
return matchoutput('gpg --version 2>&1', br'GnuPG') |
8809 | 407 |
|
29790
94fb0458a791
test-gpg: start gpg-agent under control of the test runner
Yuya Nishihara <yuya@tcha.org>
parents:
29611
diff
changeset
|
408 |
@check("gpg2", "gpg client v2") |
94fb0458a791
test-gpg: start gpg-agent under control of the test runner
Yuya Nishihara <yuya@tcha.org>
parents:
29611
diff
changeset
|
409 |
def has_gpg2(): |
94fb0458a791
test-gpg: start gpg-agent under control of the test runner
Yuya Nishihara <yuya@tcha.org>
parents:
29611
diff
changeset
|
410 |
return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.') |
94fb0458a791
test-gpg: start gpg-agent under control of the test runner
Yuya Nishihara <yuya@tcha.org>
parents:
29611
diff
changeset
|
411 |
|
29873
80ba176bad62
test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
Yuya Nishihara <yuya@tcha.org>
parents:
29867
diff
changeset
|
412 |
@check("gpg21", "gpg client v2.1+") |
80ba176bad62
test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
Yuya Nishihara <yuya@tcha.org>
parents:
29867
diff
changeset
|
413 |
def has_gpg21(): |
80ba176bad62
test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
Yuya Nishihara <yuya@tcha.org>
parents:
29867
diff
changeset
|
414 |
return matchoutput('gpg --version 2>&1', br'GnuPG[^0-9]+2\.(?!0)') |
80ba176bad62
test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
Yuya Nishihara <yuya@tcha.org>
parents:
29867
diff
changeset
|
415 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
416 |
@check("unix-permissions", "unix-style permissions") |
6063
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
417 |
def has_unix_permissions(): |
16968
456f457e376d
tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents:
16966
diff
changeset
|
418 |
d = tempfile.mkdtemp(dir='.', prefix=tempprefix) |
6063
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
419 |
try: |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
420 |
fname = os.path.join(d, 'foo') |
25658
e93036747902
global: mass rewrite to use modern octal syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25413
diff
changeset
|
421 |
for umask in (0o77, 0o07, 0o22): |
6063
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
422 |
os.umask(umask) |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
423 |
f = open(fname, 'w') |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
424 |
f.close() |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
425 |
mode = os.stat(fname).st_mode |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
426 |
os.unlink(fname) |
25658
e93036747902
global: mass rewrite to use modern octal syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25413
diff
changeset
|
427 |
if mode & 0o777 != ~umask & 0o666: |
6063
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
428 |
return False |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
429 |
return True |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
430 |
finally: |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
431 |
os.rmdir(d) |
b74a0c4bfb30
hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5685
diff
changeset
|
432 |
|
22994
840be5ca03e1
cmdserver: add service that listens on unix domain socket and forks process
Yuya Nishihara <yuya@tcha.org>
parents:
22579
diff
changeset
|
433 |
@check("unix-socket", "AF_UNIX socket family") |
840be5ca03e1
cmdserver: add service that listens on unix domain socket and forks process
Yuya Nishihara <yuya@tcha.org>
parents:
22579
diff
changeset
|
434 |
def has_unix_socket(): |
840be5ca03e1
cmdserver: add service that listens on unix domain socket and forks process
Yuya Nishihara <yuya@tcha.org>
parents:
22579
diff
changeset
|
435 |
return getattr(socket, 'AF_UNIX', None) is not None |
840be5ca03e1
cmdserver: add service that listens on unix domain socket and forks process
Yuya Nishihara <yuya@tcha.org>
parents:
22579
diff
changeset
|
436 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
437 |
@check("root", "root permissions") |
20008
e54a078153f7
tests: skip tests that require not having root (issue4089)
Matt Mackall <mpm@selenic.com>
parents:
19931
diff
changeset
|
438 |
def has_root(): |
20114
390aff33c2f9
tests: fix `hghave root` on windows
Simon Heimberg <simohe@besonet.ch>
parents:
20008
diff
changeset
|
439 |
return getattr(os, 'geteuid', None) and os.geteuid() == 0 |
20008
e54a078153f7
tests: skip tests that require not having root (issue4089)
Matt Mackall <mpm@selenic.com>
parents:
19931
diff
changeset
|
440 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
441 |
@check("pyflakes", "Pyflakes python linter") |
14140
82f0412ef7de
tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
14050
diff
changeset
|
442 |
def has_pyflakes(): |
16872
40d930848fd0
hghave: wrap command in 'sh -c "..."' for has_pyflakes()
Adrian Buehlmann <adrian@cadifra.com>
parents:
16688
diff
changeset
|
443 |
return matchoutput("sh -c \"echo 'import re' 2>&1 | pyflakes\"", |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
444 |
br"<stdin>:1: 're' imported but unused", |
14140
82f0412ef7de
tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
14050
diff
changeset
|
445 |
True) |
82f0412ef7de
tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents:
14050
diff
changeset
|
446 |
|
31413
aa797bd54f44
test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30559
diff
changeset
|
447 |
@check("pylint", "Pylint python linter") |
aa797bd54f44
test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30559
diff
changeset
|
448 |
def has_pylint(): |
aa797bd54f44
test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30559
diff
changeset
|
449 |
return matchoutput("pylint --help", |
aa797bd54f44
test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30559
diff
changeset
|
450 |
br"Usage: pylint", |
aa797bd54f44
test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30559
diff
changeset
|
451 |
True) |
aa797bd54f44
test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
30559
diff
changeset
|
452 |
|
34696
15b561fffde5
hghave: add a check for clang-format
Augie Fackler <augie@google.com>
parents:
34401
diff
changeset
|
453 |
@check("clang-format", "clang-format C code formatter") |
15b561fffde5
hghave: add a check for clang-format
Augie Fackler <augie@google.com>
parents:
34401
diff
changeset
|
454 |
def has_clang_format(): |
38703
b93dc48e74ad
hghave: require clang-format >= 6 due to output change
Yuya Nishihara <yuya@tcha.org>
parents:
38239
diff
changeset
|
455 |
m = matchoutput('clang-format --version', br'clang-format version (\d)') |
b93dc48e74ad
hghave: require clang-format >= 6 due to output change
Yuya Nishihara <yuya@tcha.org>
parents:
38239
diff
changeset
|
456 |
# style changed somewhere between 4.x and 6.x |
b93dc48e74ad
hghave: require clang-format >= 6 due to output change
Yuya Nishihara <yuya@tcha.org>
parents:
38239
diff
changeset
|
457 |
return m and int(m.group(1)) >= 6 |
34696
15b561fffde5
hghave: add a check for clang-format
Augie Fackler <augie@google.com>
parents:
34401
diff
changeset
|
458 |
|
35043
5d4369079c86
tests: use jshint when available to check .js files
Anton Shestakov <av6@dwimlabs.net>
parents:
34892
diff
changeset
|
459 |
@check("jshint", "JSHint static code analysis tool") |
5d4369079c86
tests: use jshint when available to check .js files
Anton Shestakov <av6@dwimlabs.net>
parents:
34892
diff
changeset
|
460 |
def has_jshint(): |
5d4369079c86
tests: use jshint when available to check .js files
Anton Shestakov <av6@dwimlabs.net>
parents:
34892
diff
changeset
|
461 |
return matchoutput("jshint --version 2>&1", br"jshint v") |
5d4369079c86
tests: use jshint when available to check .js files
Anton Shestakov <av6@dwimlabs.net>
parents:
34892
diff
changeset
|
462 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
463 |
@check("pygments", "Pygments source highlighting library") |
6355
3b841c189ab7
tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6079
diff
changeset
|
464 |
def has_pygments(): |
3b841c189ab7
tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6079
diff
changeset
|
465 |
try: |
3b841c189ab7
tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6079
diff
changeset
|
466 |
import pygments |
22198
77142de48ae4
cleanup: make sure we always access members of imported modules
Mads Kiilerich <madski@unity3d.com>
parents:
22093
diff
changeset
|
467 |
pygments.highlight # silence unused import warning |
6355
3b841c189ab7
tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6079
diff
changeset
|
468 |
return True |
3b841c189ab7
tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6079
diff
changeset
|
469 |
except ImportError: |
3b841c189ab7
tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6079
diff
changeset
|
470 |
return False |
3b841c189ab7
tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6079
diff
changeset
|
471 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
472 |
@check("outer-repo", "outer repo") |
7429
dbc40381620e
tests: Skip tests if they will fail because of outer repo
Mads Kiilerich <mads@kiilerich.com>
parents:
7315
diff
changeset
|
473 |
def has_outer_repo(): |
17016
468a950aebc3
tests: hghave outer-repo should be true even if a bad repo is found
Mads Kiilerich <mads@kiilerich.com>
parents:
16971
diff
changeset
|
474 |
# failing for other reasons than 'no repo' imply that there is a repo |
468a950aebc3
tests: hghave outer-repo should be true even if a bad repo is found
Mads Kiilerich <mads@kiilerich.com>
parents:
16971
diff
changeset
|
475 |
return not matchoutput('hg root 2>&1', |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
476 |
br'abort: no repository found', True) |
7429
dbc40381620e
tests: Skip tests if they will fail because of outer repo
Mads Kiilerich <mads@kiilerich.com>
parents:
7315
diff
changeset
|
477 |
|
28591
f29cab5c519c
hghave: change ssl check to just check ssl module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28582
diff
changeset
|
478 |
@check("ssl", "ssl module available") |
12740
b86c6954ec4c
serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents:
10971
diff
changeset
|
479 |
def has_ssl(): |
b86c6954ec4c
serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents:
10971
diff
changeset
|
480 |
try: |
b86c6954ec4c
serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents:
10971
diff
changeset
|
481 |
import ssl |
28591
f29cab5c519c
hghave: change ssl check to just check ssl module
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28582
diff
changeset
|
482 |
ssl.CERT_NONE |
12740
b86c6954ec4c
serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents:
10971
diff
changeset
|
483 |
return True |
b86c6954ec4c
serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents:
10971
diff
changeset
|
484 |
except ImportError: |
b86c6954ec4c
serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents:
10971
diff
changeset
|
485 |
return False |
b86c6954ec4c
serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents:
10971
diff
changeset
|
486 |
|
25413
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
487 |
@check("sslcontext", "python >= 2.7.9 ssl") |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
488 |
def has_sslcontext(): |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
489 |
try: |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
490 |
import ssl |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
491 |
ssl.SSLContext |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
492 |
return True |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
493 |
except (ImportError, AttributeError): |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
494 |
return False |
4d705f6a3c35
test-https: test basic functions of client certificate authentication
Yuya Nishihara <yuya@tcha.org>
parents:
25106
diff
changeset
|
495 |
|
24289
07fafcd4bc74
test-https: enable dummycert test only if Apple python is used (issue4500)
Yuya Nishihara <yuya@tcha.org>
parents:
23825
diff
changeset
|
496 |
@check("defaultcacerts", "can verify SSL certs by system's CA certs store") |
07fafcd4bc74
test-https: enable dummycert test only if Apple python is used (issue4500)
Yuya Nishihara <yuya@tcha.org>
parents:
23825
diff
changeset
|
497 |
def has_defaultcacerts(): |
29483
918dce4b8c26
sslutil: pass ui to _defaultcacerts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29481
diff
changeset
|
498 |
from mercurial import sslutil, ui as uimod |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30441
diff
changeset
|
499 |
ui = uimod.ui.load() |
29483
918dce4b8c26
sslutil: pass ui to _defaultcacerts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29481
diff
changeset
|
500 |
return sslutil._defaultcacerts(ui) or sslutil._canloaddefaultcerts |
24289
07fafcd4bc74
test-https: enable dummycert test only if Apple python is used (issue4500)
Yuya Nishihara <yuya@tcha.org>
parents:
23825
diff
changeset
|
501 |
|
29481
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
502 |
@check("defaultcacertsloaded", "detected presence of loaded system CA certs") |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
503 |
def has_defaultcacertsloaded(): |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
504 |
import ssl |
29483
918dce4b8c26
sslutil: pass ui to _defaultcacerts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29481
diff
changeset
|
505 |
from mercurial import sslutil, ui as uimod |
29481
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
506 |
|
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
507 |
if not has_defaultcacerts(): |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
508 |
return False |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
509 |
if not has_sslcontext(): |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
510 |
return False |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
511 |
|
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30441
diff
changeset
|
512 |
ui = uimod.ui.load() |
29483
918dce4b8c26
sslutil: pass ui to _defaultcacerts
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29481
diff
changeset
|
513 |
cafile = sslutil._defaultcacerts(ui) |
29481
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
514 |
ctx = ssl.create_default_context() |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
515 |
if cafile: |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
516 |
ctx.load_verify_locations(cafile=cafile) |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
517 |
else: |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
518 |
ctx.load_default_certs() |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
519 |
|
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
520 |
return len(ctx.get_ca_certs()) > 0 |
5caa415aa48b
tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29140
diff
changeset
|
521 |
|
29601
6cff2ac0ccb9
sslutil: more robustly detect protocol support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29576
diff
changeset
|
522 |
@check("tls1.2", "TLS 1.2 protocol support") |
6cff2ac0ccb9
sslutil: more robustly detect protocol support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29576
diff
changeset
|
523 |
def has_tls1_2(): |
6cff2ac0ccb9
sslutil: more robustly detect protocol support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29576
diff
changeset
|
524 |
from mercurial import sslutil |
29611
334632380e22
hghave: fix typo of sslutil.supportedprotocols
Yuya Nishihara <yuya@tcha.org>
parents:
29601
diff
changeset
|
525 |
return 'tls1.2' in sslutil.supportedprotocols |
29601
6cff2ac0ccb9
sslutil: more robustly detect protocol support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
29576
diff
changeset
|
526 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
527 |
@check("windows", "Windows") |
15444
e1f05d7a8c7b
tests: use 'hghave no-windows' to avoid testing reserved file names on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
15441
diff
changeset
|
528 |
def has_windows(): |
e1f05d7a8c7b
tests: use 'hghave no-windows' to avoid testing reserved file names on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
15441
diff
changeset
|
529 |
return os.name == 'nt' |
e1f05d7a8c7b
tests: use 'hghave no-windows' to avoid testing reserved file names on windows
Mads Kiilerich <mads@kiilerich.com>
parents:
15441
diff
changeset
|
530 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
531 |
@check("system-sh", "system() uses sh") |
15445
7cbb81c47025
tests: use 'hghave system-sh' to guard tests that requires sh in system()
Mads Kiilerich <mads@kiilerich.com>
parents:
15444
diff
changeset
|
532 |
def has_system_sh(): |
7cbb81c47025
tests: use 'hghave system-sh' to guard tests that requires sh in system()
Mads Kiilerich <mads@kiilerich.com>
parents:
15444
diff
changeset
|
533 |
return os.name != 'nt' |
7cbb81c47025
tests: use 'hghave system-sh' to guard tests that requires sh in system()
Mads Kiilerich <mads@kiilerich.com>
parents:
15444
diff
changeset
|
534 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
535 |
@check("serve", "platform and python can manage 'hg serve -d'") |
15446
c5c9ca3719f9
tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents:
15445
diff
changeset
|
536 |
def has_serve(): |
32856
41f99a90675d
hghave: enable 'serve' on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
32770
diff
changeset
|
537 |
return True |
15446
c5c9ca3719f9
tests: use 'hghave serve' to guard tests that requires serve daemon management
Mads Kiilerich <mads@kiilerich.com>
parents:
15445
diff
changeset
|
538 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
539 |
@check("test-repo", "running tests from repository") |
21208
0e1cbd3d52f7
tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents:
20644
diff
changeset
|
540 |
def has_test_repo(): |
0e1cbd3d52f7
tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents:
20644
diff
changeset
|
541 |
t = os.environ["TESTDIR"] |
0e1cbd3d52f7
tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents:
20644
diff
changeset
|
542 |
return os.path.isdir(os.path.join(t, "..", ".hg")) |
0e1cbd3d52f7
tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents:
20644
diff
changeset
|
543 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
544 |
@check("tic", "terminfo compiler and curses module") |
15539
d09ea5bbc9a4
tests: skip color test on platforms without tic
Mads Kiilerich <mads@kiilerich.com>
parents:
15446
diff
changeset
|
545 |
def has_tic(): |
20304
e457321a5687
tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents:
20114
diff
changeset
|
546 |
try: |
e457321a5687
tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents:
20114
diff
changeset
|
547 |
import curses |
e457321a5687
tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents:
20114
diff
changeset
|
548 |
curses.COLOR_BLUE |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
549 |
return matchoutput('test -x "`which tic`"', br'') |
20304
e457321a5687
tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents:
20114
diff
changeset
|
550 |
except ImportError: |
e457321a5687
tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents:
20114
diff
changeset
|
551 |
return False |
15539
d09ea5bbc9a4
tests: skip color test on platforms without tic
Mads Kiilerich <mads@kiilerich.com>
parents:
15446
diff
changeset
|
552 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
553 |
@check("msys", "Windows with MSYS") |
15567
8b84d040d9f9
tests: introduce 'hghave msys' to skip tests that would fail because of msys
Mads Kiilerich <mads@kiilerich.com>
parents:
15539
diff
changeset
|
554 |
def has_msys(): |
8b84d040d9f9
tests: introduce 'hghave msys' to skip tests that would fail because of msys
Mads Kiilerich <mads@kiilerich.com>
parents:
15539
diff
changeset
|
555 |
return os.getenv('MSYSTEM') |
8b84d040d9f9
tests: introduce 'hghave msys' to skip tests that would fail because of msys
Mads Kiilerich <mads@kiilerich.com>
parents:
15539
diff
changeset
|
556 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
557 |
@check("aix", "AIX") |
19092
8c560ad1cdc4
tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents:
18285
diff
changeset
|
558 |
def has_aix(): |
8c560ad1cdc4
tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents:
18285
diff
changeset
|
559 |
return sys.platform.startswith("aix") |
8c560ad1cdc4
tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents:
18285
diff
changeset
|
560 |
|
22575
d7f7f1860f00
ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs
Mads Kiilerich <madski@unity3d.com>
parents:
22198
diff
changeset
|
561 |
@check("osx", "OS X") |
d7f7f1860f00
ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs
Mads Kiilerich <madski@unity3d.com>
parents:
22198
diff
changeset
|
562 |
def has_osx(): |
d7f7f1860f00
ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs
Mads Kiilerich <madski@unity3d.com>
parents:
22198
diff
changeset
|
563 |
return sys.platform == 'darwin' |
d7f7f1860f00
ssl: on OS X, use a dummy cert to trick Python/OpenSSL to use system CA certs
Mads Kiilerich <madski@unity3d.com>
parents:
22198
diff
changeset
|
564 |
|
29026
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
565 |
@check("osxpackaging", "OS X packaging tools") |
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
566 |
def has_osxpackaging(): |
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
567 |
try: |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
568 |
return (matchoutput('pkgbuild', br'Usage: pkgbuild ', ignorestatus=1) |
29026
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
569 |
and matchoutput( |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
570 |
'productbuild', br'Usage: productbuild ', |
29026
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
571 |
ignorestatus=1) |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
572 |
and matchoutput('lsbom', br'Usage: lsbom', ignorestatus=1) |
29026
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
573 |
and matchoutput( |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
574 |
'xar --help', br'Usage: xar', ignorestatus=1)) |
29026
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
575 |
except ImportError: |
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
576 |
return False |
80f15aa32edd
hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents:
29022
diff
changeset
|
577 |
|
34885
df2ff314e36f
fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34840
diff
changeset
|
578 |
@check('linuxormacos', 'Linux or MacOS') |
df2ff314e36f
fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34840
diff
changeset
|
579 |
def has_linuxormacos(): |
df2ff314e36f
fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34840
diff
changeset
|
580 |
# This isn't a perfect test for MacOS. But it is sufficient for our needs. |
df2ff314e36f
fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34840
diff
changeset
|
581 |
return sys.platform.startswith(('linux', 'darwin')) |
df2ff314e36f
fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents:
34840
diff
changeset
|
582 |
|
26111
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
583 |
@check("docker", "docker support") |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
584 |
def has_docker(): |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
585 |
pat = br'A self-sufficient runtime for' |
26111
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
586 |
if matchoutput('docker --help', pat): |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
587 |
if 'linux' not in sys.platform: |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
588 |
# TODO: in theory we should be able to test docker-based |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
589 |
# package creation on non-linux using boot2docker, but in |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
590 |
# practice that requires extra coordination to make sure |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
591 |
# $TESTTEMP is going to be visible at the same path to the |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
592 |
# boot2docker VM. If we figure out how to verify that, we |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
593 |
# can use the following instead of just saying False: |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
594 |
# return 'DOCKER_HOST' in os.environ |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
595 |
return False |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
596 |
|
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
597 |
return True |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
598 |
return False |
dcc12365fa38
hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents:
26110
diff
changeset
|
599 |
|
26110
2dcfb98c5314
hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents:
26109
diff
changeset
|
600 |
@check("debhelper", "debian packaging tools") |
2dcfb98c5314
hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents:
26109
diff
changeset
|
601 |
def has_debhelper(): |
34394
dbf83230e8be
hghave: fix dpkg --version check to work on recent dpkg versions
Kyle Lippincott <spectral@google.com>
parents:
33697
diff
changeset
|
602 |
# Some versions of dpkg say `dpkg', some say 'dpkg' (` vs ' on the first |
dbf83230e8be
hghave: fix dpkg --version check to work on recent dpkg versions
Kyle Lippincott <spectral@google.com>
parents:
33697
diff
changeset
|
603 |
# quote), so just accept anything in that spot. |
26110
2dcfb98c5314
hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents:
26109
diff
changeset
|
604 |
dpkg = matchoutput('dpkg --version', |
34394
dbf83230e8be
hghave: fix dpkg --version check to work on recent dpkg versions
Kyle Lippincott <spectral@google.com>
parents:
33697
diff
changeset
|
605 |
br"Debian .dpkg' package management program") |
26110
2dcfb98c5314
hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents:
26109
diff
changeset
|
606 |
dh = matchoutput('dh --help', |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
607 |
br'dh is a part of debhelper.', ignorestatus=True) |
26110
2dcfb98c5314
hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents:
26109
diff
changeset
|
608 |
dh_py2 = matchoutput('dh_python2 --help', |
29140
47eab0cb72e3
hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents:
29107
diff
changeset
|
609 |
br'other supported Python versions') |
34399
200eadbcf0b0
hghave: check for debuild being installed as well
Kyle Lippincott <spectral@google.com>
parents:
34394
diff
changeset
|
610 |
# debuild comes from the 'devscripts' package, though you might want |
200eadbcf0b0
hghave: check for debuild being installed as well
Kyle Lippincott <spectral@google.com>
parents:
34394
diff
changeset
|
611 |
# the 'build-debs' package instead, which has a dependency on devscripts. |
200eadbcf0b0
hghave: check for debuild being installed as well
Kyle Lippincott <spectral@google.com>
parents:
34394
diff
changeset
|
612 |
debuild = matchoutput('debuild --help', |
200eadbcf0b0
hghave: check for debuild being installed as well
Kyle Lippincott <spectral@google.com>
parents:
34394
diff
changeset
|
613 |
br'to run debian/rules with given parameter') |
200eadbcf0b0
hghave: check for debuild being installed as well
Kyle Lippincott <spectral@google.com>
parents:
34394
diff
changeset
|
614 |
return dpkg and dh and dh_py2 and debuild |
26110
2dcfb98c5314
hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents:
26109
diff
changeset
|
615 |
|
34401
13d3f8aaed87
tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents:
34399
diff
changeset
|
616 |
@check("debdeps", |
13d3f8aaed87
tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents:
34399
diff
changeset
|
617 |
"debian build dependencies (run dpkg-checkbuilddeps in contrib/)") |
13d3f8aaed87
tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents:
34399
diff
changeset
|
618 |
def has_debdeps(): |
13d3f8aaed87
tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents:
34399
diff
changeset
|
619 |
# just check exit status (ignoring output) |
38009
e51c91c14a07
packaging: move contrib/debian to contrib/packaging/
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37415
diff
changeset
|
620 |
path = '%s/../contrib/packaging/debian/control' % os.environ['TESTDIR'] |
34401
13d3f8aaed87
tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents:
34399
diff
changeset
|
621 |
return matchoutput('dpkg-checkbuilddeps %s' % path, br'') |
13d3f8aaed87
tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents:
34399
diff
changeset
|
622 |
|
29867
b05a3a04f046
hghave: add demandimport checking
timeless <timeless@mozdev.org>
parents:
29866
diff
changeset
|
623 |
@check("demandimport", "demandimport enabled") |
b05a3a04f046
hghave: add demandimport checking
timeless <timeless@mozdev.org>
parents:
29866
diff
changeset
|
624 |
def has_demandimport(): |
34840
88624b40a9cb
hghave: disable demandimport when chg is running
Saurabh Singh <singhsrb@fb.com>
parents:
34696
diff
changeset
|
625 |
# chg disables demandimport intentionally for performance wins. |
88624b40a9cb
hghave: disable demandimport when chg is running
Saurabh Singh <singhsrb@fb.com>
parents:
34696
diff
changeset
|
626 |
return ((not has_chg()) and os.environ.get('HGDEMANDIMPORT') != 'disable') |
29867
b05a3a04f046
hghave: add demandimport checking
timeless <timeless@mozdev.org>
parents:
29866
diff
changeset
|
627 |
|
22093
45611a306f77
tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents:
21208
diff
changeset
|
628 |
@check("py3k", "running with Python 3.x") |
19931
8bbe208c1812
hghave: add "py3k" feature to check whether test runs with Python 3.x
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19930
diff
changeset
|
629 |
def has_py3k(): |
8bbe208c1812
hghave: add "py3k" feature to check whether test runs with Python 3.x
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
19930
diff
changeset
|
630 |
return 3 == sys.version_info[0] |
25859
1619563959b3
tests: disable test of buffer overflow in parsers.c if --pure
Yuya Nishihara <yuya@tcha.org>
parents:
25658
diff
changeset
|
631 |
|
28582
cdbc25306696
run-tests: add --with-python3 to define a Python 3 interpreter
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28383
diff
changeset
|
632 |
@check("py3exe", "a Python 3.x interpreter is available") |
cdbc25306696
run-tests: add --with-python3 to define a Python 3 interpreter
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28383
diff
changeset
|
633 |
def has_python3exe(): |
39351
4cfd1eebe6aa
hghave: move from requiring the PYTHON3 env var to looking for `python3`
Augie Fackler <augie@google.com>
parents:
38703
diff
changeset
|
634 |
return matchoutput('python3 -V', br'^Python 3.(5|6|7|8|9)') |
28582
cdbc25306696
run-tests: add --with-python3 to define a Python 3 interpreter
Gregory Szorc <gregory.szorc@gmail.com>
parents:
28383
diff
changeset
|
635 |
|
25859
1619563959b3
tests: disable test of buffer overflow in parsers.c if --pure
Yuya Nishihara <yuya@tcha.org>
parents:
25658
diff
changeset
|
636 |
@check("pure", "running with pure Python code") |
1619563959b3
tests: disable test of buffer overflow in parsers.c if --pure
Yuya Nishihara <yuya@tcha.org>
parents:
25658
diff
changeset
|
637 |
def has_pure(): |
27702
39122c2442cd
hghave: support HGMODULEPOLICY for pure
timeless <timeless@mozdev.org>
parents:
27298
diff
changeset
|
638 |
return any([ |
39122c2442cd
hghave: support HGMODULEPOLICY for pure
timeless <timeless@mozdev.org>
parents:
27298
diff
changeset
|
639 |
os.environ.get("HGMODULEPOLICY") == "py", |
39122c2442cd
hghave: support HGMODULEPOLICY for pure
timeless <timeless@mozdev.org>
parents:
27298
diff
changeset
|
640 |
os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure", |
39122c2442cd
hghave: support HGMODULEPOLICY for pure
timeless <timeless@mozdev.org>
parents:
27298
diff
changeset
|
641 |
]) |
26109
bad09bd22b6a
run-tests: add support for marking tests as very slow
Augie Fackler <augie@google.com>
parents:
26068
diff
changeset
|
642 |
|
32474
c2b7fb580794
tests: hint how to run slow tests when rejecting
Kyle Lippincott <spectral@google.com>
parents:
32245
diff
changeset
|
643 |
@check("slow", "allow slow tests (use --allow-slow-tests)") |
26109
bad09bd22b6a
run-tests: add support for marking tests as very slow
Augie Fackler <augie@google.com>
parents:
26068
diff
changeset
|
644 |
def has_slow(): |
bad09bd22b6a
run-tests: add support for marking tests as very slow
Augie Fackler <augie@google.com>
parents:
26068
diff
changeset
|
645 |
return os.environ.get('HGTEST_SLOW') == 'slow' |
26842
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
646 |
|
28383
e13e0e189990
hghave: improve description of Hypothesis
timeless <timeless@mozdev.org>
parents:
28126
diff
changeset
|
647 |
@check("hypothesis", "Hypothesis automated test generation") |
26842
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
648 |
def has_hypothesis(): |
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
649 |
try: |
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
650 |
import hypothesis |
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
651 |
hypothesis.given |
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
652 |
return True |
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
653 |
except ImportError: |
0f76c64f5cc3
testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents:
26145
diff
changeset
|
654 |
return False |
29843
00ca4f966ca6
hghave: add a check for unzip(1) that understands symlinks
Augie Fackler <augie@google.com>
parents:
29809
diff
changeset
|
655 |
|
00ca4f966ca6
hghave: add a check for unzip(1) that understands symlinks
Augie Fackler <augie@google.com>
parents:
29809
diff
changeset
|
656 |
@check("unziplinks", "unzip(1) understands and extracts symlinks") |
00ca4f966ca6
hghave: add a check for unzip(1) that understands symlinks
Augie Fackler <augie@google.com>
parents:
29809
diff
changeset
|
657 |
def unzip_understands_symlinks(): |
00ca4f966ca6
hghave: add a check for unzip(1) that understands symlinks
Augie Fackler <augie@google.com>
parents:
29809
diff
changeset
|
658 |
return matchoutput('unzip --help', br'Info-ZIP') |
30441
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
659 |
|
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
660 |
@check("zstd", "zstd Python module available") |
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
661 |
def has_zstd(): |
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
662 |
try: |
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
663 |
import mercurial.zstd |
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
664 |
mercurial.zstd.__version__ |
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
665 |
return True |
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
666 |
except ImportError: |
de48d3a0573a
hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents:
30297
diff
changeset
|
667 |
return False |
31964
ebaada96aec3
stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents:
31678
diff
changeset
|
668 |
|
ebaada96aec3
stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents:
31678
diff
changeset
|
669 |
@check("devfull", "/dev/full special file") |
ebaada96aec3
stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents:
31678
diff
changeset
|
670 |
def has_dev_full(): |
ebaada96aec3
stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents:
31678
diff
changeset
|
671 |
return os.path.exists('/dev/full') |
32726
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
672 |
|
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
673 |
@check("virtualenv", "Python virtualenv support") |
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
674 |
def has_virtualenv(): |
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
675 |
try: |
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
676 |
import virtualenv |
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
677 |
virtualenv.ACTIVATE_SH |
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
678 |
return True |
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
679 |
except ImportError: |
a6e4c4218b71
hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents:
32474
diff
changeset
|
680 |
return False |
32770
9cf74abd1252
hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents:
32726
diff
changeset
|
681 |
|
9cf74abd1252
hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents:
32726
diff
changeset
|
682 |
@check("fsmonitor", "running tests with fsmonitor") |
9cf74abd1252
hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents:
32726
diff
changeset
|
683 |
def has_fsmonitor(): |
9cf74abd1252
hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents:
32726
diff
changeset
|
684 |
return 'HGFSMONITOR_TESTS' in os.environ |
33697
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
685 |
|
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
686 |
@check("fuzzywuzzy", "Fuzzy string matching library") |
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
687 |
def has_fuzzywuzzy(): |
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
688 |
try: |
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
689 |
import fuzzywuzzy |
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
690 |
fuzzywuzzy.__version__ |
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
691 |
return True |
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
692 |
except ImportError: |
4d1e79945c2e
releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents:
33528
diff
changeset
|
693 |
return False |
35668
67cead0eb671
hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents:
35139
diff
changeset
|
694 |
|
67cead0eb671
hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents:
35139
diff
changeset
|
695 |
@check("clang-libfuzzer", "clang new enough to include libfuzzer") |
67cead0eb671
hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents:
35139
diff
changeset
|
696 |
def has_clang_libfuzzer(): |
36659
dc11f257ad1d
hghave: fix up clang-libfuzzer regex to be bytes
Augie Fackler <augie@google.com>
parents:
35668
diff
changeset
|
697 |
mat = matchoutput('clang --version', b'clang version (\d)') |
35668
67cead0eb671
hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents:
35139
diff
changeset
|
698 |
if mat: |
67cead0eb671
hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents:
35139
diff
changeset
|
699 |
# libfuzzer is new in clang 6 |
67cead0eb671
hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents:
35139
diff
changeset
|
700 |
return int(mat.group(1)) > 5 |
67cead0eb671
hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents:
35139
diff
changeset
|
701 |
return False |
36678
7834927f0243
tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
36659
diff
changeset
|
702 |
|
38236
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38009
diff
changeset
|
703 |
@check("clang-6.0", "clang 6.0 with version suffix (libfuzzer included)") |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38009
diff
changeset
|
704 |
def has_clang60(): |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38009
diff
changeset
|
705 |
return matchoutput('clang-6.0 --version', b'clang version 6\.') |
a6347ae6168d
test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents:
38009
diff
changeset
|
706 |
|
36678
7834927f0243
tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
36659
diff
changeset
|
707 |
@check("xdiff", "xdiff algorithm") |
7834927f0243
tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
36659
diff
changeset
|
708 |
def has_xdiff(): |
7834927f0243
tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
36659
diff
changeset
|
709 |
try: |
7834927f0243
tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
36659
diff
changeset
|
710 |
from mercurial import policy |
7834927f0243
tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
36659
diff
changeset
|
711 |
bdiff = policy.importmod('bdiff') |
36941
3f7bbce8fbaa
hghave: fix xdiff check on Python 3
Augie Fackler <augie@google.com>
parents:
36694
diff
changeset
|
712 |
return bdiff.xdiffblocks(b'', b'') == [(0, 0, 0, 0)] |
36694
1d06407d0ee9
hghave: remove unused "as ex" in exception block
Augie Fackler <augie@google.com>
parents:
36678
diff
changeset
|
713 |
except (ImportError, AttributeError): |
36678
7834927f0243
tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
36659
diff
changeset
|
714 |
return False |
37338
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
715 |
|
37342
4e6a6d0dccee
tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37338
diff
changeset
|
716 |
@check('extraextensions', 'whether tests are running with extra extensions') |
4e6a6d0dccee
tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37338
diff
changeset
|
717 |
def has_extraextensions(): |
4e6a6d0dccee
tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37338
diff
changeset
|
718 |
return 'HGTESTEXTRAEXTENSIONS' in os.environ |
4e6a6d0dccee
tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37338
diff
changeset
|
719 |
|
37338
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
720 |
def getrepofeatures(): |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
721 |
"""Obtain set of repository features in use. |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
722 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
723 |
HGREPOFEATURES can be used to define or remove features. It contains |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
724 |
a space-delimited list of feature strings. Strings beginning with ``-`` |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
725 |
mean to remove. |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
726 |
""" |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
727 |
# Default list provided by core. |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
728 |
features = { |
37346
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37342
diff
changeset
|
729 |
'bundlerepo', |
37338
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
730 |
'revlogstore', |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
731 |
'fncache', |
37338
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
732 |
} |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
733 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
734 |
# Features that imply other features. |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
735 |
implies = { |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
736 |
'simplestore': ['-revlogstore', '-bundlerepo', '-fncache'], |
37338
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
737 |
} |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
738 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
739 |
for override in os.environ.get('HGREPOFEATURES', '').split(' '): |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
740 |
if not override: |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
741 |
continue |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
742 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
743 |
if override.startswith('-'): |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
744 |
if override[1:] in features: |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
745 |
features.remove(override[1:]) |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
746 |
else: |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
747 |
features.add(override) |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
748 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
749 |
for imply in implies.get(override, []): |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
750 |
if imply.startswith('-'): |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
751 |
if imply[1:] in features: |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
752 |
features.remove(imply[1:]) |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
753 |
else: |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
754 |
features.add(imply) |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
755 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
756 |
return features |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
757 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
758 |
@check('reporevlogstore', 'repository using the default revlog store') |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
759 |
def has_reporevlogstore(): |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
760 |
return 'revlogstore' in getrepofeatures() |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
761 |
|
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
762 |
@check('reposimplestore', 'repository using simple storage extension') |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
763 |
def has_reposimplestore(): |
cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36942
diff
changeset
|
764 |
return 'simplestore' in getrepofeatures() |
37346
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37342
diff
changeset
|
765 |
|
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37342
diff
changeset
|
766 |
@check('repobundlerepo', 'whether we can open bundle files as repos') |
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37342
diff
changeset
|
767 |
def has_repobundlerepo(): |
45a4799174a1
tests: disallow using simple store repo with bundlerepo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37342
diff
changeset
|
768 |
return 'bundlerepo' in getrepofeatures() |
37415
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
769 |
|
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
770 |
@check('repofncache', 'repository has an fncache') |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
771 |
def has_repofncache(): |
c2c8962a9465
simplestore: use a custom store for the simple store repo
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37346
diff
changeset
|
772 |
return 'fncache' in getrepofeatures() |