annotate tests/hghave.py @ 53040:cdd7bf612c7b stable tip

bundle-spec: properly format boolean parameter (issue6960) This was breaking automatic clone bundle generation. This changeset fixes it and add a test to catch it in the future.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 11 Mar 2025 02:29:42 +0100
parents 771706c5acfb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26137
99e8a9ff1f5f hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents: 26111
diff changeset
1 import os
5252
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
2 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
3 import socket
26137
99e8a9ff1f5f hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents: 26111
diff changeset
4 import stat
99e8a9ff1f5f hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents: 26111
diff changeset
5 import subprocess
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
6 import sys
5072
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
7 import tempfile
4881
c51c9bc4579d Add hghave utility and run-tests.py support.
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
8
51712
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
9 try:
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
10 from setuptools.extern.packaging.version import Version
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
11 except ImportError:
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
12 from distutils.version import StrictVersion as Version
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
13
5090
bf60e4bd6672 hghave: prefix temporary files with "hg-hghave-"
Patrick Mezard <pmezard@gmail.com>
parents: 5084
diff changeset
14 tempprefix = 'hg-hghave-'
bf60e4bd6672 hghave: prefix temporary files with "hg-hghave-"
Patrick Mezard <pmezard@gmail.com>
parents: 5084
diff changeset
15
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
16 checks = {
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
17 "true": (lambda: True, "yak shaving"),
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
18 "false": (lambda: False, "nail clipper"),
46163
ebcc52046096 hghave: add some official category for known-bad and missing-good output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46098
diff changeset
19 "known-bad-output": (lambda: True, "use for currently known bad output"),
ebcc52046096 hghave: add some official category for known-bad and missing-good output
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46098
diff changeset
20 "missing-correct-output": (lambda: False, "use for missing good output"),
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
21 }
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
22
41013
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
23 try:
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
24 import msvcrt
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
25
41013
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
26 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
27 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
28 except ImportError:
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
29 pass
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
30
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
31 stdout = getattr(sys.stdout, 'buffer', sys.stdout)
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
32 stderr = getattr(sys.stderr, 'buffer', sys.stderr)
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
33
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
34
50250
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
35 def _sys2bytes(p):
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
36 if p is None:
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
37 return p
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
38 return p.encode('utf-8')
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
39
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
40
50250
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
41 def _bytes2sys(p):
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
42 if p is None:
39775
aeb2812f304d py3: fix a type error in hghave.has_hardlink
Matt Harbison <matt_harbison@yahoo.com>
parents: 39664
diff changeset
43 return p
50250
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
44 return p.decode('utf-8')
39775
aeb2812f304d py3: fix a type error in hghave.has_hardlink
Matt Harbison <matt_harbison@yahoo.com>
parents: 39664
diff changeset
45
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
46
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
47 def check(name, desc):
28757
93bf61913f33 hghave: add docstring for check
timeless <timeless@mozdev.org>
parents: 28756
diff changeset
48 """Registers a check function for a feature."""
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
49
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
50 def decorator(func):
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
51 checks[name] = (func, desc)
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
52 return func
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
53
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
54 return decorator
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
55
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
56
28758
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
57 def checkvers(name, desc, vers):
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
58 """Registers a check function for each of a series of versions.
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
59
43113
37af48031d6f hghave: document format for version feature checks as <name><vers>, no dots
Kyle Lippincott <spectral@google.com>
parents: 43095
diff changeset
60 vers can be a list or an iterator.
37af48031d6f hghave: document format for version feature checks as <name><vers>, no dots
Kyle Lippincott <spectral@google.com>
parents: 43095
diff changeset
61
37af48031d6f hghave: document format for version feature checks as <name><vers>, no dots
Kyle Lippincott <spectral@google.com>
parents: 43095
diff changeset
62 Produces a series of feature checks that have the form <name><vers> without
37af48031d6f hghave: document format for version feature checks as <name><vers>, no dots
Kyle Lippincott <spectral@google.com>
parents: 43095
diff changeset
63 any punctuation (even if there's punctuation in 'vers'; i.e. this produces
37af48031d6f hghave: document format for version feature checks as <name><vers>, no dots
Kyle Lippincott <spectral@google.com>
parents: 43095
diff changeset
64 'py38', not 'py3.8' or 'py-38')."""
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
65
28758
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
66 def decorator(func):
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
67 def funcv(v):
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
68 def f():
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
69 return func(v)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
70
28758
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
71 return f
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
72
28758
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
73 for v in vers:
51375
7d313b259169 hghave: use strings instead of floats for version numbers passed to checkvers
Manuel Jacob <me@manueljacob.de>
parents: 51372
diff changeset
74 assert isinstance(v, str)
28758
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
75 f = funcv(v)
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
76 checks['%s%s' % (name, v.replace('.', ''))] = (f, desc % v)
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
77 return func
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
78
28758
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
79 return decorator
44e076a12bd3 hghave: add checkvers function
timeless <timeless@mozdev.org>
parents: 28757
diff changeset
80
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
81
26067
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
82 def checkfeatures(features):
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
83 result = {
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
84 'error': [],
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
85 'missing': [],
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
86 'skipped': [],
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
87 }
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
88
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
89 for feature in features:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
90 negate = feature.startswith('no-')
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
91 if negate:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
92 feature = feature[3:]
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
93
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
94 if feature not in checks:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
95 result['missing'].append(feature)
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
96 continue
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
97
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
98 check, desc = checks[feature]
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
99 try:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
100 available = check()
47313
338623a2ebf2 hghave: make error output easier to diagnose
Augie Fackler <augie@google.com>
parents: 47312
diff changeset
101 except Exception as e:
338623a2ebf2 hghave: make error output easier to diagnose
Augie Fackler <augie@google.com>
parents: 47312
diff changeset
102 result['error'].append('hghave check %s failed: %r' % (feature, e))
26067
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
103 continue
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
104
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
105 if not negate and not available:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
106 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
107 elif negate and available:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
108 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
109
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
110 return result
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
111
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
112
26068
05e7f57c74ac hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26067
diff changeset
113 def require(features):
26067
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
114 """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
115 result = checkfeatures(features)
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
116
26068
05e7f57c74ac hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26067
diff changeset
117 for missing in result['missing']:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
118 stderr.write(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
119 ('skipped: unknown feature: %s\n' % missing).encode('utf-8')
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
120 )
26068
05e7f57c74ac hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26067
diff changeset
121 for msg in result['skipped']:
41013
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
122 stderr.write(('skipped: %s\n' % msg).encode('utf-8'))
26068
05e7f57c74ac hghave: remove quiet option
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26067
diff changeset
123 for msg in result['error']:
41013
87c98ffbc8c7 py3: use bytes stdout in hghave.py
Matt Harbison <matt_harbison@yahoo.com>
parents: 40427
diff changeset
124 stderr.write(('%s\n' % msg).encode('utf-8'))
26067
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
125
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
126 if result['missing']:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
127 sys.exit(2)
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
128
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
129 if result['skipped'] or result['error']:
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
130 sys.exit(1)
8107c308ff22 hghave: move feature checking into hghave.py
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25859
diff changeset
131
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
132
52572
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
133 def environ():
46870
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
134 # Tests on Windows have to fake USERPROFILE to point to the test area so
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
135 # that `~` is properly expanded on py3.8+. However, some tools like black
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
136 # make calls that need the real USERPROFILE in order to run `foo --version`.
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
137 env = os.environ
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
138 if os.name == 'nt':
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
139 env = os.environ.copy()
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
140 env['USERPROFILE'] = env['REALUSERPROFILE']
52572
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
141 return env
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
142
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
143
52699
e1c5d823287b hghave: make the `ignorestatus` argument to `matchoutput()` a bool
Matt Harbison <matt_harbison@yahoo.com>
parents: 52698
diff changeset
144 def matchoutput(cmd, regexp: bytes, ignorestatus: bool = False):
52572
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
145 """Return the match object if cmd executes successfully and its output
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
146 is matched by the supplied regular expression.
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
147 """
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
148 env = environ()
46870
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
149
5252
c0281c6b40b0 hghave: wrap command output matching
Patrick Mezard <pmezard@gmail.com>
parents: 5218
diff changeset
150 r = re.compile(regexp)
41388
fabb0224a599 hghave: let OSError with ENOENT through like any other
Martin von Zweigbergk <martinvonz@google.com>
parents: 41013
diff changeset
151 p = subprocess.Popen(
46870
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
152 cmd,
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
153 shell=True,
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
154 stdout=subprocess.PIPE,
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
155 stderr=subprocess.STDOUT,
41d43d12c2c4 tests: restore the ability to run `black` on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46737
diff changeset
156 env=env,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
157 )
37852
6fb76897e066 hghave: avoid a deadlock reading the child process's output
Matt Harbison <matt_harbison@yahoo.com>
parents: 37415
diff changeset
158 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
159 ret = p.returncode
26137
99e8a9ff1f5f hghave: use subprocess instead of os.popen
Augie Fackler <augie@google.com>
parents: 26111
diff changeset
160 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
161
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
162
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
163 @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
164 def has_baz():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
165 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
166
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
167
47383
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
168 @check("bzr", "Breezy library and executable version >= 3.1")
7053
209ef5f3534c convert: add bzr source
Marek Kubica <marek@xivilization.net>
parents: 6998
diff changeset
169 def has_bzr():
7061
8b874f8cd29f tests: check for bzr support by importing bzrlib
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7053
diff changeset
170 try:
47383
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
171 # Test the Breezy python lib
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
172 import breezy
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
173 import breezy.bzr.bzrdir
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
174 import breezy.errors
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
175 import breezy.revision
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
176 import breezy.revisionspec
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
177
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
178 del breezy.revisionspec
47383
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
179 if breezy.__doc__ is None or breezy.version_info[:2] < (3, 1):
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
180 return False
29907
fe81c953f369 hghave: fix has_bzr() to not try to import RevisionSpec as module
Yuya Nishihara <yuya@tcha.org>
parents: 29877
diff changeset
181 except (AttributeError, ImportError):
7061
8b874f8cd29f tests: check for bzr support by importing bzrlib
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7053
diff changeset
182 return False
47383
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
183 # Test the executable
26127236b229 convert-bazaar: use breezy package instead of old bzr one
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47382
diff changeset
184 return matchoutput('brz --version 2>&1', br'Breezy \(brz\) ')
8126
13b36eb14324 convert/bzr: handle files replaced by directories (issue1623)
Patrick Mezard <pmezard@gmail.com>
parents: 7823
diff changeset
185
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
186
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
187 @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
188 def has_chg():
47586
a8e33ab50c4f run-tests: use more explicit signaling for `chg`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47383
diff changeset
189 return 'CHG_INSTALLED_AS_HG' in os.environ
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
190
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
191
46737
78e6700ab009 tests: Add `rhg` and `no-rhg` for #require and #if in .t files
Simon Sapin <simon.sapin@octobus.net>
parents: 46643
diff changeset
192 @check("rhg", "running with rhg as 'hg'")
78e6700ab009 tests: Add `rhg` and `no-rhg` for #require and #if in .t files
Simon Sapin <simon.sapin@octobus.net>
parents: 46643
diff changeset
193 def has_rhg():
78e6700ab009 tests: Add `rhg` and `no-rhg` for #require and #if in .t files
Simon Sapin <simon.sapin@octobus.net>
parents: 46643
diff changeset
194 return 'RHG_INSTALLED_AS_HG' in os.environ
78e6700ab009 tests: Add `rhg` and `no-rhg` for #require and #if in .t files
Simon Sapin <simon.sapin@octobus.net>
parents: 46643
diff changeset
195
78e6700ab009 tests: Add `rhg` and `no-rhg` for #require and #if in .t files
Simon Sapin <simon.sapin@octobus.net>
parents: 46643
diff changeset
196
47826
94158c541c74 pyoxidized: add a `pyoxidizer` hghave keyword for line matching
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47586
diff changeset
197 @check("pyoxidizer", "running with pyoxidizer build as 'hg'")
49289
223d55086d7c cleanup: rename some functions to avoid redefinitions
Manuel Jacob <me@manueljacob.de>
parents: 49287
diff changeset
198 def has_pyoxidizer():
47826
94158c541c74 pyoxidized: add a `pyoxidizer` hghave keyword for line matching
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47586
diff changeset
199 return 'PYOXIDIZED_INSTALLED_AS_HG' in os.environ
94158c541c74 pyoxidized: add a `pyoxidizer` hghave keyword for line matching
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47586
diff changeset
200
94158c541c74 pyoxidized: add a `pyoxidizer` hghave keyword for line matching
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47586
diff changeset
201
49618
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
202 @check(
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
203 "pyoxidizer-in-memory",
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
204 "running with pyoxidizer build as 'hg' with embedded resources",
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
205 )
49644
5df6d4f06a8f hghave: make different has_pyoxidizer functions have different names
Anton Shestakov <av6@dwimlabs.net>
parents: 49643
diff changeset
206 def has_pyoxidizer_mem():
49618
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
207 return 'PYOXIDIZED_IN_MEMORY_RSRC' in os.environ
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
208
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
209
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
210 @check(
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
211 "pyoxidizer-in-filesystem",
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
212 "running with pyoxidizer build as 'hg' with external resources",
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
213 )
49644
5df6d4f06a8f hghave: make different has_pyoxidizer functions have different names
Anton Shestakov <av6@dwimlabs.net>
parents: 49643
diff changeset
214 def has_pyoxidizer_fs():
49618
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
215 return 'PYOXIDIZED_FILESYSTEM_RSRC' in os.environ
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
216
a2356e15200a hghave: add predicates for embedded and filesystem pyoxidizer resources
Matt Harbison <matt_harbison@yahoo.com>
parents: 49612
diff changeset
217
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
218 @check("cvs", "cvs client/server")
5302
961876838de0 hghave: detect cvs and cvsps availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
219 def has_cvs():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
220 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
221 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
222
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
223
28756
45954a251a40 hghave: update cvs112 description
timeless <timeless@mozdev.org>
parents: 28591
diff changeset
224 @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
225 def has_cvs112():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
226 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
227 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
228
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
229
28796
08a686a4a0a2 hghave: add cvsnt
timeless <timeless@mozdev.org>
parents: 28779
diff changeset
230 @check("cvsnt", "cvsnt client/server")
08a686a4a0a2 hghave: add cvsnt
timeless <timeless@mozdev.org>
parents: 28779
diff changeset
231 def has_cvsnt():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
232 re = br'Concurrent Versions System \(CVSNT\) (\d+).(\d+).*\(client/server\)'
28796
08a686a4a0a2 hghave: add cvsnt
timeless <timeless@mozdev.org>
parents: 28779
diff changeset
233 return matchoutput('cvsnt --version 2>&1', re)
08a686a4a0a2 hghave: add cvsnt
timeless <timeless@mozdev.org>
parents: 28779
diff changeset
234
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
235
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
236 @check("darcs", "darcs client")
5410
2daecf3d2582 hghave: detect darcs client
Patrick Mezard <pmezard@gmail.com>
parents: 5409
diff changeset
237 def has_darcs():
30311
d4db88a26ad5 hghave: check darcs version more strictly
Yuya Nishihara <yuya@tcha.org>
parents: 30242
diff changeset
238 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
239
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
240
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
241 @check("mtn", "monotone client (>= 1.0)")
6372
8f79820443a4 Add a test for monotone conversion
Patrick Mezard <pmezard@gmail.com>
parents: 6355
diff changeset
242 def has_mtn():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
243 return matchoutput('mtn --version', br'monotone', True) and not matchoutput(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
244 'mtn --version', br'monotone 0\.', True
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
245 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
246
6372
8f79820443a4 Add a test for monotone conversion
Patrick Mezard <pmezard@gmail.com>
parents: 6355
diff changeset
247
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
248 @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
249 def has_eol_in_paths():
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
250 try:
16968
456f457e376d tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 16966
diff changeset
251 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
252 os.close(fd)
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
253 os.remove(path)
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
254 return True
52665
24ee91ba9aa8 pyupgrade: drop usage of py3 aliases for `OSError`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52573
diff changeset
255 except OSError:
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
256 return False
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
257
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
258
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
259 @check("execbit", "executable bit")
5072
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
260 def has_executablebit():
7e2385a31933 hghave: detect executable permission availability.
Patrick Mezard <pmezard@gmail.com>
parents: 5070
diff changeset
261 try:
16320
e11ab387e89c tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 16319
diff changeset
262 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
263 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
264 try:
e11ab387e89c tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 16319
diff changeset
265 os.close(fh)
25658
e93036747902 global: mass rewrite to use modern octal syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25413
diff changeset
266 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
267 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
268 os.chmod(fn, m ^ EXECFLAGS)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
269 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
270 finally:
e11ab387e89c tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 16319
diff changeset
271 os.unlink(fn)
52665
24ee91ba9aa8 pyupgrade: drop usage of py3 aliases for `OSError`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52573
diff changeset
272 except OSError:
16320
e11ab387e89c tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 16319
diff changeset
273 # 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
274 return False
e11ab387e89c tests: make hghave handle exec bit on Linux with vfat
Matt Mackall <mpm@selenic.com>
parents: 16319
diff changeset
275 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
276
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
277
48312
7dd48d5da64f tests: add guard check for suid support
pacien <pacien.trangirard@pacien.net>
parents: 47904
diff changeset
278 @check("suidbit", "setuid and setgid bit")
7dd48d5da64f tests: add guard check for suid support
pacien <pacien.trangirard@pacien.net>
parents: 47904
diff changeset
279 def has_suidbit():
48341
f21e7748c257 hghave: fix the check for suid on platforms lacking support
Matt Harbison <matt_harbison@yahoo.com>
parents: 48318
diff changeset
280 if (
f21e7748c257 hghave: fix the check for suid on platforms lacking support
Matt Harbison <matt_harbison@yahoo.com>
parents: 48318
diff changeset
281 getattr(os, "statvfs", None) is None
f21e7748c257 hghave: fix the check for suid on platforms lacking support
Matt Harbison <matt_harbison@yahoo.com>
parents: 48318
diff changeset
282 or getattr(os, "ST_NOSUID", None) is None
f21e7748c257 hghave: fix the check for suid on platforms lacking support
Matt Harbison <matt_harbison@yahoo.com>
parents: 48318
diff changeset
283 ):
48312
7dd48d5da64f tests: add guard check for suid support
pacien <pacien.trangirard@pacien.net>
parents: 47904
diff changeset
284 return False
7dd48d5da64f tests: add guard check for suid support
pacien <pacien.trangirard@pacien.net>
parents: 47904
diff changeset
285 return bool(os.statvfs('.').f_flag & os.ST_NOSUID)
7dd48d5da64f tests: add guard check for suid support
pacien <pacien.trangirard@pacien.net>
parents: 47904
diff changeset
286
7dd48d5da64f tests: add guard check for suid support
pacien <pacien.trangirard@pacien.net>
parents: 47904
diff changeset
287
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
288 @check("icasefs", "case insensitive file system")
6806
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
289 def has_icasefs():
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
290 # Stolen from mercurial.util
16968
456f457e376d tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 16966
diff changeset
291 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
6806
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
292 os.close(fd)
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
293 try:
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
294 s1 = os.stat(path)
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
295 d, b = os.path.split(path)
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
296 p2 = os.path.join(d, b.upper())
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
297 if path == p2:
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
298 p2 = os.path.join(d, b.lower())
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
299 try:
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
300 s2 = os.stat(p2)
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
301 return s2 == s1
16688
cfb6682961b8 cleanup: replace naked excepts with more specific ones
Brodie Rao <brodie@sf.io>
parents: 16685
diff changeset
302 except OSError:
6806
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
303 return False
2134d6c09432 Add test for case folding issues
Patrick Mezard <pmezard@gmail.com>
parents: 6626
diff changeset
304 finally:
6998
ddfcefab8b97 merge with -stable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6806 6996
diff changeset
305 os.remove(path)
ddfcefab8b97 merge with -stable
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 6806 6996
diff changeset
306
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
307
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
308 @check("fifo", "named pipes")
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
309 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
310 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
311 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
312 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
313 try:
6d1673107143 tests/hghave: test that a fifo actually can be created on the filesystem
Mads Kiilerich <mads@kiilerich.com>
parents: 16968
diff changeset
314 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
315 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
316 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
317 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
318 return False
5074
e86788af599a hghave: detect support for EOL in paths.
Patrick Mezard <pmezard@gmail.com>
parents: 5072
diff changeset
319
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
320
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
321 @check("killdaemons", 'killdaemons.py support')
17467
448d0c452140 test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents: 17016
diff changeset
322 def has_killdaemons():
448d0c452140 test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents: 17016
diff changeset
323 return True
448d0c452140 test-http-branchmap: enable on Windows
Patrick Mezard <patrick@mezard.eu>
parents: 17016
diff changeset
324
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
325
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
326 @check("cacheable", "cacheable filesystem")
14927
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
327 def has_cacheable_fs():
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
328 from mercurial import util
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
329
16968
456f457e376d tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 16966
diff changeset
330 fd, path = tempfile.mkstemp(dir='.', prefix=tempprefix)
14927
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
331 os.close(fd)
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
332 try:
50249
a7cbb626ec3f hghave: byteify a path passed to a core API
Matt Harbison <matt_harbison@yahoo.com>
parents: 49645
diff changeset
333 return util.cachestat(_sys2bytes(path)).cacheable()
14927
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
334 finally:
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
335 os.remove(path)
2aa3e07b2f07 posix, windows: introduce cachestat
Idan Kamara <idankk86@gmail.com>
parents: 14550
diff changeset
336
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
337
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
338 @check("lsprof", "python lsprof module")
5099
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
339 def has_lsprof():
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
340 try:
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
341 import _lsprof
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
342
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
343 del _lsprof # silence unused import warning
5099
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
344 return True
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
345 except ImportError:
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
346 return False
105d4cf7ec24 Test --time, --profile and --lsprof
Patrick Mezard <pmezard@gmail.com>
parents: 5092
diff changeset
347
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
348
44325
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
349 def _gethgversion():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
350 m = matchoutput('hg --version --quiet 2>&1', br'(\d+)\.(\d+)')
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
351 if not m:
52700
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
352 return 0, 0
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
353 return int(m.group(1)), int(m.group(2))
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
354
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
355
44325
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
356 _hgversion = None
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
357
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
358
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
359 def gethgversion():
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
360 global _hgversion
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
361 if _hgversion is None:
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
362 _hgversion = _gethgversion()
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
363 return _hgversion
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
364
e48a996d12bc hghave: cache the result of gethgversion
Julien Cristau <jcristau@mozilla.com>
parents: 44311
diff changeset
365
51375
7d313b259169 hghave: use strings instead of floats for version numbers passed to checkvers
Manuel Jacob <me@manueljacob.de>
parents: 51372
diff changeset
366 @checkvers(
7d313b259169 hghave: use strings instead of floats for version numbers passed to checkvers
Manuel Jacob <me@manueljacob.de>
parents: 51372
diff changeset
367 "hg", "Mercurial >= %s", ['%d.%d' % divmod(x, 10) for x in range(9, 99)]
7d313b259169 hghave: use strings instead of floats for version numbers passed to checkvers
Manuel Jacob <me@manueljacob.de>
parents: 51372
diff changeset
368 )
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
369 def has_hg_range(v):
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
370 major, minor = v.split('.')[0:2]
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
371 return gethgversion() >= (int(major), int(minor))
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
372
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
373
44483
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
374 @check("rust", "Using the Rust extensions")
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
375 def has_rust():
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
376 """Check is the mercurial currently running is using some rust code"""
44644
51ffb2a6c08a tests: pass str to matchoutput()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44510
diff changeset
377 cmd = 'hg debuginstall --quiet 2>&1'
44483
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
378 match = br'checking module policy \(([^)]+)\)'
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
379 policy = matchoutput(cmd, match)
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
380 if not policy:
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
381 return False
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
382 return b'rust' in policy.group(1)
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
383
75ada5fe9b62 hghave: add a `rust` keyword to detect the use of compiled rust code
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44479
diff changeset
384
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
385 @check("hg08", "Mercurial >= 0.8")
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
386 def has_hg08():
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
387 if checks["hg09"][0]():
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
388 return True
52698
6ed726d1cd16 hghave: byteify the `regexp` arg to `matchoutput()`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52665
diff changeset
389 return matchoutput('hg help annotate 2>&1', b'--date')
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
390
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
391
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
392 @check("hg07", "Mercurial >= 0.7")
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
393 def has_hg07():
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
394 if checks["hg08"][0]():
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
395 return True
52698
6ed726d1cd16 hghave: byteify the `regexp` arg to `matchoutput()`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52665
diff changeset
396 return matchoutput(
6ed726d1cd16 hghave: byteify the `regexp` arg to `matchoutput()`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52665
diff changeset
397 'hg --version --quiet 2>&1', b'Mercurial Distributed SCM'
6ed726d1cd16 hghave: byteify the `regexp` arg to `matchoutput()`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52665
diff changeset
398 )
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
399
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
400
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
401 @check("hg06", "Mercurial >= 0.6")
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
402 def has_hg06():
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
403 if checks["hg07"][0]():
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
404 return True
52698
6ed726d1cd16 hghave: byteify the `regexp` arg to `matchoutput()`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52665
diff changeset
405 return matchoutput('hg --version --quiet 2>&1', b'Mercurial version')
28761
be13a0fb84e8 hghave: add hg06..hg39
timeless <timeless@mozdev.org>
parents: 28760
diff changeset
406
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
407
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
408 @check("gettext", "GNU Gettext (msgfmt)")
13442
bb107a31820e test-i18n: make test conditional on msgfmt availability
Martin Geisler <mg@lazybytes.net>
parents: 13418
diff changeset
409 def has_gettext():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
410 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
411
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
412
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
413 @check("git", "git command line client")
5218
4fa0f2dff643 hghave: detect git availability
Patrick Mezard <pmezard@gmail.com>
parents: 5103
diff changeset
414 def has_git():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
415 return matchoutput('git --version 2>&1', br'^git version')
5218
4fa0f2dff643 hghave: detect git availability
Patrick Mezard <pmezard@gmail.com>
parents: 5103
diff changeset
416
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
417
32919
559db66dead5 hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents: 32874
diff changeset
418 def getgitversion():
559db66dead5 hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents: 32874
diff changeset
419 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: 32874
diff changeset
420 if not m:
52700
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
421 return 0, 0
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
422 return int(m.group(1)), int(m.group(2))
32919
559db66dead5 hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents: 32874
diff changeset
423
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
424
44495
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
425 @check("pygit2", "pygit2 Python library")
49289
223d55086d7c cleanup: rename some functions to avoid redefinitions
Manuel Jacob <me@manueljacob.de>
parents: 49287
diff changeset
426 def has_pygit2():
44495
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
427 try:
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
428 import pygit2
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
429
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
430 del pygit2 # silence unused import
44495
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
431 return True
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
432 except ImportError:
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
433 return False
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
434
2e464925f662 hghave: add a check for pygit2
Martin von Zweigbergk <martinvonz@google.com>
parents: 44483
diff changeset
435
35160
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
436 # https://github.com/git-lfs/lfs-test-server
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
437 @check("lfs-test-server", "git-lfs test server")
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
438 def has_lfsserver():
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
439 exe = 'lfs-test-server'
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
440 if has_windows():
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
441 exe = 'lfs-test-server.exe'
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
442 return any(
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
443 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: 35066
diff changeset
444 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: 35066
diff changeset
445 )
a2e927ded455 hghave: add a check for lfs-test-server
Matt Harbison <matt_harbison@yahoo.com>
parents: 35066
diff changeset
446
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
447
51375
7d313b259169 hghave: use strings instead of floats for version numbers passed to checkvers
Manuel Jacob <me@manueljacob.de>
parents: 51372
diff changeset
448 @checkvers("git", "git client (with ext::sh support) version >= %s", ('1.9',))
32919
559db66dead5 hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents: 32874
diff changeset
449 def has_git_range(v):
559db66dead5 hghave: add has_git_range for testing if git understands ext::sh
Sean Farley <sean@farley.io>
parents: 32874
diff changeset
450 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: 32874
diff changeset
451 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: 32874
diff changeset
452
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
453
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
454 @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
455 def has_docutils():
cbe400a8e217 doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents: 9819
diff changeset
456 try:
28779
0970ebec29b4 hghave: replace relative import of docutils.core
Yuya Nishihara <yuya@tcha.org>
parents: 28761
diff changeset
457 import docutils.core
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
458
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
459 del docutils.core # silence unused import
10971
cbe400a8e217 doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents: 9819
diff changeset
460 return True
cbe400a8e217 doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents: 9819
diff changeset
461 except ImportError:
cbe400a8e217 doc: add generic frontend to rst2man and rst2html
Martin Geisler <mg@aragost.com>
parents: 9819
diff changeset
462 return False
9446
57d682d7d2da test-gendoc: test documentation generation
Martin Geisler <mg@lazybytes.net>
parents: 9395
diff changeset
463
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
464
14050
9e8a9d45945c subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents: 13543
diff changeset
465 def getsvnversion():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
466 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
467 if not m:
52700
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
468 return 0, 0
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
469 return int(m.group(1)), int(m.group(2))
14050
9e8a9d45945c subrepo: handle svn tracked/unknown directory collisions
Patrick Mezard <pmezard@gmail.com>
parents: 13543
diff changeset
470
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
471
51375
7d313b259169 hghave: use strings instead of floats for version numbers passed to checkvers
Manuel Jacob <me@manueljacob.de>
parents: 51372
diff changeset
472 @checkvers("svn", "subversion client and admin tools >= %s", ('1.3', '1.5'))
28759
2348ca49aaee hghave: replace has_svn13/has_svn15 with checkvers
timeless <timeless@mozdev.org>
parents: 28758
diff changeset
473 def has_svn_range(v):
2348ca49aaee hghave: replace has_svn13/has_svn15 with checkvers
timeless <timeless@mozdev.org>
parents: 28758
diff changeset
474 major, minor = v.split('.')[0:2]
2348ca49aaee hghave: replace has_svn13/has_svn15 with checkvers
timeless <timeless@mozdev.org>
parents: 28758
diff changeset
475 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
476
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
477
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
478 @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
479 def has_svn():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
480 return matchoutput('svn --version 2>&1', br'^svn, version') and matchoutput(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
481 'svnadmin --version 2>&1', br'^svnadmin, version'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
482 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
483
5253
d82ebcdf20e1 hghave: detect subversion client and admin tools availability
Patrick Mezard <pmezard@gmail.com>
parents: 5252
diff changeset
484
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
485 @check("svn-bindings", "subversion python bindings")
5254
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
486 def has_svn_bindings():
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
487 try:
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
488 import svn.core
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
489
7315
408cf9eb9e5d tests: run svn tests only with svn bindings >1.3
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7061
diff changeset
490 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
491 if version < (1, 4):
408cf9eb9e5d tests: run svn tests only with svn bindings >1.3
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 7061
diff changeset
492 return False
5254
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
493 return True
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
494 except ImportError:
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
495 return False
d61e98a82cee hghave: detect subversion bindings availability
Patrick Mezard <pmezard@gmail.com>
parents: 5253
diff changeset
496
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
497
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
498 @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
499 def has_p4():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
500 return matchoutput('p4 -V', br'Rev\. P4/') and matchoutput(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
501 'p4d -V', br'Rev\. P4D/'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
502 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
503
7823
11efa41037e2 convert: Perforce source for conversion to Mercurial
Frank Kingswood <frank@kingswood-consulting.co.uk>
parents: 7773
diff changeset
504
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
505 @check("symlink", "symbolic links")
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
506 def has_symlink():
43507
6792da448437 hghave: disallow symlinks on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 43412
diff changeset
507 # mercurial.windows.checklink() is a hard 'no' at the moment
6792da448437 hghave: disallow symlinks on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 43412
diff changeset
508 if os.name == 'nt' or 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
509 return False
16968
456f457e376d tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 16966
diff changeset
510 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
511 try:
ac0da5caebec tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 15568
diff changeset
512 os.symlink(".", name)
ac0da5caebec tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 15568
diff changeset
513 os.unlink(name)
ac0da5caebec tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 15568
diff changeset
514 return True
ac0da5caebec tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 15568
diff changeset
515 except (OSError, AttributeError):
ac0da5caebec tests: teach hghave to actually test for symlink support
Matt Mackall <mpm@selenic.com>
parents: 15568
diff changeset
516 return False
5409
190c234c8fa0 hghave: reorder check functions and entries
Patrick Mezard <pmezard@gmail.com>
parents: 5308
diff changeset
517
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
518
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
519 @check("hardlink", "hardlinks")
16971
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
520 def has_hardlink():
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
521 from mercurial import util
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
522
16971
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
523 fh, fn = tempfile.mkstemp(dir='.', prefix=tempprefix)
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
524 os.close(fh)
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
525 name = tempfile.mktemp(dir='.', prefix=tempprefix)
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
526 try:
44468
55c443fcb4fc tests: rename _bytespath() to _sys2bytes() and _strpath() to _sys2str()
Manuel Jacob <me@manueljacob.de>
parents: 44325
diff changeset
527 util.oslink(_sys2bytes(fn), _sys2bytes(name))
25090
252412e24551 hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 24290
diff changeset
528 os.unlink(name)
252412e24551 hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 24290
diff changeset
529 return True
252412e24551 hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 24290
diff changeset
530 except OSError:
252412e24551 hghave: use try/except/finally
Matt Mackall <mpm@selenic.com>
parents: 24290
diff changeset
531 return False
16971
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
532 finally:
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
533 os.unlink(fn)
8aeb2f1ae94c tests: introduce hghave hardlinks
Mads Kiilerich <mads@kiilerich.com>
parents: 16970
diff changeset
534
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
535
31582
07f0cddb0594 hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents: 31422
diff changeset
536 @check("hardlink-whitelisted", "hardlinks on whitelisted filesystems")
07f0cddb0594 hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents: 31422
diff changeset
537 def has_hardlink_whitelisted():
31679
b33e352c365c hghave: use util.getfstype
Yuya Nishihara <yuya@tcha.org>
parents: 31582
diff changeset
538 from mercurial import util
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
539
31683
1ed57a7dd904 statfs: make getfstype() raise OSError
Yuya Nishihara <yuya@tcha.org>
parents: 31679
diff changeset
540 try:
36948
bf73012877a4 hghave: fix hardlink-whitelisted check on Python 3
Augie Fackler <augie@google.com>
parents: 36947
diff changeset
541 fstype = util.getfstype(b'.')
31683
1ed57a7dd904 statfs: make getfstype() raise OSError
Yuya Nishihara <yuya@tcha.org>
parents: 31679
diff changeset
542 except OSError:
1ed57a7dd904 statfs: make getfstype() raise OSError
Yuya Nishihara <yuya@tcha.org>
parents: 31679
diff changeset
543 return False
31582
07f0cddb0594 hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents: 31422
diff changeset
544 return fstype in util._hardlinkfswhitelist
07f0cddb0594 hghave: add a check about whitelisted filesystem that supports hardlink
Jun Wu <quark@fb.com>
parents: 31422
diff changeset
545
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
546
30230
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
547 @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: 29907
diff changeset
548 def has_rmcwd():
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
549 ocwd = os.getcwd()
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
550 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: 29907
diff changeset
551 try:
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
552 os.chdir(temp)
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
553 # 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: 29907
diff changeset
554 # 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: 29907
diff changeset
555 os.rmdir(os.getcwd())
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
556 return True
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
557 except OSError:
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
558 return False
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
559 finally:
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
560 os.chdir(ocwd)
30242
389cbfe63586 hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents: 30230
diff changeset
561 # 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
562 try:
389cbfe63586 hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents: 30230
diff changeset
563 os.rmdir(temp)
389cbfe63586 hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents: 30230
diff changeset
564 except OSError:
389cbfe63586 hghave: fix 'rmcwd' to ensure temporary directory is removed
Yuya Nishihara <yuya@tcha.org>
parents: 30230
diff changeset
565 pass
30230
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 29907
diff changeset
566
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
567
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
568 @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
569 def has_tla():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
570 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
571
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
572
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
573 @check("gpg", "gpg client")
8809
6fce36336e42 gpg: add test
Brendan Cully <brendan@kublai.com>
parents: 8213
diff changeset
574 def has_gpg():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
575 return matchoutput('gpg --version 2>&1', br'GnuPG')
8809
6fce36336e42 gpg: add test
Brendan Cully <brendan@kublai.com>
parents: 8213
diff changeset
576
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
577
29801
94fb0458a791 test-gpg: start gpg-agent under control of the test runner
Yuya Nishihara <yuya@tcha.org>
parents: 29611
diff changeset
578 @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
579 def has_gpg2():
94fb0458a791 test-gpg: start gpg-agent under control of the test runner
Yuya Nishihara <yuya@tcha.org>
parents: 29611
diff changeset
580 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
581
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
582
29877
80ba176bad62 test-gpg: start gpg-agent by gpg-connect-agent only if GnuPG v2.1+ detected
Yuya Nishihara <yuya@tcha.org>
parents: 29871
diff changeset
583 @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: 29871
diff changeset
584 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: 29871
diff changeset
585 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: 29871
diff changeset
586
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
587
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
588 @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
589 def has_unix_permissions():
16968
456f457e376d tests/hghave: consistently use dir='.', prefix=tempprefix for tempfiles
Mads Kiilerich <mads@kiilerich.com>
parents: 16966
diff changeset
590 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
591 try:
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
592 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
593 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
594 os.umask(umask)
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
595 f = open(fname, 'w')
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
596 f.close()
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
597 mode = os.stat(fname).st_mode
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
598 os.unlink(fname)
25658
e93036747902 global: mass rewrite to use modern octal syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents: 25413
diff changeset
599 if mode & 0o777 != ~umask & 0o666:
6063
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
600 return False
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
601 return True
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
602 finally:
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
603 os.rmdir(d)
b74a0c4bfb30 hghave: detect unix-style permissions
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5685
diff changeset
604
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
605
22994
840be5ca03e1 cmdserver: add service that listens on unix domain socket and forks process
Yuya Nishihara <yuya@tcha.org>
parents: 22579
diff changeset
606 @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
607 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
608 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
609
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
610
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
611 @check("root", "root permissions")
20008
e54a078153f7 tests: skip tests that require not having root (issue4089)
Matt Mackall <mpm@selenic.com>
parents: 19931
diff changeset
612 def has_root():
20114
390aff33c2f9 tests: fix `hghave root` on windows
Simon Heimberg <simohe@besonet.ch>
parents: 20008
diff changeset
613 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
614
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
615
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
616 @check("pyflakes", "Pyflakes python linter")
14140
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents: 14050
diff changeset
617 def has_pyflakes():
52087
43602c675b4f tests: use pyflakes as a tool, not a python module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52086
diff changeset
618 return matchoutput("pyflakes --version", br"^\d+\.\d+\.\d+\b", True)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
619
14140
82f0412ef7de tests: add pyflakes checking for unused imports
timeless <timeless@mozdev.org>
parents: 14050
diff changeset
620
31422
aa797bd54f44 test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30564
diff changeset
621 @check("pylint", "Pylint python linter")
aa797bd54f44 test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30564
diff changeset
622 def has_pylint():
49612
38ae503b369b hghave: detect newer pylint
Anton Shestakov <av6@dwimlabs.net>
parents: 49604
diff changeset
623 return matchoutput("pylint --help", br"[Uu]sage:[ ]+pylint", True)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
624
31422
aa797bd54f44 test: add a basic 'test-check-pylint.t'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30564
diff changeset
625
52134
f1312d0803a8 hghave: make the description for "clang-format" ascii
Matt Harbison <matt_harbison@yahoo.com>
parents: 52118
diff changeset
626 @check("clang-format", "clang-format C code formatter (11 <= ... < 19)")
34696
15b561fffde5 hghave: add a check for clang-format
Augie Fackler <augie@google.com>
parents: 34402
diff changeset
627 def has_clang_format():
45184
3781e9f74b27 hghave: fix possible int('') in has_clang_format()
Yuya Nishihara <yuya@tcha.org>
parents: 45172
diff changeset
628 m = matchoutput('clang-format --version', br'clang-format version (\d+)')
52086
73cf8b56c2f5 clang-format: do not accept version above 19.x
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52050
diff changeset
629 # style changed somewhere between 10.x and 11.x and after 19.
47904
1ff06ceb070f tests: allow Google's internal builds of clang-format to be used
Kyle Lippincott <spectral@google.com>
parents: 47826
diff changeset
630 if m:
52086
73cf8b56c2f5 clang-format: do not accept version above 19.x
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52050
diff changeset
631 major_version = int(m.group(1))
73cf8b56c2f5 clang-format: do not accept version above 19.x
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52050
diff changeset
632 return 11 <= major_version < 19
47904
1ff06ceb070f tests: allow Google's internal builds of clang-format to be used
Kyle Lippincott <spectral@google.com>
parents: 47826
diff changeset
633 # Assist Googler contributors, they have a centrally-maintained version of
1ff06ceb070f tests: allow Google's internal builds of clang-format to be used
Kyle Lippincott <spectral@google.com>
parents: 47826
diff changeset
634 # clang-format that is generally very fresh, but unlike most builds (both
1ff06ceb070f tests: allow Google's internal builds of clang-format to be used
Kyle Lippincott <spectral@google.com>
parents: 47826
diff changeset
635 # official and unofficial), it does *not* include a version number.
1ff06ceb070f tests: allow Google's internal builds of clang-format to be used
Kyle Lippincott <spectral@google.com>
parents: 47826
diff changeset
636 return matchoutput(
1ff06ceb070f tests: allow Google's internal builds of clang-format to be used
Kyle Lippincott <spectral@google.com>
parents: 47826
diff changeset
637 'clang-format --version', br'clang-format .*google3-trunk \([0-9a-f]+\)'
1ff06ceb070f tests: allow Google's internal builds of clang-format to be used
Kyle Lippincott <spectral@google.com>
parents: 47826
diff changeset
638 )
34696
15b561fffde5 hghave: add a check for clang-format
Augie Fackler <augie@google.com>
parents: 34402
diff changeset
639
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
640
35066
5d4369079c86 tests: use jshint when available to check .js files
Anton Shestakov <av6@dwimlabs.net>
parents: 34892
diff changeset
641 @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
642 def has_jshint():
5d4369079c86 tests: use jshint when available to check .js files
Anton Shestakov <av6@dwimlabs.net>
parents: 34892
diff changeset
643 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
644
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
645
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
646 @check("pygments", "Pygments source highlighting library")
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6079
diff changeset
647 def has_pygments():
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6079
diff changeset
648 try:
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6079
diff changeset
649 import pygments
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
650
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
651 del pygments # silence unused import warning
6355
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6079
diff changeset
652 return True
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6079
diff changeset
653 except ImportError:
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6079
diff changeset
654 return False
3b841c189ab7 tests: add highlight extension tests
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6079
diff changeset
655
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
656
49645
194e654815e6 hghave: refactor checks for pygments versions using checkvers()
Anton Shestakov <av6@dwimlabs.net>
parents: 49644
diff changeset
657 def getpygmentsversion():
48579
21c0ae0693bc tests: support pygments 2.11 (issue6628)
C?dric Krier <ced@b2ck.com>
parents: 48344
diff changeset
658 try:
21c0ae0693bc tests: support pygments 2.11 (issue6628)
C?dric Krier <ced@b2ck.com>
parents: 48344
diff changeset
659 import pygments
21c0ae0693bc tests: support pygments 2.11 (issue6628)
C?dric Krier <ced@b2ck.com>
parents: 48344
diff changeset
660
21c0ae0693bc tests: support pygments 2.11 (issue6628)
C?dric Krier <ced@b2ck.com>
parents: 48344
diff changeset
661 v = pygments.__version__
49645
194e654815e6 hghave: refactor checks for pygments versions using checkvers()
Anton Shestakov <av6@dwimlabs.net>
parents: 49644
diff changeset
662
194e654815e6 hghave: refactor checks for pygments versions using checkvers()
Anton Shestakov <av6@dwimlabs.net>
parents: 49644
diff changeset
663 parts = v.split(".")
52700
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
664 return int(parts[0]), int(parts[1])
48579
21c0ae0693bc tests: support pygments 2.11 (issue6628)
C?dric Krier <ced@b2ck.com>
parents: 48344
diff changeset
665 except ImportError:
52700
1f76fd3e9f7f hghave: drop redundant parentheses
Matt Harbison <matt_harbison@yahoo.com>
parents: 52699
diff changeset
666 return 0, 0
48579
21c0ae0693bc tests: support pygments 2.11 (issue6628)
C?dric Krier <ced@b2ck.com>
parents: 48344
diff changeset
667
21c0ae0693bc tests: support pygments 2.11 (issue6628)
C?dric Krier <ced@b2ck.com>
parents: 48344
diff changeset
668
53034
771706c5acfb tests: pygments 2.19+ highlight more whitespace in python code
Anton Shestakov <av6@dwimlabs.net>
parents: 53011
diff changeset
669 @checkvers(
771706c5acfb tests: pygments 2.19+ highlight more whitespace in python code
Anton Shestakov <av6@dwimlabs.net>
parents: 53011
diff changeset
670 "pygments", "Pygments version >= %s", ('2.5', '2.11', '2.14', '2.19')
771706c5acfb tests: pygments 2.19+ highlight more whitespace in python code
Anton Shestakov <av6@dwimlabs.net>
parents: 53011
diff changeset
671 )
49645
194e654815e6 hghave: refactor checks for pygments versions using checkvers()
Anton Shestakov <av6@dwimlabs.net>
parents: 49644
diff changeset
672 def has_pygments_range(v):
194e654815e6 hghave: refactor checks for pygments versions using checkvers()
Anton Shestakov <av6@dwimlabs.net>
parents: 49644
diff changeset
673 major, minor = v.split('.')[0:2]
194e654815e6 hghave: refactor checks for pygments versions using checkvers()
Anton Shestakov <av6@dwimlabs.net>
parents: 49644
diff changeset
674 return getpygmentsversion() >= (int(major), int(minor))
49643
42baf12efd21 tests: pygments 2.14+ highlight whitespace in python code
Anton Shestakov <av6@dwimlabs.net>
parents: 49618
diff changeset
675
42baf12efd21 tests: pygments 2.14+ highlight whitespace in python code
Anton Shestakov <av6@dwimlabs.net>
parents: 49618
diff changeset
676
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
677 @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
678 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
679 # failing for other reasons than 'no repo' imply that there is a repo
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
680 return not matchoutput('hg root 2>&1', br'abort: no repository found', True)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
681
7429
dbc40381620e tests: Skip tests if they will fail because of outer repo
Mads Kiilerich <mads@kiilerich.com>
parents: 7315
diff changeset
682
28591
f29cab5c519c hghave: change ssl check to just check ssl module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28582
diff changeset
683 @check("ssl", "ssl module available")
12740
b86c6954ec4c serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents: 10971
diff changeset
684 def has_ssl():
b86c6954ec4c serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents: 10971
diff changeset
685 try:
b86c6954ec4c serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents: 10971
diff changeset
686 import ssl
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
687
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
688 del ssl
12740
b86c6954ec4c serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents: 10971
diff changeset
689 return True
b86c6954ec4c serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents: 10971
diff changeset
690 except ImportError:
b86c6954ec4c serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents: 10971
diff changeset
691 return False
b86c6954ec4c serve: fix https mode and add test
Mads Kiilerich <mads@kiilerich.com>
parents: 10971
diff changeset
692
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
693
29481
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
694 @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
695 def has_defaultcacertsloaded():
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
696 import ssl
29483
918dce4b8c26 sslutil: pass ui to _defaultcacerts
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29481
diff changeset
697 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
698
30564
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 30450
diff changeset
699 ui = uimod.ui.load()
29483
918dce4b8c26 sslutil: pass ui to _defaultcacerts
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29481
diff changeset
700 cafile = sslutil._defaultcacerts(ui)
29481
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
701 ctx = ssl.create_default_context()
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
702 if cafile:
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
703 ctx.load_verify_locations(cafile=cafile)
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
704 else:
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
705 ctx.load_default_certs()
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
706
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
707 return len(ctx.get_ca_certs()) > 0
5caa415aa48b tests: better testing of loaded certificates
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29140
diff changeset
708
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
709
29601
6cff2ac0ccb9 sslutil: more robustly detect protocol support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29576
diff changeset
710 @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
711 def has_tls1_2():
6cff2ac0ccb9 sslutil: more robustly detect protocol support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29576
diff changeset
712 from mercurial import sslutil
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
713
41403
423a6b2ddafa tests: add b'' when testing for tls1.2
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41388
diff changeset
714 return b'tls1.2' in sslutil.supportedprotocols
29601
6cff2ac0ccb9 sslutil: more robustly detect protocol support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 29576
diff changeset
715
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
716
52321
323e3626929a sslutil: add support for clients to set TLSv1.3 as the minimum protocol
Matt Harbison <matt_harbison@yahoo.com>
parents: 52134
diff changeset
717 @check("tls1.3", "TLS 1.3 protocol support")
323e3626929a sslutil: add support for clients to set TLSv1.3 as the minimum protocol
Matt Harbison <matt_harbison@yahoo.com>
parents: 52134
diff changeset
718 def has_tls1_3():
323e3626929a sslutil: add support for clients to set TLSv1.3 as the minimum protocol
Matt Harbison <matt_harbison@yahoo.com>
parents: 52134
diff changeset
719 from mercurial import sslutil
323e3626929a sslutil: add support for clients to set TLSv1.3 as the minimum protocol
Matt Harbison <matt_harbison@yahoo.com>
parents: 52134
diff changeset
720
323e3626929a sslutil: add support for clients to set TLSv1.3 as the minimum protocol
Matt Harbison <matt_harbison@yahoo.com>
parents: 52134
diff changeset
721 return b'tls1.3' in sslutil.supportedprotocols
323e3626929a sslutil: add support for clients to set TLSv1.3 as the minimum protocol
Matt Harbison <matt_harbison@yahoo.com>
parents: 52134
diff changeset
722
323e3626929a sslutil: add support for clients to set TLSv1.3 as the minimum protocol
Matt Harbison <matt_harbison@yahoo.com>
parents: 52134
diff changeset
723
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
724 @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
725 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
726 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
727
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
728
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
729 @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
730 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
731 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
732
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
733
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
734 @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
735 def has_serve():
32874
41f99a90675d hghave: enable 'serve' on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 32790
diff changeset
736 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
737
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
738
45010
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
739 @check("setprocname", "whether osutil.setprocname is available or not")
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
740 def has_setprocname():
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
741 try:
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
742 from mercurial.utils import procutil
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
743
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
744 procutil.setprocname
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
745 return True
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
746 except AttributeError:
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
747 return False
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
748
62bdb288c449 tests: add hghave rule 'setprocname' to check if osutil.setprocname and use it
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44940
diff changeset
749
52050
d1b54c152673 extdiff: don't run gui programs when in a cli-only environment
Ludovic Chabant <ludovic@chabant.com>
parents: 51803
diff changeset
750 @check("gui", "whether a gui environment is available or not")
d1b54c152673 extdiff: don't run gui programs when in a cli-only environment
Ludovic Chabant <ludovic@chabant.com>
parents: 51803
diff changeset
751 def has_gui():
d1b54c152673 extdiff: don't run gui programs when in a cli-only environment
Ludovic Chabant <ludovic@chabant.com>
parents: 51803
diff changeset
752 from mercurial.utils import procutil
d1b54c152673 extdiff: don't run gui programs when in a cli-only environment
Ludovic Chabant <ludovic@chabant.com>
parents: 51803
diff changeset
753
d1b54c152673 extdiff: don't run gui programs when in a cli-only environment
Ludovic Chabant <ludovic@chabant.com>
parents: 51803
diff changeset
754 return procutil.gui()
d1b54c152673 extdiff: don't run gui programs when in a cli-only environment
Ludovic Chabant <ludovic@chabant.com>
parents: 51803
diff changeset
755
d1b54c152673 extdiff: don't run gui programs when in a cli-only environment
Ludovic Chabant <ludovic@chabant.com>
parents: 51803
diff changeset
756
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
757 @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
758 def has_test_repo():
0e1cbd3d52f7 tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents: 20644
diff changeset
759 t = os.environ["TESTDIR"]
0e1cbd3d52f7 tests: add repository check for pyflakes test
Matt Mackall <mpm@selenic.com>
parents: 20644
diff changeset
760 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
761
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
762
46643
ad107ed7a4aa ci: test real dependency installation for pip
Joerg Sonnenberger <joerg@bec.de>
parents: 46477
diff changeset
763 @check("network-io", "whether tests are allowed to access 3rd party services")
49289
223d55086d7c cleanup: rename some functions to avoid redefinitions
Manuel Jacob <me@manueljacob.de>
parents: 49287
diff changeset
764 def has_network_io():
46643
ad107ed7a4aa ci: test real dependency installation for pip
Joerg Sonnenberger <joerg@bec.de>
parents: 46477
diff changeset
765 t = os.environ.get("HGTESTS_ALLOW_NETIO")
ad107ed7a4aa ci: test real dependency installation for pip
Joerg Sonnenberger <joerg@bec.de>
parents: 46477
diff changeset
766 return t == "1"
ad107ed7a4aa ci: test real dependency installation for pip
Joerg Sonnenberger <joerg@bec.de>
parents: 46477
diff changeset
767
ad107ed7a4aa ci: test real dependency installation for pip
Joerg Sonnenberger <joerg@bec.de>
parents: 46477
diff changeset
768
46325
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
769 @check("curses", "terminfo compiler and curses module")
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
770 def has_curses():
20304
e457321a5687 tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents: 20114
diff changeset
771 try:
e457321a5687 tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents: 20114
diff changeset
772 import curses
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
773
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
774 del curses
46320
ef771d329961 hghave: adjust the definition of `tic` to allow curses tests on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46264
diff changeset
775
ef771d329961 hghave: adjust the definition of `tic` to allow curses tests on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46264
diff changeset
776 # Windows doesn't have a `tic` executable, but the windows_curses
ef771d329961 hghave: adjust the definition of `tic` to allow curses tests on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46264
diff changeset
777 # package is sufficient to run the tests without it.
ef771d329961 hghave: adjust the definition of `tic` to allow curses tests on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46264
diff changeset
778 if os.name == 'nt':
ef771d329961 hghave: adjust the definition of `tic` to allow curses tests on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46264
diff changeset
779 return True
ef771d329961 hghave: adjust the definition of `tic` to allow curses tests on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46264
diff changeset
780
46325
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
781 return has_tic()
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
782
44311
d3f776c4760e py3: catch AttributeError too with ImportError
Pulkit Goyal <7895pulkit@gmail.com>
parents: 44119
diff changeset
783 except (ImportError, AttributeError):
20304
e457321a5687 tests: 'hghave tic' also requires curses support in Python
Mads Kiilerich <madski@unity3d.com>
parents: 20114
diff changeset
784 return False
15539
d09ea5bbc9a4 tests: skip color test on platforms without tic
Mads Kiilerich <mads@kiilerich.com>
parents: 15446
diff changeset
785
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
786
46325
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
787 @check("tic", "terminfo compiler")
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
788 def has_tic():
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
789 return matchoutput('test -x "`which tic`"', br'')
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
790
e5e6282fa66a hghave: split apart testing for the curses module and `tic` executable
Matt Harbison <matt_harbison@yahoo.com>
parents: 46320
diff changeset
791
43739
21e05aabef8c hghave: add a check for the `xz` compression utility
Matt Harbison <matt_harbison@yahoo.com>
parents: 43518
diff changeset
792 @check("xz", "xz compression utility")
21e05aabef8c hghave: add a check for the `xz` compression utility
Matt Harbison <matt_harbison@yahoo.com>
parents: 43518
diff changeset
793 def has_xz():
21e05aabef8c hghave: add a check for the `xz` compression utility
Matt Harbison <matt_harbison@yahoo.com>
parents: 43518
diff changeset
794 # When Windows invokes a subprocess in shell mode, it uses `cmd.exe`, which
21e05aabef8c hghave: add a check for the `xz` compression utility
Matt Harbison <matt_harbison@yahoo.com>
parents: 43518
diff changeset
795 # only knows `where`, not `which`. So invoke MSYS shell explicitly.
21e05aabef8c hghave: add a check for the `xz` compression utility
Matt Harbison <matt_harbison@yahoo.com>
parents: 43518
diff changeset
796 return matchoutput("sh -c 'test -x \"`which xz`\"'", b'')
21e05aabef8c hghave: add a check for the `xz` compression utility
Matt Harbison <matt_harbison@yahoo.com>
parents: 43518
diff changeset
797
21e05aabef8c hghave: add a check for the `xz` compression utility
Matt Harbison <matt_harbison@yahoo.com>
parents: 43518
diff changeset
798
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
799 @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
800 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
801 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
802
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
803
22093
45611a306f77 tests: use a decorator for hghave checks
Matt Mackall <mpm@selenic.com>
parents: 21208
diff changeset
804 @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
805 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
806 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
807
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
808
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
809 @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
810 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
811 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
812
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
813
29026
80f15aa32edd hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents: 29022
diff changeset
814 @check("osxpackaging", "OS X packaging tools")
80f15aa32edd hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents: 29022
diff changeset
815 def has_osxpackaging():
80f15aa32edd hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents: 29022
diff changeset
816 try:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
817 return (
52699
e1c5d823287b hghave: make the `ignorestatus` argument to `matchoutput()` a bool
Matt Harbison <matt_harbison@yahoo.com>
parents: 52698
diff changeset
818 matchoutput('pkgbuild', br'Usage: pkgbuild ', ignorestatus=True)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
819 and matchoutput(
52699
e1c5d823287b hghave: make the `ignorestatus` argument to `matchoutput()` a bool
Matt Harbison <matt_harbison@yahoo.com>
parents: 52698
diff changeset
820 'productbuild', br'Usage: productbuild ', ignorestatus=True
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
821 )
52699
e1c5d823287b hghave: make the `ignorestatus` argument to `matchoutput()` a bool
Matt Harbison <matt_harbison@yahoo.com>
parents: 52698
diff changeset
822 and matchoutput('lsbom', br'Usage: lsbom', ignorestatus=True)
e1c5d823287b hghave: make the `ignorestatus` argument to `matchoutput()` a bool
Matt Harbison <matt_harbison@yahoo.com>
parents: 52698
diff changeset
823 and matchoutput('xar --help', br'Usage: xar', ignorestatus=True)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
824 )
29026
80f15aa32edd hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents: 29022
diff changeset
825 except ImportError:
80f15aa32edd hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents: 29022
diff changeset
826 return False
80f15aa32edd hghave: add check for OS X packaging tools
Augie Fackler <augie@google.com>
parents: 29022
diff changeset
827
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
828
34885
df2ff314e36f fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34840
diff changeset
829 @check('linuxormacos', 'Linux or MacOS')
df2ff314e36f fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34840
diff changeset
830 def has_linuxormacos():
df2ff314e36f fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34840
diff changeset
831 # 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
832 return sys.platform.startswith(('linux', 'darwin'))
df2ff314e36f fsmonitor: warn when fsmonitor could be used
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34840
diff changeset
833
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
834
26111
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
835 @check("docker", "docker support")
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
836 def has_docker():
29140
47eab0cb72e3 hghave: matchoutput needs to use bytes for regexp
timeless <timeless@mozdev.org>
parents: 29107
diff changeset
837 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
838 if matchoutput('docker --help', pat):
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
839 if 'linux' not in sys.platform:
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
840 # 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
841 # 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
842 # 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
843 # $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
844 # 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
845 # 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
846 # return 'DOCKER_HOST' in os.environ
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
847 return False
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
848
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
849 return True
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
850 return False
dcc12365fa38 hghave: add a check for docker support
Augie Fackler <augie@google.com>
parents: 26110
diff changeset
851
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
852
26110
2dcfb98c5314 hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents: 26109
diff changeset
853 @check("debhelper", "debian packaging tools")
2dcfb98c5314 hghave: add a check for debian packaging tools
Augie Fackler <augie@google.com>
parents: 26109
diff changeset
854 def has_debhelper():
34395
dbf83230e8be hghave: fix dpkg --version check to work on recent dpkg versions
Kyle Lippincott <spectral@google.com>
parents: 33723
diff changeset
855 # 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: 33723
diff changeset
856 # quote), so just accept anything in that spot.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
857 dpkg = matchoutput(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
858 'dpkg --version', br"Debian .dpkg' package management program"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
859 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
860 dh = matchoutput(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
861 'dh --help', br'dh is a part of debhelper.', ignorestatus=True
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
862 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
863 dh_py2 = matchoutput(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
864 'dh_python2 --help', br'other supported Python versions'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
865 )
34400
200eadbcf0b0 hghave: check for debuild being installed as well
Kyle Lippincott <spectral@google.com>
parents: 34395
diff changeset
866 # 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: 34395
diff changeset
867 # the 'build-debs' package instead, which has a dependency on devscripts.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
868 debuild = matchoutput(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
869 'debuild --help', br'to run debian/rules with given parameter'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
870 )
34400
200eadbcf0b0 hghave: check for debuild being installed as well
Kyle Lippincott <spectral@google.com>
parents: 34395
diff changeset
871 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
872
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
873
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
874 @check(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
875 "debdeps", "debian build dependencies (run dpkg-checkbuilddeps in contrib/)"
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
876 )
34402
13d3f8aaed87 tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents: 34400
diff changeset
877 def has_debdeps():
13d3f8aaed87 tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents: 34400
diff changeset
878 # just check exit status (ignoring output)
38051
e51c91c14a07 packaging: move contrib/debian to contrib/packaging/
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37415
diff changeset
879 path = '%s/../contrib/packaging/debian/control' % os.environ['TESTDIR']
34402
13d3f8aaed87 tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents: 34400
diff changeset
880 return matchoutput('dpkg-checkbuilddeps %s' % path, br'')
13d3f8aaed87 tests: add "have" check for dpkg builddeps
Kyle Lippincott <spectral@google.com>
parents: 34400
diff changeset
881
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
882
29871
b05a3a04f046 hghave: add demandimport checking
timeless <timeless@mozdev.org>
parents: 29870
diff changeset
883 @check("demandimport", "demandimport enabled")
b05a3a04f046 hghave: add demandimport checking
timeless <timeless@mozdev.org>
parents: 29870
diff changeset
884 def has_demandimport():
34840
88624b40a9cb hghave: disable demandimport when chg is running
Saurabh Singh <singhsrb@fb.com>
parents: 34696
diff changeset
885 # chg disables demandimport intentionally for performance wins.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
886 return (not has_chg()) and os.environ.get('HGDEMANDIMPORT') != 'disable'
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
887
29871
b05a3a04f046 hghave: add demandimport checking
timeless <timeless@mozdev.org>
parents: 29870
diff changeset
888
50250
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
889 # Add "py36", "py37", ... as possible feature checks. Note that there's no
43113
37af48031d6f hghave: document format for version feature checks as <name><vers>, no dots
Kyle Lippincott <spectral@google.com>
parents: 43095
diff changeset
890 # punctuation here.
51376
54a75576287a hghave: add py312 and py313
Manuel Jacob <me@manueljacob.de>
parents: 51375
diff changeset
891 @checkvers(
54a75576287a hghave: add py312 and py313
Manuel Jacob <me@manueljacob.de>
parents: 51375
diff changeset
892 "py",
54a75576287a hghave: add py312 and py313
Manuel Jacob <me@manueljacob.de>
parents: 51375
diff changeset
893 "Python >= %s",
54a75576287a hghave: add py312 and py313
Manuel Jacob <me@manueljacob.de>
parents: 51375
diff changeset
894 ('3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13'),
54a75576287a hghave: add py312 and py313
Manuel Jacob <me@manueljacob.de>
parents: 51375
diff changeset
895 )
41465
1a6a01a21d6a hghave: add pyXY features for Python version numbers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41403
diff changeset
896 def has_python_range(v):
1a6a01a21d6a hghave: add pyXY features for Python version numbers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41403
diff changeset
897 major, minor = v.split('.')[0:2]
1a6a01a21d6a hghave: add pyXY features for Python version numbers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41403
diff changeset
898 py_major, py_minor = sys.version_info.major, sys.version_info.minor
1a6a01a21d6a hghave: add pyXY features for Python version numbers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41403
diff changeset
899
1a6a01a21d6a hghave: add pyXY features for Python version numbers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41403
diff changeset
900 return (py_major, py_minor) >= (int(major), int(minor))
1a6a01a21d6a hghave: add pyXY features for Python version numbers
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41403
diff changeset
901
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
902
40263
8cf459d8b111 py3: use py3 as the test tag, dropping the k
Martijn Pieters <mj@octobus.net>
parents: 39775
diff changeset
903 @check("py3", "running with Python 3.x")
8cf459d8b111 py3: use py3 as the test tag, dropping the k
Martijn Pieters <mj@octobus.net>
parents: 39775
diff changeset
904 def has_py3():
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
905 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
906
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
907
28582
cdbc25306696 run-tests: add --with-python3 to define a Python 3 interpreter
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28383
diff changeset
908 @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
909 def has_python3exe():
47039
94c0c36299b1 hghave: fix the definition of `python3` to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46870
diff changeset
910 py = 'python3'
94c0c36299b1 hghave: fix the definition of `python3` to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46870
diff changeset
911 if os.name == 'nt':
94c0c36299b1 hghave: fix the definition of `python3` to work on Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 46870
diff changeset
912 py = 'py -3'
50250
57133107ab4d hghave: drop py27 and py35 support
Matt Harbison <matt_harbison@yahoo.com>
parents: 50249
diff changeset
913 return matchoutput('%s -V' % py, br'^Python 3.(6|7|8|9|10|11)')
28582
cdbc25306696 run-tests: add --with-python3 to define a Python 3 interpreter
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28383
diff changeset
914
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
915
25859
1619563959b3 tests: disable test of buffer overflow in parsers.c if --pure
Yuya Nishihara <yuya@tcha.org>
parents: 25658
diff changeset
916 @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
917 def has_pure():
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
918 return any(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
919 [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
920 os.environ.get("HGMODULEPOLICY") == "py",
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
921 os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure",
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
922 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
923 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
924
26109
bad09bd22b6a run-tests: add support for marking tests as very slow
Augie Fackler <augie@google.com>
parents: 26068
diff changeset
925
32507
c2b7fb580794 tests: hint how to run slow tests when rejecting
Kyle Lippincott <spectral@google.com>
parents: 32285
diff changeset
926 @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
927 def has_slow():
bad09bd22b6a run-tests: add support for marking tests as very slow
Augie Fackler <augie@google.com>
parents: 26068
diff changeset
928 return os.environ.get('HGTEST_SLOW') == 'slow'
26842
0f76c64f5cc3 testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents: 26145
diff changeset
929
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
930
28383
e13e0e189990 hghave: improve description of Hypothesis
timeless <timeless@mozdev.org>
parents: 28126
diff changeset
931 @check("hypothesis", "Hypothesis automated test generation")
26842
0f76c64f5cc3 testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents: 26145
diff changeset
932 def has_hypothesis():
0f76c64f5cc3 testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents: 26145
diff changeset
933 try:
0f76c64f5cc3 testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents: 26145
diff changeset
934 import hypothesis
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
935
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
936 del hypothesis
26842
0f76c64f5cc3 testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents: 26145
diff changeset
937 return True
0f76c64f5cc3 testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents: 26145
diff changeset
938 except ImportError:
0f76c64f5cc3 testing: add hypothesis fuzz testing
David R. MacIver <david@drmaciver.com>
parents: 26145
diff changeset
939 return False
29854
00ca4f966ca6 hghave: add a check for unzip(1) that understands symlinks
Augie Fackler <augie@google.com>
parents: 29820
diff changeset
940
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
941
29854
00ca4f966ca6 hghave: add a check for unzip(1) that understands symlinks
Augie Fackler <augie@google.com>
parents: 29820
diff changeset
942 @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: 29820
diff changeset
943 def unzip_understands_symlinks():
00ca4f966ca6 hghave: add a check for unzip(1) that understands symlinks
Augie Fackler <augie@google.com>
parents: 29820
diff changeset
944 return matchoutput('unzip --help', br'Info-ZIP')
30450
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
945
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
946
30450
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
947 @check("zstd", "zstd Python module available")
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
948 def has_zstd():
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
949 try:
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
950 import mercurial.zstd
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
951
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
952 del mercurial.zstd
30450
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
953 return True
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
954 except ImportError:
de48d3a0573a hghave: add check for zstd support
Gregory Szorc <gregory.szorc@gmail.com>
parents: 30311
diff changeset
955 return False
31964
ebaada96aec3 stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents: 31683
diff changeset
956
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
957
31964
ebaada96aec3 stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents: 31683
diff changeset
958 @check("devfull", "/dev/full special file")
ebaada96aec3 stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents: 31683
diff changeset
959 def has_dev_full():
ebaada96aec3 stdio: add Linux-specific tests for error checking
Bryan O'Sullivan <bryano@fb.com>
parents: 31683
diff changeset
960 return os.path.exists('/dev/full')
32746
a6e4c4218b71 hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents: 32507
diff changeset
961
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
962
43412
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
963 @check("ensurepip", "ensurepip module")
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
964 def has_ensurepip():
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
965 try:
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
966 import ensurepip
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
967
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
968 del ensurepip
43412
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
969 return True
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
970 except ImportError:
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
971 return False
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
972
ca0cd0a13514 tests: look for ensurepip before using venv
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43406
diff changeset
973
46098
1b5e0d0bdb05 hghave: update the check for virtualenv
Matt Harbison <matt_harbison@yahoo.com>
parents: 46002
diff changeset
974 @check("virtualenv", "virtualenv support")
1b5e0d0bdb05 hghave: update the check for virtualenv
Matt Harbison <matt_harbison@yahoo.com>
parents: 46002
diff changeset
975 def has_virtualenv():
32746
a6e4c4218b71 hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents: 32507
diff changeset
976 try:
a6e4c4218b71 hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents: 32507
diff changeset
977 import virtualenv
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
978
46098
1b5e0d0bdb05 hghave: update the check for virtualenv
Matt Harbison <matt_harbison@yahoo.com>
parents: 46002
diff changeset
979 # --no-site-package became the default in 1.7 (Nov 2011), and the
1b5e0d0bdb05 hghave: update the check for virtualenv
Matt Harbison <matt_harbison@yahoo.com>
parents: 46002
diff changeset
980 # argument was removed in 20.0 (Feb 2020). Rather than make the
1b5e0d0bdb05 hghave: update the check for virtualenv
Matt Harbison <matt_harbison@yahoo.com>
parents: 46002
diff changeset
981 # script complicated, just ignore ancient versions.
1b5e0d0bdb05 hghave: update the check for virtualenv
Matt Harbison <matt_harbison@yahoo.com>
parents: 46002
diff changeset
982 return int(virtualenv.__version__.split('.')[0]) > 1
1b5e0d0bdb05 hghave: update the check for virtualenv
Matt Harbison <matt_harbison@yahoo.com>
parents: 46002
diff changeset
983 except (AttributeError, ImportError, IndexError):
32746
a6e4c4218b71 hghave: add check for virtualenv
Augie Fackler <augie@google.com>
parents: 32507
diff changeset
984 return False
32790
9cf74abd1252 hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents: 32746
diff changeset
985
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
986
32790
9cf74abd1252 hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents: 32746
diff changeset
987 @check("fsmonitor", "running tests with fsmonitor")
9cf74abd1252 hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents: 32746
diff changeset
988 def has_fsmonitor():
9cf74abd1252 hghave: add test for whether fsmonitor is enabled
Siddharth Agarwal <sid0@fb.com>
parents: 32746
diff changeset
989 return 'HGFSMONITOR_TESTS' in os.environ
33723
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
990
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
991
33723
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
992 @check("fuzzywuzzy", "Fuzzy string matching library")
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
993 def has_fuzzywuzzy():
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
994 try:
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
995 import fuzzywuzzy
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
996
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
997 del fuzzywuzzy
33723
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
998 return True
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
999 except ImportError:
4d1e79945c2e releasenotes: add import check for fuzzywuzzy
Rishabh Madan <rishabhmadan96@gmail.com>
parents: 33528
diff changeset
1000 return False
35668
67cead0eb671 hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents: 35160
diff changeset
1001
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1002
35668
67cead0eb671 hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents: 35160
diff changeset
1003 @check("clang-libfuzzer", "clang new enough to include libfuzzer")
67cead0eb671 hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents: 35160
diff changeset
1004 def has_clang_libfuzzer():
41557
dddf53473315 tests: use raw strings for regular expressions with escapes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41465
diff changeset
1005 mat = matchoutput('clang --version', br'clang version (\d)')
35668
67cead0eb671 hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents: 35160
diff changeset
1006 if mat:
67cead0eb671 hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents: 35160
diff changeset
1007 # libfuzzer is new in clang 6
67cead0eb671 hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents: 35160
diff changeset
1008 return int(mat.group(1)) > 5
67cead0eb671 hghave: add test for clang 6 and later
Augie Fackler <augie@google.com>
parents: 35160
diff changeset
1009 return False
36707
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents: 36688
diff changeset
1010
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1011
38248
a6347ae6168d test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents: 38051
diff changeset
1012 @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: 38051
diff changeset
1013 def has_clang60():
41557
dddf53473315 tests: use raw strings for regular expressions with escapes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41465
diff changeset
1014 return matchoutput('clang-6.0 --version', br'clang version 6\.')
38248
a6347ae6168d test-fuzz-targets: look for clang-6.0 binary as well
Yuya Nishihara <yuya@tcha.org>
parents: 38051
diff changeset
1015
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1016
36707
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents: 36688
diff changeset
1017 @check("xdiff", "xdiff algorithm")
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents: 36688
diff changeset
1018 def has_xdiff():
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents: 36688
diff changeset
1019 try:
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents: 36688
diff changeset
1020 from mercurial import policy
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1021
36707
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents: 36688
diff changeset
1022 bdiff = policy.importmod('bdiff')
36947
3f7bbce8fbaa hghave: fix xdiff check on Python 3
Augie Fackler <augie@google.com>
parents: 36719
diff changeset
1023 return bdiff.xdiffblocks(b'', b'') == [(0, 0, 0, 0)]
36719
1d06407d0ee9 hghave: remove unused "as ex" in exception block
Augie Fackler <augie@google.com>
parents: 36707
diff changeset
1024 except (ImportError, AttributeError):
36707
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents: 36688
diff changeset
1025 return False
37338
cbc4425e81b5 tests: conditionalize tests based on presence of revlogs for files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36948
diff changeset
1026
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1027
37342
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37338
diff changeset
1028 @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
1029 def has_extraextensions():
4e6a6d0dccee tests: conditionalize tests based on presence of custom extensions
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37338
diff changeset
1030 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
1031
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1032
47290
40b51c28b242 dirstate-v2: Update the expected output of some tests for new requirement
Simon Sapin <simon.sapin@octobus.net>
parents: 47039
diff changeset
1033 @check('dirstate-v2', 'using the v2 format of .hg/dirstate')
40b51c28b242 dirstate-v2: Update the expected output of some tests for new requirement
Simon Sapin <simon.sapin@octobus.net>
parents: 47039
diff changeset
1034 def has_dirstate_v2():
40b51c28b242 dirstate-v2: Update the expected output of some tests for new requirement
Simon Sapin <simon.sapin@octobus.net>
parents: 47039
diff changeset
1035 # Keep this logic in sync with `newreporequirements()` in `mercurial/localrepo.py`
49584
8cd39c20445e tests: fix the detection of dirstate-v2 in hghave.py
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 49289
diff changeset
1036 return matchoutput(
8cd39c20445e tests: fix the detection of dirstate-v2 in hghave.py
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 49289
diff changeset
1037 'hg config format.use-dirstate-v2', b'(?i)1|yes|true|on|always'
47290
40b51c28b242 dirstate-v2: Update the expected output of some tests for new requirement
Simon Sapin <simon.sapin@octobus.net>
parents: 47039
diff changeset
1038 )
40b51c28b242 dirstate-v2: Update the expected output of some tests for new requirement
Simon Sapin <simon.sapin@octobus.net>
parents: 47039
diff changeset
1039
40b51c28b242 dirstate-v2: Update the expected output of some tests for new requirement
Simon Sapin <simon.sapin@octobus.net>
parents: 47039
diff changeset
1040
46264
7149fb17ff72 hghave: clarify `sqlite` requirements
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46177
diff changeset
1041 @check('sqlite', 'sqlite3 module and matching cli is available')
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40263
diff changeset
1042 def has_sqlite():
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40263
diff changeset
1043 try:
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40263
diff changeset
1044 import sqlite3
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1045
40427
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40326
diff changeset
1046 version = sqlite3.sqlite_version_info
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40263
diff changeset
1047 except ImportError:
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40263
diff changeset
1048 return False
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40263
diff changeset
1049
40427
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40326
diff changeset
1050 if version < (3, 8, 3):
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40326
diff changeset
1051 # WITH clause not supported
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40326
diff changeset
1052 return False
1bf3e6041e2c tests: require SQLite 3.8.3+ as sqlitestore relies on "WITH" clause
Yuya Nishihara <yuya@tcha.org>
parents: 40326
diff changeset
1053
41557
dddf53473315 tests: use raw strings for regular expressions with escapes
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41465
diff changeset
1054 return matchoutput('sqlite3 -version', br'^3\.\d+')
40326
fed697fa1734 sqlitestore: file storage backend using SQLite
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40263
diff changeset
1055
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1056
46465
66e8e279133b hghave: list the module needed for the `vcr` check
Matt Harbison <matt_harbison@yahoo.com>
parents: 46325
diff changeset
1057 @check('vcr', 'vcr http mocking library (pytest-vcr)')
39664
e37a0fcd82c0 hghave: add a checker for the vcr HTTP record/replay library
Augie Fackler <raf@durin42.com>
parents: 39429
diff changeset
1058 def has_vcr():
e37a0fcd82c0 hghave: add a checker for the vcr HTTP record/replay library
Augie Fackler <raf@durin42.com>
parents: 39429
diff changeset
1059 try:
e37a0fcd82c0 hghave: add a checker for the vcr HTTP record/replay library
Augie Fackler <raf@durin42.com>
parents: 39429
diff changeset
1060 import vcr
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1061
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
1062 del vcr
39664
e37a0fcd82c0 hghave: add a checker for the vcr HTTP record/replay library
Augie Fackler <raf@durin42.com>
parents: 39429
diff changeset
1063 return True
e37a0fcd82c0 hghave: add a checker for the vcr HTTP record/replay library
Augie Fackler <raf@durin42.com>
parents: 39429
diff changeset
1064 except (ImportError, AttributeError):
e37a0fcd82c0 hghave: add a checker for the vcr HTTP record/replay library
Augie Fackler <raf@durin42.com>
parents: 39429
diff changeset
1065 pass
e37a0fcd82c0 hghave: add a checker for the vcr HTTP record/replay library
Augie Fackler <raf@durin42.com>
parents: 39429
diff changeset
1066 return False
41796
2a6ca0d94b70 hghave: add check for GNU emacs
Augie Fackler <augie@google.com>
parents: 41768
diff changeset
1067
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42159
diff changeset
1068
41796
2a6ca0d94b70 hghave: add check for GNU emacs
Augie Fackler <augie@google.com>
parents: 41768
diff changeset
1069 @check('emacs', 'GNU Emacs')
2a6ca0d94b70 hghave: add check for GNU emacs
Augie Fackler <augie@google.com>
parents: 41768
diff changeset
1070 def has_emacs():
41847
28842adf8ed5 hghave: skip emacs tests on 24.3 and earlier
Augie Fackler <augie@google.com>
parents: 41796
diff changeset
1071 # Our emacs lisp uses `with-eval-after-load` which is new in emacs
28842adf8ed5 hghave: skip emacs tests on 24.3 and earlier
Augie Fackler <augie@google.com>
parents: 41796
diff changeset
1072 # 24.4, so we allow emacs 24.4, 24.5, and 25+ (24.5 was the last
28842adf8ed5 hghave: skip emacs tests on 24.3 and earlier
Augie Fackler <augie@google.com>
parents: 41796
diff changeset
1073 # 24 release)
28842adf8ed5 hghave: skip emacs tests on 24.3 and earlier
Augie Fackler <augie@google.com>
parents: 41796
diff changeset
1074 return matchoutput('emacs --version', b'GNU Emacs 2(4.4|4.5|5|6|7|8|9)')
43095
fb41ea2ea076 formatting: introduce a `test-check-format-black.t` that enforce formatting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
1075
fb41ea2ea076 formatting: introduce a `test-check-format-black.t` that enforce formatting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
1076
52572
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1077 @check(
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1078 'black', 'the black formatter for python (version set in pyproject.toml)'
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1079 )
43095
fb41ea2ea076 formatting: introduce a `test-check-format-black.t` that enforce formatting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43076
diff changeset
1080 def has_black():
52572
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1081 env = environ()
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1082
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1083 # The top level #require statements are evaluated from $TESTTMP, and won't
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1084 # see the project level pyproject.toml unless executing from the project
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1085 # directory.
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1086 cwd = os.getcwd()
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1087 if 'RUNTESTDIR' in env:
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1088 cwd = os.path.realpath(f"{env['RUNTESTDIR']}/..")
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1089
52573
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1090 try:
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1091 p = subprocess.Popen(
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1092 ['black', '--check', '-'],
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1093 stdin=subprocess.PIPE,
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1094 cwd=cwd,
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1095 env=env,
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1096 )
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1097 except FileNotFoundError:
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1098 return False
918ef1fca39e hghave: handle the case where the `black` executable is not on PATH
Matt Harbison <matt_harbison@yahoo.com>
parents: 52572
diff changeset
1099
52572
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1100 p.communicate(b'# test\n')
384d71e3dd65 pyproject: defer the `hghave` version check of `black` to the project file
Matt Harbison <matt_harbison@yahoo.com>
parents: 52321
diff changeset
1101 return p.returncode == 0
43518
32ac4d0b4102 hghave: add a check for pytype, Google's Python type checker
Augie Fackler <augie@google.com>
parents: 43507
diff changeset
1102
32ac4d0b4102 hghave: add a check for pytype, Google's Python type checker
Augie Fackler <augie@google.com>
parents: 43507
diff changeset
1103
32ac4d0b4102 hghave: add a check for pytype, Google's Python type checker
Augie Fackler <augie@google.com>
parents: 43507
diff changeset
1104 @check('pytype', 'the pytype type checker')
32ac4d0b4102 hghave: add a check for pytype, Google's Python type checker
Augie Fackler <augie@google.com>
parents: 43507
diff changeset
1105 def has_pytype():
32ac4d0b4102 hghave: add a check for pytype, Google's Python type checker
Augie Fackler <augie@google.com>
parents: 43507
diff changeset
1106 pytypecmd = 'pytype --version'
32ac4d0b4102 hghave: add a check for pytype, Google's Python type checker
Augie Fackler <augie@google.com>
parents: 43507
diff changeset
1107 version = matchoutput(pytypecmd, b'[0-9a-b.]+')
51712
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
1108 if not version:
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
1109 return False
a26a05199070 tests: use packaging from setuptools instead of deprecated distutils
Mads Kiilerich <mads@kiilerich.com>
parents: 51376
diff changeset
1110 return Version(_bytes2sys(version.group(0))) >= Version('2019.10.17')
43837
e8a3bbffdc7d tests: add test for Rust formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43739
diff changeset
1111
e8a3bbffdc7d tests: add test for Rust formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43739
diff changeset
1112
51794
c8188b10cf43 hghave: update expected rustfmt version
Rapha?l Gom?s <rgomes@octobus.net>
parents: 51763
diff changeset
1113 @check("rustfmt", "rustfmt tool at version nightly-2024-07-16")
43837
e8a3bbffdc7d tests: add test for Rust formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43739
diff changeset
1114 def has_rustfmt():
e8a3bbffdc7d tests: add test for Rust formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43739
diff changeset
1115 # We use Nightly's rustfmt due to current unstable config options.
e8a3bbffdc7d tests: add test for Rust formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43739
diff changeset
1116 return matchoutput(
51794
c8188b10cf43 hghave: update expected rustfmt version
Rapha?l Gom?s <rgomes@octobus.net>
parents: 51763
diff changeset
1117 '`rustup which --toolchain nightly-2024-07-16 rustfmt` --version',
46002
d42809b6b10f rust-format: pin the formatted to a specific nightly version
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45958
diff changeset
1118 b'rustfmt',
43837
e8a3bbffdc7d tests: add test for Rust formatting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43739
diff changeset
1119 )
44842
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1120
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1121
45559
952f9d37002c rust-tests: add test to check if `Cargo.lock` is up-to-date
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45249
diff changeset
1122 @check("cargo", "cargo tool")
952f9d37002c rust-tests: add test to check if `Cargo.lock` is up-to-date
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45249
diff changeset
1123 def has_cargo():
952f9d37002c rust-tests: add test to check if `Cargo.lock` is up-to-date
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45249
diff changeset
1124 return matchoutput('`rustup which cargo` --version', b'cargo')
952f9d37002c rust-tests: add test to check if `Cargo.lock` is up-to-date
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45249
diff changeset
1125
952f9d37002c rust-tests: add test to check if `Cargo.lock` is up-to-date
Rapha?l Gom?s <rgomes@octobus.net>
parents: 45249
diff changeset
1126
44842
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1127 @check("lzma", "python lzma module")
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1128 def has_lzma():
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1129 try:
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1130 import _lzma
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1131
52701
3c6460c0586f hghave: avoid unused import warning by deleting the imported module
Matt Harbison <matt_harbison@yahoo.com>
parents: 52700
diff changeset
1132 del _lzma
44842
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1133 return True
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1134 except ImportError:
2c0043977b6d archival: abort if compression method is unavailable
Manuel Jacob <me@manueljacob.de>
parents: 44644
diff changeset
1135 return False
47312
97f04eaafa65 tests: add req on bash for test-transaction-rollback-on-sigpipe (issue6429)
Augie Fackler <augie@google.com>
parents: 47290
diff changeset
1136
97f04eaafa65 tests: add req on bash for test-transaction-rollback-on-sigpipe (issue6429)
Augie Fackler <augie@google.com>
parents: 47290
diff changeset
1137
97f04eaafa65 tests: add req on bash for test-transaction-rollback-on-sigpipe (issue6429)
Augie Fackler <augie@google.com>
parents: 47290
diff changeset
1138 @check("bash", "bash shell")
97f04eaafa65 tests: add req on bash for test-transaction-rollback-on-sigpipe (issue6429)
Augie Fackler <augie@google.com>
parents: 47290
diff changeset
1139 def has_bash():
97f04eaafa65 tests: add req on bash for test-transaction-rollback-on-sigpipe (issue6429)
Augie Fackler <augie@google.com>
parents: 47290
diff changeset
1140 return matchoutput("bash -c 'echo hi'", b'^hi$')
48344
f447b90a4b11 tests: allow for variation in zstd output as seen on s390x and powerpc
Julien Cristau <jcristau@debian.org>
parents: 48341
diff changeset
1141
f447b90a4b11 tests: allow for variation in zstd output as seen on s390x and powerpc
Julien Cristau <jcristau@debian.org>
parents: 48341
diff changeset
1142
f447b90a4b11 tests: allow for variation in zstd output as seen on s390x and powerpc
Julien Cristau <jcristau@debian.org>
parents: 48341
diff changeset
1143 @check("bigendian", "big-endian CPU")
f447b90a4b11 tests: allow for variation in zstd output as seen on s390x and powerpc
Julien Cristau <jcristau@debian.org>
parents: 48341
diff changeset
1144 def has_bigendian():
f447b90a4b11 tests: allow for variation in zstd output as seen on s390x and powerpc
Julien Cristau <jcristau@debian.org>
parents: 48341
diff changeset
1145 return sys.byteorder == 'big'