Mercurial > hg
comparison tests/hghave @ 5072:7e2385a31933
hghave: detect executable permission availability.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 06 Aug 2007 10:26:04 +0200 |
parents | 4cf6f8dbd1b4 |
children | e86788af599a |
comparison
equal
deleted
inserted
replaced
5071:1b970cdab695 | 5072:7e2385a31933 |
---|---|
3 if all features are there, non-zero otherwise. | 3 if all features are there, non-zero otherwise. |
4 """ | 4 """ |
5 import optparse | 5 import optparse |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 import tempfile | |
8 | 9 |
9 def has_symlink(): | 10 def has_symlink(): |
10 return hasattr(os, "symlink") | 11 return hasattr(os, "symlink") |
11 | 12 |
12 def has_fifo(): | 13 def has_fifo(): |
13 return hasattr(os, "mkfifo") | 14 return hasattr(os, "mkfifo") |
14 | 15 |
16 def has_executablebit(): | |
17 fd, path = tempfile.mkstemp() | |
18 os.close(fd) | |
19 try: | |
20 s = os.lstat(path).st_mode | |
21 os.chmod(path, s | 0100) | |
22 return (os.lstat(path).st_mode & 0100 != 0) | |
23 finally: | |
24 os.remove(path) | |
25 | |
15 checks = { | 26 checks = { |
16 "symlink": (has_symlink, "symbolic links"), | 27 "symlink": (has_symlink, "symbolic links"), |
17 "fifo": (has_fifo, "named pipes"), | 28 "fifo": (has_fifo, "named pipes"), |
29 "execbit": (has_executablebit, "executable bit"), | |
18 } | 30 } |
19 | 31 |
20 def list_features(): | 32 def list_features(): |
21 for name, feature in checks.iteritems(): | 33 for name, feature in checks.iteritems(): |
22 desc = feature[1] | 34 desc = feature[1] |