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