t3800: make hash-size independent
Replace references to several hard-coded object IDs with a variable referring to the generated commit. Avoid matching on exact character positions, which will be different depending on the hash in use. In the test for a valid object ID, use an obviously invalid one from the lookup table. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Aug 18, 2019 at 19:16 UTC
acb49d1cc8b1f4a59af1071791f2751383464f0b
1 file changed
+25
-24
t/t3800-mktag.sh
+25
-24
@@ -23,6 +23,7 @@ check_verify_failure () {
23
# first create a commit, so we have a valid object/type
24
# for the tag.
25
test_expect_success 'setup' '
26
+ test_oid_init &&
27
echo Hello >A &&
28
git update-index --add A &&
29
git commit -m "Initial commit" &&
@@ -69,28 +70,28 @@ check_verify_failure '"object" line SHA1 check' '^error: char7: .*SHA1 hash$'
70
# 4. type line label check
71
72
cat >tag.sig <<EOF
72
-object 779e9b33986b1c2670fff52c5067603117b3e895
73
+object $head
74
xxxx tag
75
tag mytag
76
tagger . <> 0 +0000
77
78
EOF
79
79
-check_verify_failure '"type" line label check' '^error: char47: .*"\\ntype "$'
80
+check_verify_failure '"type" line label check' '^error: char.*: .*"\\ntype "$'
81
82
############################################################
83
# 5. type line eol check
84
84
-echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
85
+echo "object $head" >tag.sig
86
printf "type tagsssssssssssssssssssssssssssssss" >>tag.sig
87
87
-check_verify_failure '"type" line eol check' '^error: char48: .*"\\n"$'
88
+check_verify_failure '"type" line eol check' '^error: char.*: .*"\\n"$'
89
90
############################################################
91
# 6. tag line label check #1
92
93
cat >tag.sig <<EOF
93
-object 779e9b33986b1c2670fff52c5067603117b3e895
94
+object $head
95
type tag
96
xxx mytag
97
tagger . <> 0 +0000
@@ -98,37 +99,37 @@ tagger . <> 0 +0000
99
EOF
100
101
check_verify_failure '"tag" line label check #1' \
101
- '^error: char57: no "tag " found$'
102
+ '^error: char.*: no "tag " found$'
103
104
############################################################
105
# 7. tag line label check #2
106
107
cat >tag.sig <<EOF
107
-object 779e9b33986b1c2670fff52c5067603117b3e895
108
+object $head
109
type taggggggggggggggggggggggggggggggg
110
tag
111
EOF
112
113
check_verify_failure '"tag" line label check #2' \
113
- '^error: char87: no "tag " found$'
114
+ '^error: char.*: no "tag " found$'
115
116
############################################################
117
# 8. type line type-name length check
118
119
cat >tag.sig <<EOF
119
-object 779e9b33986b1c2670fff52c5067603117b3e895
120
+object $head
121
type taggggggggggggggggggggggggggggggg
122
tag mytag
123
EOF
124
125
check_verify_failure '"type" line type-name length check' \
125
- '^error: char53: type too long$'
126
+ '^error: char.*: type too long$'
127
128
############################################################
129
# 9. verify object (SHA1/type) check
130
131
cat >tag.sig <<EOF
131
-object 779e9b33986b1c2670fff52c5067603117b3e895
132
+object $(test_oid deadbeef)
133
type tagggg
134
tag mytag
135
tagger . <> 0 +0000
@@ -150,7 +151,7 @@ tagger . <> 0 +0000
151
EOF
152
153
check_verify_failure 'verify tag-name check' \
153
- '^error: char67: could not verify tag name$'
154
+ '^error: char.*: could not verify tag name$'
155
156
############################################################
157
# 11. tagger line label check #1
@@ -164,7 +165,7 @@ This is filler
165
EOF
166
167
check_verify_failure '"tagger" line label check #1' \
167
- '^error: char70: could not find "tagger "$'
168
+ '^error: char.*: could not find "tagger "$'
169
170
############################################################
171
# 12. tagger line label check #2
@@ -179,7 +180,7 @@ This is filler
180
EOF
181
182
check_verify_failure '"tagger" line label check #2' \
182
- '^error: char70: could not find "tagger "$'
183
+ '^error: char.*: could not find "tagger "$'
184
185
############################################################
186
# 13. disallow missing tag author name
@@ -194,7 +195,7 @@ This is filler
195
EOF
196
197
check_verify_failure 'disallow missing tag author name' \
197
- '^error: char77: missing tagger name$'
198
+ '^error: char.*: missing tagger name$'
199
200
############################################################
201
# 14. disallow missing tag author name
@@ -209,7 +210,7 @@ tagger T A Gger <
210
EOF
211
212
check_verify_failure 'disallow malformed tagger' \
212
- '^error: char77: malformed tagger field$'
213
+ '^error: char.*: malformed tagger field$'
214
215
############################################################
216
# 15. allow empty tag email
@@ -238,7 +239,7 @@ tagger T A Gger <tag ger@example.com> 0 +0000
239
EOF
240
241
check_verify_failure 'disallow spaces in tag email' \
241
- '^error: char77: malformed tagger field$'
242
+ '^error: char.*: malformed tagger field$'
243
244
############################################################
245
# 17. disallow missing tag timestamp
@@ -252,7 +253,7 @@ tagger T A Gger <tagger@example.com>__
253
EOF
254
255
check_verify_failure 'disallow missing tag timestamp' \
255
- '^error: char107: missing tag timestamp$'
256
+ '^error: char.*: missing tag timestamp$'
257
258
############################################################
259
# 18. detect invalid tag timestamp1
@@ -266,7 +267,7 @@ tagger T A Gger <tagger@example.com> Tue Mar 25 15:47:44 2008
267
EOF
268
269
check_verify_failure 'detect invalid tag timestamp1' \
269
- '^error: char107: missing tag timestamp$'
270
+ '^error: char.*: missing tag timestamp$'
271
272
############################################################
273
# 19. detect invalid tag timestamp2
@@ -280,7 +281,7 @@ tagger T A Gger <tagger@example.com> 2008-03-31T12:20:15-0500
281
EOF
282
283
check_verify_failure 'detect invalid tag timestamp2' \
283
- '^error: char111: malformed tag timestamp$'
284
+ '^error: char.*: malformed tag timestamp$'
285
286
############################################################
287
# 20. detect invalid tag timezone1
@@ -294,7 +295,7 @@ tagger T A Gger <tagger@example.com> 1206478233 GMT
295
EOF
296
297
check_verify_failure 'detect invalid tag timezone1' \
297
- '^error: char118: malformed tag timezone$'
298
+ '^error: char.*: malformed tag timezone$'
299
300
############################################################
301
# 21. detect invalid tag timezone2
@@ -308,7 +309,7 @@ tagger T A Gger <tagger@example.com> 1206478233 + 30
309
EOF
310
311
check_verify_failure 'detect invalid tag timezone2' \
311
- '^error: char118: malformed tag timezone$'
312
+ '^error: char.*: malformed tag timezone$'
313
314
############################################################
315
# 22. detect invalid tag timezone3
@@ -322,7 +323,7 @@ tagger T A Gger <tagger@example.com> 1206478233 -1430
323
EOF
324
325
check_verify_failure 'detect invalid tag timezone3' \
325
- '^error: char118: malformed tag timezone$'
326
+ '^error: char.*: malformed tag timezone$'
327
328
############################################################
329
# 23. detect invalid header entry
@@ -337,7 +338,7 @@ this line should not be here
338
EOF
339
340
check_verify_failure 'detect invalid header entry' \
340
- '^error: char124: trailing garbage in tag header$'
341
+ '^error: char.*: trailing garbage in tag header$'
342
343
############################################################
344
# 24. create valid tag