Mercurial > hg
comparison tests/hghave @ 16320:e11ab387e89c stable
tests: make hghave handle exec bit on Linux with vfat
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 31 Mar 2012 10:44:31 -0500 |
parents | ac0da5caebec |
children | e14d7805845d |
comparison
equal
deleted
inserted
replaced
16319:ac0da5caebec | 16320:e11ab387e89c |
---|---|
2 """Test the running system for features availability. Exit with zero | 2 """Test the running system for features availability. Exit with zero |
3 if all features are there, non-zero otherwise. If a feature name is | 3 if all features are there, non-zero otherwise. If a feature name is |
4 prefixed with "no-", the absence of feature is tested. | 4 prefixed with "no-", the absence of feature is tested. |
5 """ | 5 """ |
6 import optparse | 6 import optparse |
7 import os | 7 import os, stat |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
11 | 11 |
12 tempprefix = 'hg-hghave-' | 12 tempprefix = 'hg-hghave-' |
62 return True | 62 return True |
63 except: | 63 except: |
64 return False | 64 return False |
65 | 65 |
66 def has_executablebit(): | 66 def has_executablebit(): |
67 fd, path = tempfile.mkstemp(prefix=tempprefix) | 67 try: |
68 os.close(fd) | 68 EXECFLAGS = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
69 try: | 69 fh, fn = tempfile.mkstemp(dir=".", prefix='hg-checkexec-') |
70 s = os.lstat(path).st_mode | 70 try: |
71 os.chmod(path, s | 0100) | 71 os.close(fh) |
72 return (os.lstat(path).st_mode & 0100 != 0) | 72 m = os.stat(fn).st_mode & 0777 |
73 finally: | 73 new_file_has_exec = m & EXECFLAGS |
74 os.remove(path) | 74 os.chmod(fn, m ^ EXECFLAGS) |
75 exec_flags_cannot_flip = ((os.stat(fn).st_mode & 0777) == m) | |
76 finally: | |
77 os.unlink(fn) | |
78 except (IOError, OSError): | |
79 # we don't care, the user probably won't be able to commit anyway | |
80 return False | |
81 return not (new_file_has_exec or exec_flags_cannot_flip) | |
75 | 82 |
76 def has_icasefs(): | 83 def has_icasefs(): |
77 # Stolen from mercurial.util | 84 # Stolen from mercurial.util |
78 fd, path = tempfile.mkstemp(prefix=tempprefix, dir='.') | 85 fd, path = tempfile.mkstemp(prefix=tempprefix, dir='.') |
79 os.close(fd) | 86 os.close(fd) |