##// END OF EJS Templates
Fix hgwebdir after 9858477ed74cce9dc8f4069f9453a1bda0e13ba1 broke it.
Fix hgwebdir after 9858477ed74cce9dc8f4069f9453a1bda0e13ba1 broke it.

File last commit:

r5081:ea7b982b default
r5083:f94dbc6c default
Show More
hghave
81 lines | 1.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
if all features are there, non-zero otherwise.
"""
import optparse
import os
import sys
Patrick Mezard
hghave: detect executable permission availability.
r5072 import tempfile
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881
def has_symlink():
return hasattr(os, "symlink")
Patrick Mezard
hghave: detect FIFO availability
r5070 def has_fifo():
return hasattr(os, "mkfifo")
Patrick Mezard
hghave: detect executable permission availability.
r5072 def has_executablebit():
fd, path = tempfile.mkstemp()
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
hghave: detect support for EOL in paths.
r5074 def has_eol_in_paths():
try:
fd, path = tempfile.mkstemp(suffix='\n\r')
os.close(fd)
os.remove(path)
return True
except:
return False
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 checks = {
"symlink": (has_symlink, "symbolic links"),
Patrick Mezard
hghave: detect FIFO availability
r5070 "fifo": (has_fifo, "named pipes"),
Patrick Mezard
hghave: detect executable permission availability.
r5072 "execbit": (has_executablebit, "executable bit"),
Patrick Mezard
hghave: detect support for EOL in paths.
r5074 "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
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:
if feature not in checks:
error('hghave: unknown feature: ' + feature)
continue
Thomas Arendsen Hein
Remove trailing spaces
r5081
check, desc = checks[feature]
Patrick Mezard
Add hghave utility and run-tests.py support....
r4881 if not check():
error('hghave: missing feature: ' + desc)
if failures != 0:
sys.exit(1)
Thomas Arendsen Hein
Remove trailing spaces
r5081