##// END OF EJS Templates
Add test for case folding issues
Patrick Mezard -
r6806:2134d6c0 default
parent child Browse files
Show More
@@ -0,0 +1,41 b''
1 #!/bin/sh
2
3 "$TESTDIR/hghave" icasefs || exit 80
4
5 echo '% test file addition with bad case'
6 hg init repo1
7 cd repo1
8 echo a > a
9 hg add A
10 hg st
11 hg ci -m adda
12 hg manifest
13 cd ..
14
15 echo '% test case collision on rename (issue 750)'
16 hg init repo2
17 cd repo2
18 echo a > a
19 hg --debug ci -Am adda
20 hg mv a A
21 # 'a' used to be removed under windows
22 test -f a || echo 'a is missing'
23 hg st
24 cd ..
25
26 echo '% test case collision between revisions (issue 912)'
27 hg init repo3
28 cd repo3
29 echo a > a
30 hg ci -Am adda
31 hg rm a
32 hg ci -Am removea
33 echo A > A
34 hg ci -Am addA
35 # Used to fail under case insensitive fs
36 hg up -C 0
37 hg up -C
38 cd ..
39
40
41
@@ -0,0 +1,13 b''
1 % test file addition with bad case
2 adding a
3 A a
4 a
5 % test case collision on rename (issue 750)
6 adding a
7 a
8 A: not overwriting - file exists
9 % test case collision between revisions (issue 912)
10 adding a
11 adding A
12 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
13 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
@@ -1,187 +1,206 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
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
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-'
13
13
14 def matchoutput(cmd, regexp, ignorestatus=False):
14 def matchoutput(cmd, regexp, ignorestatus=False):
15 """Return True if cmd executes successfully and its output
15 """Return True if cmd executes successfully and its output
16 is matched by the supplied regular expression.
16 is matched by the supplied regular expression.
17 """
17 """
18 r = re.compile(regexp)
18 r = re.compile(regexp)
19 fh = os.popen(cmd)
19 fh = os.popen(cmd)
20 s = fh.read()
20 s = fh.read()
21 ret = fh.close()
21 ret = fh.close()
22 return (ignorestatus or ret is None) and r.search(s)
22 return (ignorestatus or ret is None) and r.search(s)
23
23
24 def has_baz():
24 def has_baz():
25 return matchoutput('baz --version 2>&1', r'baz Bazaar version')
25 return matchoutput('baz --version 2>&1', r'baz Bazaar version')
26
26
27 def has_cvs():
27 def has_cvs():
28 re = r'Concurrent Versions System.*?server'
28 re = r'Concurrent Versions System.*?server'
29 return matchoutput('cvs --version 2>&1', re)
29 return matchoutput('cvs --version 2>&1', re)
30
30
31 def has_cvsps():
31 def has_cvsps():
32 return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True)
32 return matchoutput('cvsps -h -q 2>&1', r'cvsps version', True)
33
33
34 def has_darcs():
34 def has_darcs():
35 return matchoutput('darcs', r'darcs version', True)
35 return matchoutput('darcs', r'darcs version', True)
36
36
37 def has_mtn():
37 def has_mtn():
38 return matchoutput('mtn --version', r'monotone', True) and not matchoutput(
38 return matchoutput('mtn --version', r'monotone', True) and not matchoutput(
39 'mtn --version', r'monotone 0\.(\d|[12]\d|3[01])[^\d]', True)
39 'mtn --version', r'monotone 0\.(\d|[12]\d|3[01])[^\d]', True)
40
40
41 def has_eol_in_paths():
41 def has_eol_in_paths():
42 try:
42 try:
43 fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r')
43 fd, path = tempfile.mkstemp(prefix=tempprefix, suffix='\n\r')
44 os.close(fd)
44 os.close(fd)
45 os.remove(path)
45 os.remove(path)
46 return True
46 return True
47 except:
47 except:
48 return False
48 return False
49
49
50 def has_executablebit():
50 def has_executablebit():
51 fd, path = tempfile.mkstemp(prefix=tempprefix)
51 fd, path = tempfile.mkstemp(prefix=tempprefix)
52 os.close(fd)
52 os.close(fd)
53 try:
53 try:
54 s = os.lstat(path).st_mode
54 s = os.lstat(path).st_mode
55 os.chmod(path, s | 0100)
55 os.chmod(path, s | 0100)
56 return (os.lstat(path).st_mode & 0100 != 0)
56 return (os.lstat(path).st_mode & 0100 != 0)
57 finally:
57 finally:
58 os.remove(path)
58 os.remove(path)
59
59
60 def has_icasefs():
61 # Stolen from mercurial.util
62 fd, path = tempfile.mkstemp(prefix=tempprefix)
63 os.close(fd)
64 try:
65 s1 = os.stat(path)
66 d, b = os.path.split(path)
67 p2 = os.path.join(d, b.upper())
68 if path == p2:
69 p2 = os.path.join(d, b.lower())
70 try:
71 s2 = os.stat(p2)
72 return s2 == s1
73 except:
74 return False
75 finally:
76 os.remove(path)
77
60 def has_fifo():
78 def has_fifo():
61 return hasattr(os, "mkfifo")
79 return hasattr(os, "mkfifo")
62
80
63 def has_hotshot():
81 def has_hotshot():
64 try:
82 try:
65 # hotshot.stats tests hotshot and many problematic dependencies
83 # hotshot.stats tests hotshot and many problematic dependencies
66 # like profile.
84 # like profile.
67 import hotshot.stats
85 import hotshot.stats
68 return True
86 return True
69 except ImportError:
87 except ImportError:
70 return False
88 return False
71
89
72 def has_lsprof():
90 def has_lsprof():
73 try:
91 try:
74 import _lsprof
92 import _lsprof
75 return True
93 return True
76 except ImportError:
94 except ImportError:
77 return False
95 return False
78
96
79 def has_git():
97 def has_git():
80 return matchoutput('git --version 2>&1', r'^git version')
98 return matchoutput('git --version 2>&1', r'^git version')
81
99
82 def has_svn():
100 def has_svn():
83 return matchoutput('svn --version 2>&1', r'^svn, version') and \
101 return matchoutput('svn --version 2>&1', r'^svn, version') and \
84 matchoutput('svnadmin --version 2>&1', r'^svnadmin, version')
102 matchoutput('svnadmin --version 2>&1', r'^svnadmin, version')
85
103
86 def has_svn_bindings():
104 def has_svn_bindings():
87 try:
105 try:
88 import svn.core
106 import svn.core
89 return True
107 return True
90 except ImportError:
108 except ImportError:
91 return False
109 return False
92
110
93 def has_symlink():
111 def has_symlink():
94 return hasattr(os, "symlink")
112 return hasattr(os, "symlink")
95
113
96 def has_tla():
114 def has_tla():
97 return matchoutput('tla --version 2>&1', r'The GNU Arch Revision')
115 return matchoutput('tla --version 2>&1', r'The GNU Arch Revision')
98
116
99 def has_unix_permissions():
117 def has_unix_permissions():
100 d = tempfile.mkdtemp(prefix=tempprefix, dir=".")
118 d = tempfile.mkdtemp(prefix=tempprefix, dir=".")
101 try:
119 try:
102 fname = os.path.join(d, 'foo')
120 fname = os.path.join(d, 'foo')
103 for umask in (077, 007, 022):
121 for umask in (077, 007, 022):
104 os.umask(umask)
122 os.umask(umask)
105 f = open(fname, 'w')
123 f = open(fname, 'w')
106 f.close()
124 f.close()
107 mode = os.stat(fname).st_mode
125 mode = os.stat(fname).st_mode
108 os.unlink(fname)
126 os.unlink(fname)
109 if mode & 0777 != ~umask & 0666:
127 if mode & 0777 != ~umask & 0666:
110 return False
128 return False
111 return True
129 return True
112 finally:
130 finally:
113 os.rmdir(d)
131 os.rmdir(d)
114
132
115 def has_pygments():
133 def has_pygments():
116 try:
134 try:
117 import pygments
135 import pygments
118 return True
136 return True
119 except ImportError:
137 except ImportError:
120 return False
138 return False
121
139
122 checks = {
140 checks = {
123 "baz": (has_baz, "GNU Arch baz client"),
141 "baz": (has_baz, "GNU Arch baz client"),
124 "cvs": (has_cvs, "cvs client/server"),
142 "cvs": (has_cvs, "cvs client/server"),
125 "cvsps": (has_cvsps, "cvsps utility"),
143 "cvsps": (has_cvsps, "cvsps utility"),
126 "darcs": (has_darcs, "darcs client"),
144 "darcs": (has_darcs, "darcs client"),
127 "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
145 "eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
128 "execbit": (has_executablebit, "executable bit"),
146 "execbit": (has_executablebit, "executable bit"),
129 "fifo": (has_fifo, "named pipes"),
147 "fifo": (has_fifo, "named pipes"),
130 "git": (has_git, "git command line client"),
148 "git": (has_git, "git command line client"),
131 "hotshot": (has_hotshot, "python hotshot module"),
149 "hotshot": (has_hotshot, "python hotshot module"),
150 "icasefs": (has_icasefs, "case insensitive file system"),
132 "lsprof": (has_lsprof, "python lsprof module"),
151 "lsprof": (has_lsprof, "python lsprof module"),
133 "mtn": (has_mtn, "monotone client (> 0.31)"),
152 "mtn": (has_mtn, "monotone client (> 0.31)"),
134 "svn": (has_svn, "subversion client and admin tools"),
153 "svn": (has_svn, "subversion client and admin tools"),
135 "svn-bindings": (has_svn_bindings, "subversion python bindings"),
154 "svn-bindings": (has_svn_bindings, "subversion python bindings"),
136 "symlink": (has_symlink, "symbolic links"),
155 "symlink": (has_symlink, "symbolic links"),
137 "tla": (has_tla, "GNU Arch tla client"),
156 "tla": (has_tla, "GNU Arch tla client"),
138 "unix-permissions": (has_unix_permissions, "unix-style permissions"),
157 "unix-permissions": (has_unix_permissions, "unix-style permissions"),
139 "pygments": (has_pygments, "Pygments source highlighting library"),
158 "pygments": (has_pygments, "Pygments source highlighting library"),
140 }
159 }
141
160
142 def list_features():
161 def list_features():
143 for name, feature in checks.iteritems():
162 for name, feature in checks.iteritems():
144 desc = feature[1]
163 desc = feature[1]
145 print name + ':', desc
164 print name + ':', desc
146
165
147 parser = optparse.OptionParser("%prog [options] [features]")
166 parser = optparse.OptionParser("%prog [options] [features]")
148 parser.add_option("--list-features", action="store_true",
167 parser.add_option("--list-features", action="store_true",
149 help="list available features")
168 help="list available features")
150 parser.add_option("-q", "--quiet", action="store_true",
169 parser.add_option("-q", "--quiet", action="store_true",
151 help="check features silently")
170 help="check features silently")
152
171
153 if __name__ == '__main__':
172 if __name__ == '__main__':
154 options, args = parser.parse_args()
173 options, args = parser.parse_args()
155 if options.list_features:
174 if options.list_features:
156 list_features()
175 list_features()
157 sys.exit(0)
176 sys.exit(0)
158
177
159 quiet = options.quiet
178 quiet = options.quiet
160
179
161 failures = 0
180 failures = 0
162
181
163 def error(msg):
182 def error(msg):
164 global failures
183 global failures
165 if not quiet:
184 if not quiet:
166 sys.stderr.write(msg + '\n')
185 sys.stderr.write(msg + '\n')
167 failures += 1
186 failures += 1
168
187
169 for feature in args:
188 for feature in args:
170 negate = feature.startswith('no-')
189 negate = feature.startswith('no-')
171 if negate:
190 if negate:
172 feature = feature[3:]
191 feature = feature[3:]
173
192
174 if feature not in checks:
193 if feature not in checks:
175 error('skipped: unknown feature: ' + feature)
194 error('skipped: unknown feature: ' + feature)
176 continue
195 continue
177
196
178 check, desc = checks[feature]
197 check, desc = checks[feature]
179 if not negate and not check():
198 if not negate and not check():
180 error('skipped: missing feature: ' + desc)
199 error('skipped: missing feature: ' + desc)
181 elif negate and check():
200 elif negate and check():
182 error('skipped: system supports %s' % desc)
201 error('skipped: system supports %s' % desc)
183
202
184 if failures != 0:
203 if failures != 0:
185 sys.exit(1)
204 sys.exit(1)
186
205
187
206
General Comments 0
You need to be logged in to leave comments. Login now