##// END OF EJS Templates
get-with-headers: fix stream modes under Windows
get-with-headers: fix stream modes under Windows

File last commit:

r7053:209ef5f3 default
r7054:e837f229 default
Show More
hghave
218 lines | 5.9 KiB | text/plain | TextLexer
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 #!/usr/bin/env python
"""Test the running system for features availability. Exit with zero
Patrick Mezard
hghave: feature absence can be checked by prefixing with 'no-'
r5084 if all features are there, non-zero otherwise. If a feature name is
prefixed with "no-", the absence of feature is tested.
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 """
import optparse
import os
Patrick Mezard
hghave: wrap command output matching
r5252 import re
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 import sys
Patrick Mezard
hghave: detect executable permission availability.
r5072 import tempfile
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881
Patrick Mezard
hghave: prefix temporary files with "hg-hghave-"
r5090 tempprefix = 'hg-hghave-'
Patrick Mezard
hghave: detect cvs and cvsps availability...
r5302 def matchoutput(cmd, regexp, ignorestatus=False):
Patrick Mezard
hghave: wrap command output matching
r5252 """Return True if cmd executes successfully and its output
is matched by the supplied regular expression.
"""
r = re.compile(regexp)
fh = os.popen(cmd)
s = fh.read()
ret = fh.close()
Patrick Mezard
hghave: detect cvs and cvsps availability...
r5302 return (ignorestatus or ret is None) and r.search(s)
Patrick Mezard
hghave: wrap command output matching
r5252
Aleix Conchillo Flaque
convert: added gnu arch (baz) tests
r6078 def has_baz():
return matchoutput('baz --version 2>&1', r'baz Bazaar version')
Marek Kubica
convert: add bzr source
r7053 def has_bzr():
return matchoutput('bzr --version 2>&1', r'Bazaar \(bzr\)')
Patrick Mezard
hghave: detect cvs and cvsps availability...
r5302 def has_cvs():
Dirkjan Ochtman
tests: don't run test-convert-cvs if there's no cvs server
r6626 re = r'Concurrent Versions System.*?server'
return matchoutput('cvs --version 2>&1', re)
Patrick Mezard
hghave: detect cvs and cvsps availability...
r5302
def has_cvsps():
return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True)
Patrick Mezard
hghave: detect darcs client
r5410 def has_darcs():
Thomas Arendsen Hein
Skip older monotone versions for tests....
r6384 return matchoutput('darcs', r'darcs version', True)
Patrick Mezard
hghave: detect darcs client
r5410
Patrick Mezard
Add a test for monotone conversion
r6372 def has_mtn():
Thomas Arendsen Hein
Skip older monotone versions for tests....
r6384 return matchoutput('mtn --version', r'monotone', True) and not matchoutput(
'mtn --version', r'monotone 0\.(\d|[12]\d|3[01])[^\d]', True)
Patrick Mezard
Add a test for monotone conversion
r6372
Patrick Mezard
hghave: reorder check functions and entries
r5409 def has_eol_in_paths():
try:
fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r')
os.close(fd)
os.remove(path)
return True
except:
return False
Patrick Mezard
hghave: detect executable permission availability.
r5072 def has_executablebit():
Patrick Mezard
hghave: prefix temporary files with "hg-hghave-"
r5090 fd, path = tempfile.mkstemp(prefix=tempprefix)
Patrick Mezard
hghave: detect executable permission availability.
r5072 os.close(fd)
try:
s = os.lstat(path).st_mode
os.chmod(path, s | 0100)
return (os.lstat(path).st_mode & 0100 != 0)
finally:
os.remove(path)
Patrick Mezard
Add test for case folding issues
r6806 def has_icasefs():
# Stolen from mercurial.util
fd, path = tempfile.mkstemp(prefix=tempprefix)
os.close(fd)
try:
s1 = os.stat(path)
d, b = os.path.split(path)
p2 = os.path.join(d, b.upper())
if path == p2:
p2 = os.path.join(d, b.lower())
try:
s2 = os.stat(p2)
return s2 == s1
except:
return False
finally:
Benoit Boissinot
merge with -stable
r6998 os.remove(path)
Benoit Boissinot
inotify: deactivate inotify status on failure...
r6996 def has_inotify():
try:
import hgext.inotify.linux.watcher
return True
except ImportError:
return False
Patrick Mezard
hghave: reorder check functions and entries
r5409 def has_fifo():
return hasattr(os, "mkfifo")
Patrick Mezard
hghave: detect support for EOL in paths.
r5074
Patrick Mezard
test-profile: fix grep, check hotshot availability
r5102 def has_hotshot():
try:
Patrick Mezard
hghave: test hotshot dependencies (debian does not provide profile)
r5103 # hotshot.stats tests hotshot and many problematic dependencies
# like profile.
import hotshot.stats
Patrick Mezard
test-profile: fix grep, check hotshot availability
r5102 return True
except ImportError:
return False
Patrick Mezard
Test --time, --profile and --lsprof
r5099 def has_lsprof():
try:
import _lsprof
return True
except ImportError:
return False
Patrick Mezard
hghave: detect git availability
r5218 def has_git():
Patrick Mezard
hghave: wrap command output matching
r5252 return matchoutput('git --version 2>&1', r'^git version')
Patrick Mezard
hghave: detect git availability
r5218
Patrick Mezard
hghave: detect subversion client and admin tools availability
r5253 def has_svn():
return matchoutput('svn --version 2>&1', r'^svn, version') and \
matchoutput('svnadmin --version 2>&1', r'^svnadmin, version')
Patrick Mezard
hghave: detect subversion bindings availability
r5254 def has_svn_bindings():
try:
import svn.core
return True
except ImportError:
return False
Patrick Mezard
hghave: reorder check functions and entries
r5409 def has_symlink():
return hasattr(os, "symlink")
Aleix Conchillo Flaque
convert: added GNU Arch (tla) tests and related fixes
r6079 def has_tla():
return matchoutput('tla --version 2>&1', r'The GNU Arch Revision')
Alexis S. L. Carvalho
hghave: detect unix-style permissions...
r6063 def has_unix_permissions():
d = tempfile.mkdtemp(prefix=tempprefix, dir=".")
try:
fname = os.path.join(d, 'foo')
for umask in (077, 007, 022):
os.umask(umask)
f = open(fname, 'w')
f.close()
mode = os.stat(fname).st_mode
os.unlink(fname)
if mode & 0777 != ~umask & 0666:
return False
return True
finally:
os.rmdir(d)
Dirkjan Ochtman
tests: add highlight extension tests
r6355 def has_pygments():
try:
import pygments
return True
except ImportError:
return False
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 checks = {
Aleix Conchillo Flaque
convert: added gnu arch (baz) tests
r6078 "baz": (has_baz, "GNU Arch baz client"),
Marek Kubica
convert: add bzr source
r7053 "bzr": (has_bzr, "Canonical's Bazaar client"),
Dirkjan Ochtman
tests: don't run test-convert-cvs if there's no cvs server
r6626 "cvs": (has_cvs, "cvs client/server"),
Patrick Mezard
hghave: detect cvs and cvsps availability...
r5302 "cvsps": (has_cvsps, "cvsps utility"),
Patrick Mezard
hghave: detect darcs client
r5410 "darcs": (has_darcs, "darcs client"),
Patrick Mezard
Test --time, --profile and --lsprof
r5099 "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
"execbit": (has_executablebit, "executable bit"),
Patrick Mezard
hghave: reorder check functions and entries
r5409 "fifo": (has_fifo, "named pipes"),
Patrick Mezard
hghave: detect git availability
r5218 "git": (has_git, "git command line client"),
Patrick Mezard
test-profile: fix grep, check hotshot availability
r5102 "hotshot": (has_hotshot, "python hotshot module"),
Patrick Mezard
Add test for case folding issues
r6806 "icasefs": (has_icasefs, "case insensitive file system"),
Benoit Boissinot
inotify: deactivate inotify status on failure...
r6996 "inotify": (has_inotify, "inotify extension support"),
Patrick Mezard
Test --time, --profile and --lsprof
r5099 "lsprof": (has_lsprof, "python lsprof module"),
Thomas Arendsen Hein
Skip older monotone versions for tests....
r6384 "mtn": (has_mtn, "monotone client (> 0.31)"),
Benoit Boissinot
inotify: deactivate inotify status on failure...
r6996 "pygments": (has_pygments, "Pygments source highlighting library"),
Patrick Mezard
hghave: detect subversion client and admin tools availability
r5253 "svn": (has_svn, "subversion client and admin tools"),
Patrick Mezard
hghave: detect subversion bindings availability
r5254 "svn-bindings": (has_svn_bindings, "subversion python bindings"),
Patrick Mezard
Test --time, --profile and --lsprof
r5099 "symlink": (has_symlink, "symbolic links"),
Aleix Conchillo Flaque
convert: added GNU Arch (tla) tests and related fixes
r6079 "tla": (has_tla, "GNU Arch tla client"),
Alexis S. L. Carvalho
hghave: detect unix-style permissions...
r6063 "unix-permissions": (has_unix_permissions, "unix-style permissions"),
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 }
def list_features():
for name, feature in checks.iteritems():
desc = feature[1]
print name + ':', desc
parser = optparse.OptionParser("%prog [options] [features]")
parser.add_option("--list-features", action="store_true",
help="list available features")
parser.add_option("-q", "--quiet", action="store_true",
help="check features silently")
if __name__ == '__main__':
options, args = parser.parse_args()
if options.list_features:
list_features()
sys.exit(0)
Thomas Arendsen Hein
Remove trailing spaces
r5081
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 quiet = options.quiet
failures = 0
def error(msg):
global failures
if not quiet:
sys.stderr.write(msg + '\n')
failures += 1
Thomas Arendsen Hein
Remove trailing spaces
r5081
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 for feature in args:
Patrick Mezard
hghave: feature absence can be checked by prefixing with 'no-'
r5084 negate = feature.startswith('no-')
if negate:
feature = feature[3:]
Thomas Arendsen Hein
Hide absolute path from test-no-symlinks output....
r5091
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 if feature not in checks:
Thomas Arendsen Hein
Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
r5685 error('skipped: unknown feature: ' + feature)
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 continue
Thomas Arendsen Hein
Remove trailing spaces
r5081
check, desc = checks[feature]
Patrick Mezard
hghave: feature absence can be checked by prefixing with 'no-'
r5084 if not negate and not check():
Thomas Arendsen Hein
Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
r5685 error('skipped: missing feature: ' + desc)
Patrick Mezard
hghave: feature absence can be checked by prefixing with 'no-'
r5084 elif negate and check():
Thomas Arendsen Hein
Use skipped: instead of hghave: for skipping tests, use this in test-merge-types
r5685 error('skipped: system supports %s' % desc)
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881
if failures != 0:
sys.exit(1)
Thomas Arendsen Hein
Remove trailing spaces
r5081