t1402-check-ref-format: skip tests of refs beginning with slash on Windows
Bash on Windows converts program arguments that look like absolute POSIX paths to their Windows form, i.e., drive-letter-colon format. For this reason, those tests in t1402 that check refs that begin with a slash do not work as expected on Windows: valid_ref tests are doomed to fail, and invalid_ref tests fail for the wrong reason (that there is a colon rather than that they begin with a slash). Skip these tests. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Oct 13, 2011 at 10:06 UTC
42afe62df449021fcb501f9df09f8ecfaa764d25
1 file changed
+52
-36
t/t1402-check-ref-format.sh
+52
-36
@@ -5,38 +5,40 @@ test_description='Test git check-ref-format'
5
. ./test-lib.sh
6
7
valid_ref() {
8
- if test "$#" = 1
9
- then
10
- test_expect_success "ref name '$1' is valid" \
11
- "git check-ref-format '$1'"
12
- else
13
- test_expect_success "ref name '$1' is valid with options $2" \
14
- "git check-ref-format $2 '$1'"
15
- fi
8
+ prereq=
9
+ case $1 in
10
+ [A-Z]*)
11
+ prereq=$1
12
+ shift
13
+ esac
14
+ test_expect_success $prereq "ref name '$1' is valid${2:+ with options $2}" "
15
+ git check-ref-format $2 '$1'
16
+ "
17
}
18
invalid_ref() {
18
- if test "$#" = 1
19
- then
20
- test_expect_success "ref name '$1' is invalid" \
21
- "test_must_fail git check-ref-format '$1'"
22
- else
23
- test_expect_success "ref name '$1' is invalid with options $2" \
24
- "test_must_fail git check-ref-format $2 '$1'"
25
- fi
19
+ prereq=
20
+ case $1 in
21
+ [A-Z]*)
22
+ prereq=$1
23
+ shift
24
+ esac
25
+ test_expect_success $prereq "ref name '$1' is invalid${2:+ with options $2}" "
26
+ test_must_fail git check-ref-format $2 '$1'
27
+ "
28
}
29
30
invalid_ref ''
29
-invalid_ref '/'
30
-invalid_ref '/' --allow-onelevel
31
-invalid_ref '/' --normalize
32
-invalid_ref '/' '--allow-onelevel --normalize'
31
+invalid_ref NOT_MINGW '/'
32
+invalid_ref NOT_MINGW '/' --allow-onelevel
33
+invalid_ref NOT_MINGW '/' --normalize
34
+invalid_ref NOT_MINGW '/' '--allow-onelevel --normalize'
35
valid_ref 'foo/bar/baz'
36
valid_ref 'foo/bar/baz' --normalize
37
invalid_ref 'refs///heads/foo'
38
valid_ref 'refs///heads/foo' --normalize
39
invalid_ref 'heads/foo/'
38
-invalid_ref '/heads/foo'
39
-valid_ref '/heads/foo' --normalize
40
+invalid_ref NOT_MINGW '/heads/foo'
41
+valid_ref NOT_MINGW '/heads/foo' --normalize
42
invalid_ref '///heads/foo'
43
valid_ref '///heads/foo' --normalize
44
invalid_ref './foo'
@@ -115,14 +117,14 @@ invalid_ref "$ref" --refspec-pattern
117
invalid_ref "$ref" '--refspec-pattern --allow-onelevel'
118
119
ref='/foo'
118
-invalid_ref "$ref"
119
-invalid_ref "$ref" --allow-onelevel
120
-invalid_ref "$ref" --refspec-pattern
121
-invalid_ref "$ref" '--refspec-pattern --allow-onelevel'
122
-invalid_ref "$ref" --normalize
123
-valid_ref "$ref" '--allow-onelevel --normalize'
124
-invalid_ref "$ref" '--refspec-pattern --normalize'
125
-valid_ref "$ref" '--refspec-pattern --allow-onelevel --normalize'
120
+invalid_ref NOT_MINGW "$ref"
121
+invalid_ref NOT_MINGW "$ref" --allow-onelevel
122
+invalid_ref NOT_MINGW "$ref" --refspec-pattern
123
+invalid_ref NOT_MINGW "$ref" '--refspec-pattern --allow-onelevel'
124
+invalid_ref NOT_MINGW "$ref" --normalize
125
+valid_ref NOT_MINGW "$ref" '--allow-onelevel --normalize'
126
+invalid_ref NOT_MINGW "$ref" '--refspec-pattern --normalize'
127
+valid_ref NOT_MINGW "$ref" '--refspec-pattern --allow-onelevel --normalize'
128
129
test_expect_success "check-ref-format --branch @{-1}" '
130
T=$(git write-tree) &&
@@ -155,21 +157,35 @@ test_expect_success 'check-ref-format --branch from subdir' '
157
'
158
159
valid_ref_normalized() {
158
- test_expect_success "ref name '$1' simplifies to '$2'" "
160
+ prereq=
161
+ case $1 in
162
+ [A-Z]*)
163
+ prereq=$1
164
+ shift
165
+ esac
166
+ test_expect_success $prereq "ref name '$1' simplifies to '$2'" "
167
refname=\$(git check-ref-format --normalize '$1') &&
160
- test \"\$refname\" = '$2'"
168
+ test \"\$refname\" = '$2'
169
+ "
170
}
171
invalid_ref_normalized() {
163
- test_expect_success "check-ref-format --normalize rejects '$1'" "
164
- test_must_fail git check-ref-format --normalize '$1'"
172
+ prereq=
173
+ case $1 in
174
+ [A-Z]*)
175
+ prereq=$1
176
+ shift
177
+ esac
178
+ test_expect_success $prereq "check-ref-format --normalize rejects '$1'" "
179
+ test_must_fail git check-ref-format --normalize '$1'
180
+ "
181
}
182
183
valid_ref_normalized 'heads/foo' 'heads/foo'
184
valid_ref_normalized 'refs///heads/foo' 'refs/heads/foo'
169
-valid_ref_normalized '/heads/foo' 'heads/foo'
185
+valid_ref_normalized NOT_MINGW '/heads/foo' 'heads/foo'
186
valid_ref_normalized '///heads/foo' 'heads/foo'
187
invalid_ref_normalized 'foo'
172
-invalid_ref_normalized '/foo'
188
+invalid_ref_normalized NOT_MINGW '/foo'
189
invalid_ref_normalized 'heads/foo/../bar'
190
invalid_ref_normalized 'heads/./foo'
191
invalid_ref_normalized 'heads\foo'