]>
Commit | Line | Data |
---|---|---|
e1970ce4 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Test the very basics part #1. | |
7 | ||
8 | The rest of the test suite does not check the basic operation of git | |
9 | plumbing commands to work very carefully. Their job is to concentrate | |
10 | on tricky features that caused bugs in the past to detect regression. | |
11 | ||
12 | This test runs very basic features, like registering things in cache, | |
13 | writing tree, etc. | |
14 | ||
15 | Note that this test *deliberately* hard-codes many expected object | |
16 | IDs. When object ID computation changes, like in the previous case of | |
17 | swapping compression and hashing order, the person who is making the | |
18 | modification *should* take notice and update the test vectors here. | |
19 | ' | |
eea42069 | 20 | |
e1970ce4 JH |
21 | . ./test-lib.sh |
22 | ||
01d3a526 MH |
23 | try_local_x () { |
24 | local x="local" && | |
25 | echo "$x" | |
26 | } | |
27 | ||
28 | # This test is an experiment to check whether any Git users are using | |
29 | # Shells that don't support the "local" keyword. "local" is not | |
30 | # POSIX-standard, but it is very widely supported by POSIX-compliant | |
31 | # shells, and if it doesn't cause problems for people, we would like | |
32 | # to be able to use it in Git code. | |
33 | # | |
34 | # For now, this is the only test that requires "local". If your shell | |
35 | # fails this test, you can ignore the failure, but please report the | |
36 | # problem to the Git mailing list <git@vger.kernel.org>, as it might | |
37 | # convince us to continue avoiding the use of "local". | |
38 | test_expect_success 'verify that the running shell supports "local"' ' | |
39 | x="notlocal" && | |
40 | echo "local" >expected1 && | |
41 | try_local_x >actual1 && | |
42 | test_cmp expected1 actual1 && | |
43 | echo "notlocal" >expected2 && | |
44 | echo "$x" >actual2 && | |
45 | test_cmp expected2 actual2 | |
46 | ' | |
47 | ||
e1970ce4 | 48 | ################################################################ |
5be60078 | 49 | # git init has been done in an empty repository. |
e1970ce4 JH |
50 | # make sure it is empty. |
51 | ||
1b5b2b64 SL |
52 | test_expect_success '.git/objects should be empty after git init in an empty repo' ' |
53 | find .git/objects -type f -print >should-be-empty && | |
54 | test_line_count = 0 should-be-empty | |
55 | ' | |
e1970ce4 | 56 | |
9106c097 LT |
57 | # also it should have 2 subdirectories; no fan-out anymore, pack, and info. |
58 | # 3 is counting "objects" itself | |
1b5b2b64 SL |
59 | test_expect_success '.git/objects should have 3 subdirectories' ' |
60 | find .git/objects -type d -print >full-of-directories && | |
61 | test_line_count = 3 full-of-directories | |
62 | ' | |
e1970ce4 | 63 | |
41ac414e JH |
64 | ################################################################ |
65 | # Test harness | |
66 | test_expect_success 'success is reported like this' ' | |
1b5b2b64 | 67 | : |
41ac414e | 68 | ' |
7b905119 | 69 | |
0445e6f0 IB |
70 | _run_sub_test_lib_test_common () { |
71 | neg="$1" name="$2" descr="$3" # stdin is the body of the test code | |
72 | shift 3 | |
565b6fa8 AS |
73 | mkdir "$name" && |
74 | ( | |
a63c12c9 JK |
75 | # Pretend we're not running under a test harness, whether we |
76 | # are or not. The test-lib output depends on the setting of | |
77 | # this variable, so we need a stable setting under which to run | |
78 | # the sub-test. | |
79 | sane_unset HARNESS_ACTIVE && | |
565b6fa8 AS |
80 | cd "$name" && |
81 | cat >"$name.sh" <<-EOF && | |
82 | #!$SHELL_PATH | |
83 | ||
84 | test_description='$descr (run in sub test-lib) | |
85 | ||
86 | This is run in a sub test-lib so that we do not get incorrect | |
87 | passing metrics | |
88 | ' | |
89 | ||
90 | # Point to the t/test-lib.sh, which isn't in ../ as usual | |
91 | . "\$TEST_DIRECTORY"/test-lib.sh | |
92 | EOF | |
93 | cat >>"$name.sh" && | |
94 | chmod +x "$name.sh" && | |
95 | export TEST_DIRECTORY && | |
68830470 JK |
96 | TEST_OUTPUT_DIRECTORY=$(pwd) && |
97 | export TEST_OUTPUT_DIRECTORY && | |
0445e6f0 IB |
98 | if test -z "$neg" |
99 | then | |
100 | ./"$name.sh" "$@" >out 2>err | |
101 | else | |
102 | ! ./"$name.sh" "$@" >out 2>err | |
103 | fi | |
565b6fa8 AS |
104 | ) |
105 | } | |
1b5b2b64 | 106 | |
0445e6f0 IB |
107 | run_sub_test_lib_test () { |
108 | _run_sub_test_lib_test_common '' "$@" | |
109 | } | |
110 | ||
111 | run_sub_test_lib_test_err () { | |
112 | _run_sub_test_lib_test_common '!' "$@" | |
113 | } | |
114 | ||
565b6fa8 AS |
115 | check_sub_test_lib_test () { |
116 | name="$1" # stdin is the expected output from the test | |
117 | ( | |
118 | cd "$name" && | |
ec10b018 | 119 | test_must_be_empty err && |
565b6fa8 AS |
120 | sed -e 's/^> //' -e 's/Z$//' >expect && |
121 | test_cmp expect out | |
122 | ) | |
123 | } | |
1b5b2b64 | 124 | |
0445e6f0 | 125 | check_sub_test_lib_test_err () { |
832c0e5e | 126 | name="$1" # stdin is the expected output from the test |
0445e6f0 IB |
127 | # expected error output is in descriptior 3 |
128 | ( | |
129 | cd "$name" && | |
130 | sed -e 's/^> //' -e 's/Z$//' >expect.out && | |
131 | test_cmp expect.out out && | |
132 | sed -e 's/^> //' -e 's/Z$//' <&3 >expect.err && | |
133 | test_cmp expect.err err | |
134 | ) | |
135 | } | |
136 | ||
5ebf89e8 AS |
137 | test_expect_success 'pretend we have a fully passing test suite' " |
138 | run_sub_test_lib_test full-pass '3 passing tests' <<-\\EOF && | |
139 | for i in 1 2 3 | |
140 | do | |
141 | test_expect_success \"passing test #\$i\" 'true' | |
142 | done | |
143 | test_done | |
144 | EOF | |
145 | check_sub_test_lib_test full-pass <<-\\EOF | |
146 | > ok 1 - passing test #1 | |
147 | > ok 2 - passing test #2 | |
148 | > ok 3 - passing test #3 | |
149 | > # passed all 3 test(s) | |
150 | > 1..3 | |
151 | EOF | |
152 | " | |
1b5b2b64 | 153 | |
5ebf89e8 AS |
154 | test_expect_success 'pretend we have a partially passing test suite' " |
155 | test_must_fail run_sub_test_lib_test \ | |
156 | partial-pass '2/3 tests passing' <<-\\EOF && | |
157 | test_expect_success 'passing test #1' 'true' | |
158 | test_expect_success 'failing test #2' 'false' | |
159 | test_expect_success 'passing test #3' 'true' | |
160 | test_done | |
161 | EOF | |
162 | check_sub_test_lib_test partial-pass <<-\\EOF | |
163 | > ok 1 - passing test #1 | |
164 | > not ok 2 - failing test #2 | |
165 | # false | |
166 | > ok 3 - passing test #3 | |
167 | > # failed 1 among 3 test(s) | |
168 | > 1..3 | |
169 | EOF | |
170 | " | |
1b5b2b64 | 171 | |
5ebf89e8 AS |
172 | test_expect_success 'pretend we have a known breakage' " |
173 | run_sub_test_lib_test failing-todo 'A failing TODO test' <<-\\EOF && | |
174 | test_expect_success 'passing test' 'true' | |
175 | test_expect_failure 'pretend we have a known breakage' 'false' | |
176 | test_done | |
177 | EOF | |
178 | check_sub_test_lib_test failing-todo <<-\\EOF | |
179 | > ok 1 - passing test | |
180 | > not ok 2 - pretend we have a known breakage # TODO known breakage | |
181 | > # still have 1 known breakage(s) | |
182 | > # passed all remaining 1 test(s) | |
183 | > 1..2 | |
184 | EOF | |
185 | " | |
1b5b2b64 | 186 | |
565b6fa8 AS |
187 | test_expect_success 'pretend we have fixed a known breakage' " |
188 | run_sub_test_lib_test passing-todo 'A passing TODO test' <<-\\EOF && | |
189 | test_expect_failure 'pretend we have fixed a known breakage' 'true' | |
1b5b2b64 SL |
190 | test_done |
191 | EOF | |
565b6fa8 | 192 | check_sub_test_lib_test passing-todo <<-\\EOF |
b73d9a23 AS |
193 | > ok 1 - pretend we have fixed a known breakage # TODO known breakage vanished |
194 | > # 1 known breakage(s) vanished; please update test(s) | |
1b5b2b64 SL |
195 | > 1..1 |
196 | EOF | |
7b905119 | 197 | " |
565b6fa8 | 198 | |
b73d9a23 AS |
199 | test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' " |
200 | run_sub_test_lib_test partially-passing-todos \ | |
201 | '2 TODO tests, one passing' <<-\\EOF && | |
202 | test_expect_failure 'pretend we have a known breakage' 'false' | |
203 | test_expect_success 'pretend we have a passing test' 'true' | |
204 | test_expect_failure 'pretend we have fixed another known breakage' 'true' | |
205 | test_done | |
206 | EOF | |
207 | check_sub_test_lib_test partially-passing-todos <<-\\EOF | |
208 | > not ok 1 - pretend we have a known breakage # TODO known breakage | |
209 | > ok 2 - pretend we have a passing test | |
210 | > ok 3 - pretend we have fixed another known breakage # TODO known breakage vanished | |
211 | > # 1 known breakage(s) vanished; please update test(s) | |
212 | > # still have 1 known breakage(s) | |
213 | > # passed all remaining 1 test(s) | |
214 | > 1..3 | |
215 | EOF | |
216 | " | |
217 | ||
5ebf89e8 AS |
218 | test_expect_success 'pretend we have a pass, fail, and known breakage' " |
219 | test_must_fail run_sub_test_lib_test \ | |
220 | mixed-results1 'mixed results #1' <<-\\EOF && | |
221 | test_expect_success 'passing test' 'true' | |
222 | test_expect_success 'failing test' 'false' | |
223 | test_expect_failure 'pretend we have a known breakage' 'false' | |
224 | test_done | |
225 | EOF | |
226 | check_sub_test_lib_test mixed-results1 <<-\\EOF | |
227 | > ok 1 - passing test | |
228 | > not ok 2 - failing test | |
229 | > # false | |
230 | > not ok 3 - pretend we have a known breakage # TODO known breakage | |
231 | > # still have 1 known breakage(s) | |
232 | > # failed 1 among remaining 2 test(s) | |
233 | > 1..3 | |
234 | EOF | |
235 | " | |
236 | ||
237 | test_expect_success 'pretend we have a mix of all possible results' " | |
238 | test_must_fail run_sub_test_lib_test \ | |
239 | mixed-results2 'mixed results #2' <<-\\EOF && | |
240 | test_expect_success 'passing test' 'true' | |
241 | test_expect_success 'passing test' 'true' | |
242 | test_expect_success 'passing test' 'true' | |
243 | test_expect_success 'passing test' 'true' | |
244 | test_expect_success 'failing test' 'false' | |
245 | test_expect_success 'failing test' 'false' | |
246 | test_expect_success 'failing test' 'false' | |
247 | test_expect_failure 'pretend we have a known breakage' 'false' | |
248 | test_expect_failure 'pretend we have a known breakage' 'false' | |
249 | test_expect_failure 'pretend we have fixed a known breakage' 'true' | |
250 | test_done | |
251 | EOF | |
252 | check_sub_test_lib_test mixed-results2 <<-\\EOF | |
253 | > ok 1 - passing test | |
254 | > ok 2 - passing test | |
255 | > ok 3 - passing test | |
256 | > ok 4 - passing test | |
257 | > not ok 5 - failing test | |
258 | > # false | |
259 | > not ok 6 - failing test | |
260 | > # false | |
261 | > not ok 7 - failing test | |
262 | > # false | |
263 | > not ok 8 - pretend we have a known breakage # TODO known breakage | |
264 | > not ok 9 - pretend we have a known breakage # TODO known breakage | |
b73d9a23 AS |
265 | > ok 10 - pretend we have fixed a known breakage # TODO known breakage vanished |
266 | > # 1 known breakage(s) vanished; please update test(s) | |
5ebf89e8 | 267 | > # still have 2 known breakage(s) |
b73d9a23 | 268 | > # failed 3 among remaining 7 test(s) |
5ebf89e8 AS |
269 | > 1..10 |
270 | EOF | |
271 | " | |
272 | ||
517cd55f TR |
273 | test_expect_success 'test --verbose' ' |
274 | test_must_fail run_sub_test_lib_test \ | |
275 | test-verbose "test verbose" --verbose <<-\EOF && | |
276 | test_expect_success "passing test" true | |
277 | test_expect_success "test with output" "echo foo" | |
278 | test_expect_success "failing test" false | |
279 | test_done | |
280 | EOF | |
99094a7a | 281 | mv test-verbose/out test-verbose/out+ && |
517cd55f TR |
282 | grep -v "^Initialized empty" test-verbose/out+ >test-verbose/out && |
283 | check_sub_test_lib_test test-verbose <<-\EOF | |
284 | > expecting success: true | |
517cd55f TR |
285 | > ok 1 - passing test |
286 | > Z | |
287 | > expecting success: echo foo | |
288 | > foo | |
517cd55f TR |
289 | > ok 2 - test with output |
290 | > Z | |
291 | > expecting success: false | |
517cd55f TR |
292 | > not ok 3 - failing test |
293 | > # false | |
294 | > Z | |
295 | > # failed 1 among 3 test(s) | |
296 | > 1..3 | |
297 | EOF | |
298 | ' | |
299 | ||
ff09af3f TR |
300 | test_expect_success 'test --verbose-only' ' |
301 | test_must_fail run_sub_test_lib_test \ | |
302 | test-verbose-only-2 "test verbose-only=2" \ | |
303 | --verbose-only=2 <<-\EOF && | |
304 | test_expect_success "passing test" true | |
305 | test_expect_success "test with output" "echo foo" | |
306 | test_expect_success "failing test" false | |
307 | test_done | |
308 | EOF | |
309 | check_sub_test_lib_test test-verbose-only-2 <<-\EOF | |
310 | > ok 1 - passing test | |
311 | > Z | |
312 | > expecting success: echo foo | |
313 | > foo | |
ff09af3f TR |
314 | > ok 2 - test with output |
315 | > Z | |
316 | > not ok 3 - failing test | |
317 | > # false | |
318 | > # failed 1 among 3 test(s) | |
319 | > 1..3 | |
320 | EOF | |
321 | ' | |
322 | ||
ef2ac68d | 323 | test_expect_success 'GIT_SKIP_TESTS' " |
7e28c16f RJ |
324 | ( |
325 | GIT_SKIP_TESTS='git.2' && export GIT_SKIP_TESTS && | |
ef2ac68d | 326 | run_sub_test_lib_test git-skip-tests-basic \ |
7e28c16f RJ |
327 | 'GIT_SKIP_TESTS' <<-\\EOF && |
328 | for i in 1 2 3 | |
329 | do | |
330 | test_expect_success \"passing test #\$i\" 'true' | |
331 | done | |
332 | test_done | |
333 | EOF | |
334 | check_sub_test_lib_test git-skip-tests-basic <<-\\EOF | |
335 | > ok 1 - passing test #1 | |
336 | > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) | |
337 | > ok 3 - passing test #3 | |
338 | > # passed all 3 test(s) | |
339 | > 1..3 | |
340 | EOF | |
341 | ) | |
ef2ac68d IB |
342 | " |
343 | ||
344 | test_expect_success 'GIT_SKIP_TESTS several tests' " | |
7e28c16f RJ |
345 | ( |
346 | GIT_SKIP_TESTS='git.2 git.5' && export GIT_SKIP_TESTS && | |
ef2ac68d | 347 | run_sub_test_lib_test git-skip-tests-several \ |
7e28c16f RJ |
348 | 'GIT_SKIP_TESTS several tests' <<-\\EOF && |
349 | for i in 1 2 3 4 5 6 | |
350 | do | |
351 | test_expect_success \"passing test #\$i\" 'true' | |
352 | done | |
353 | test_done | |
354 | EOF | |
355 | check_sub_test_lib_test git-skip-tests-several <<-\\EOF | |
356 | > ok 1 - passing test #1 | |
357 | > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) | |
358 | > ok 3 - passing test #3 | |
359 | > ok 4 - passing test #4 | |
360 | > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) | |
361 | > ok 6 - passing test #6 | |
362 | > # passed all 6 test(s) | |
363 | > 1..6 | |
364 | EOF | |
365 | ) | |
ef2ac68d IB |
366 | " |
367 | ||
368 | test_expect_success 'GIT_SKIP_TESTS sh pattern' " | |
7e28c16f RJ |
369 | ( |
370 | GIT_SKIP_TESTS='git.[2-5]' && export GIT_SKIP_TESTS && | |
ef2ac68d | 371 | run_sub_test_lib_test git-skip-tests-sh-pattern \ |
7e28c16f RJ |
372 | 'GIT_SKIP_TESTS sh pattern' <<-\\EOF && |
373 | for i in 1 2 3 4 5 6 | |
374 | do | |
375 | test_expect_success \"passing test #\$i\" 'true' | |
376 | done | |
377 | test_done | |
378 | EOF | |
379 | check_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF | |
380 | > ok 1 - passing test #1 | |
381 | > ok 2 # skip passing test #2 (GIT_SKIP_TESTS) | |
382 | > ok 3 # skip passing test #3 (GIT_SKIP_TESTS) | |
383 | > ok 4 # skip passing test #4 (GIT_SKIP_TESTS) | |
384 | > ok 5 # skip passing test #5 (GIT_SKIP_TESTS) | |
385 | > ok 6 - passing test #6 | |
386 | > # passed all 6 test(s) | |
387 | > 1..6 | |
388 | EOF | |
389 | ) | |
ef2ac68d IB |
390 | " |
391 | ||
0445e6f0 IB |
392 | test_expect_success '--run basic' " |
393 | run_sub_test_lib_test run-basic \ | |
394 | '--run basic' --run='1 3 5' <<-\\EOF && | |
395 | for i in 1 2 3 4 5 6 | |
396 | do | |
397 | test_expect_success \"passing test #\$i\" 'true' | |
398 | done | |
399 | test_done | |
400 | EOF | |
401 | check_sub_test_lib_test run-basic <<-\\EOF | |
402 | > ok 1 - passing test #1 | |
403 | > ok 2 # skip passing test #2 (--run) | |
404 | > ok 3 - passing test #3 | |
405 | > ok 4 # skip passing test #4 (--run) | |
406 | > ok 5 - passing test #5 | |
407 | > ok 6 # skip passing test #6 (--run) | |
408 | > # passed all 6 test(s) | |
409 | > 1..6 | |
410 | EOF | |
411 | " | |
412 | ||
413 | test_expect_success '--run with a range' " | |
414 | run_sub_test_lib_test run-range \ | |
415 | '--run with a range' --run='1-3' <<-\\EOF && | |
416 | for i in 1 2 3 4 5 6 | |
417 | do | |
418 | test_expect_success \"passing test #\$i\" 'true' | |
419 | done | |
420 | test_done | |
421 | EOF | |
422 | check_sub_test_lib_test run-range <<-\\EOF | |
423 | > ok 1 - passing test #1 | |
424 | > ok 2 - passing test #2 | |
425 | > ok 3 - passing test #3 | |
426 | > ok 4 # skip passing test #4 (--run) | |
427 | > ok 5 # skip passing test #5 (--run) | |
428 | > ok 6 # skip passing test #6 (--run) | |
429 | > # passed all 6 test(s) | |
430 | > 1..6 | |
431 | EOF | |
432 | " | |
433 | ||
434 | test_expect_success '--run with two ranges' " | |
435 | run_sub_test_lib_test run-two-ranges \ | |
436 | '--run with two ranges' --run='1-2 5-6' <<-\\EOF && | |
437 | for i in 1 2 3 4 5 6 | |
438 | do | |
439 | test_expect_success \"passing test #\$i\" 'true' | |
440 | done | |
441 | test_done | |
442 | EOF | |
443 | check_sub_test_lib_test run-two-ranges <<-\\EOF | |
444 | > ok 1 - passing test #1 | |
445 | > ok 2 - passing test #2 | |
446 | > ok 3 # skip passing test #3 (--run) | |
447 | > ok 4 # skip passing test #4 (--run) | |
448 | > ok 5 - passing test #5 | |
449 | > ok 6 - passing test #6 | |
450 | > # passed all 6 test(s) | |
451 | > 1..6 | |
452 | EOF | |
453 | " | |
454 | ||
455 | test_expect_success '--run with a left open range' " | |
456 | run_sub_test_lib_test run-left-open-range \ | |
457 | '--run with a left open range' --run='-3' <<-\\EOF && | |
458 | for i in 1 2 3 4 5 6 | |
459 | do | |
460 | test_expect_success \"passing test #\$i\" 'true' | |
461 | done | |
462 | test_done | |
463 | EOF | |
464 | check_sub_test_lib_test run-left-open-range <<-\\EOF | |
465 | > ok 1 - passing test #1 | |
466 | > ok 2 - passing test #2 | |
467 | > ok 3 - passing test #3 | |
468 | > ok 4 # skip passing test #4 (--run) | |
469 | > ok 5 # skip passing test #5 (--run) | |
470 | > ok 6 # skip passing test #6 (--run) | |
471 | > # passed all 6 test(s) | |
472 | > 1..6 | |
473 | EOF | |
474 | " | |
475 | ||
476 | test_expect_success '--run with a right open range' " | |
477 | run_sub_test_lib_test run-right-open-range \ | |
478 | '--run with a right open range' --run='4-' <<-\\EOF && | |
479 | for i in 1 2 3 4 5 6 | |
480 | do | |
481 | test_expect_success \"passing test #\$i\" 'true' | |
482 | done | |
483 | test_done | |
484 | EOF | |
485 | check_sub_test_lib_test run-right-open-range <<-\\EOF | |
486 | > ok 1 # skip passing test #1 (--run) | |
487 | > ok 2 # skip passing test #2 (--run) | |
488 | > ok 3 # skip passing test #3 (--run) | |
489 | > ok 4 - passing test #4 | |
490 | > ok 5 - passing test #5 | |
491 | > ok 6 - passing test #6 | |
492 | > # passed all 6 test(s) | |
493 | > 1..6 | |
494 | EOF | |
495 | " | |
496 | ||
497 | test_expect_success '--run with basic negation' " | |
498 | run_sub_test_lib_test run-basic-neg \ | |
499 | '--run with basic negation' --run='"'!3'"' <<-\\EOF && | |
500 | for i in 1 2 3 4 5 6 | |
501 | do | |
502 | test_expect_success \"passing test #\$i\" 'true' | |
503 | done | |
504 | test_done | |
505 | EOF | |
506 | check_sub_test_lib_test run-basic-neg <<-\\EOF | |
507 | > ok 1 - passing test #1 | |
508 | > ok 2 - passing test #2 | |
509 | > ok 3 # skip passing test #3 (--run) | |
510 | > ok 4 - passing test #4 | |
511 | > ok 5 - passing test #5 | |
512 | > ok 6 - passing test #6 | |
513 | > # passed all 6 test(s) | |
514 | > 1..6 | |
515 | EOF | |
516 | " | |
517 | ||
518 | test_expect_success '--run with two negations' " | |
519 | run_sub_test_lib_test run-two-neg \ | |
520 | '--run with two negations' --run='"'!3 !6'"' <<-\\EOF && | |
521 | for i in 1 2 3 4 5 6 | |
522 | do | |
523 | test_expect_success \"passing test #\$i\" 'true' | |
524 | done | |
525 | test_done | |
526 | EOF | |
527 | check_sub_test_lib_test run-two-neg <<-\\EOF | |
528 | > ok 1 - passing test #1 | |
529 | > ok 2 - passing test #2 | |
530 | > ok 3 # skip passing test #3 (--run) | |
531 | > ok 4 - passing test #4 | |
532 | > ok 5 - passing test #5 | |
533 | > ok 6 # skip passing test #6 (--run) | |
534 | > # passed all 6 test(s) | |
535 | > 1..6 | |
536 | EOF | |
537 | " | |
538 | ||
539 | test_expect_success '--run a range and negation' " | |
540 | run_sub_test_lib_test run-range-and-neg \ | |
541 | '--run a range and negation' --run='"'-4 !2'"' <<-\\EOF && | |
542 | for i in 1 2 3 4 5 6 | |
543 | do | |
544 | test_expect_success \"passing test #\$i\" 'true' | |
545 | done | |
546 | test_done | |
547 | EOF | |
548 | check_sub_test_lib_test run-range-and-neg <<-\\EOF | |
549 | > ok 1 - passing test #1 | |
550 | > ok 2 # skip passing test #2 (--run) | |
551 | > ok 3 - passing test #3 | |
552 | > ok 4 - passing test #4 | |
553 | > ok 5 # skip passing test #5 (--run) | |
554 | > ok 6 # skip passing test #6 (--run) | |
555 | > # passed all 6 test(s) | |
556 | > 1..6 | |
557 | EOF | |
558 | " | |
559 | ||
560 | test_expect_success '--run range negation' " | |
561 | run_sub_test_lib_test run-range-neg \ | |
562 | '--run range negation' --run='"'!1-3'"' <<-\\EOF && | |
563 | for i in 1 2 3 4 5 6 | |
564 | do | |
565 | test_expect_success \"passing test #\$i\" 'true' | |
566 | done | |
567 | test_done | |
568 | EOF | |
569 | check_sub_test_lib_test run-range-neg <<-\\EOF | |
570 | > ok 1 # skip passing test #1 (--run) | |
571 | > ok 2 # skip passing test #2 (--run) | |
572 | > ok 3 # skip passing test #3 (--run) | |
573 | > ok 4 - passing test #4 | |
574 | > ok 5 - passing test #5 | |
575 | > ok 6 - passing test #6 | |
576 | > # passed all 6 test(s) | |
577 | > 1..6 | |
578 | EOF | |
579 | " | |
580 | ||
581 | test_expect_success '--run include, exclude and include' " | |
582 | run_sub_test_lib_test run-inc-neg-inc \ | |
583 | '--run include, exclude and include' \ | |
584 | --run='"'1-5 !1-3 2'"' <<-\\EOF && | |
585 | for i in 1 2 3 4 5 6 | |
586 | do | |
587 | test_expect_success \"passing test #\$i\" 'true' | |
588 | done | |
589 | test_done | |
590 | EOF | |
591 | check_sub_test_lib_test run-inc-neg-inc <<-\\EOF | |
592 | > ok 1 # skip passing test #1 (--run) | |
593 | > ok 2 - passing test #2 | |
594 | > ok 3 # skip passing test #3 (--run) | |
595 | > ok 4 - passing test #4 | |
596 | > ok 5 - passing test #5 | |
597 | > ok 6 # skip passing test #6 (--run) | |
598 | > # passed all 6 test(s) | |
599 | > 1..6 | |
600 | EOF | |
601 | " | |
602 | ||
603 | test_expect_success '--run include, exclude and include, comma separated' " | |
604 | run_sub_test_lib_test run-inc-neg-inc-comma \ | |
605 | '--run include, exclude and include, comma separated' \ | |
606 | --run=1-5,\!1-3,2 <<-\\EOF && | |
607 | for i in 1 2 3 4 5 6 | |
608 | do | |
609 | test_expect_success \"passing test #\$i\" 'true' | |
610 | done | |
611 | test_done | |
612 | EOF | |
613 | check_sub_test_lib_test run-inc-neg-inc-comma <<-\\EOF | |
614 | > ok 1 # skip passing test #1 (--run) | |
615 | > ok 2 - passing test #2 | |
616 | > ok 3 # skip passing test #3 (--run) | |
617 | > ok 4 - passing test #4 | |
618 | > ok 5 - passing test #5 | |
619 | > ok 6 # skip passing test #6 (--run) | |
620 | > # passed all 6 test(s) | |
621 | > 1..6 | |
622 | EOF | |
623 | " | |
624 | ||
625 | test_expect_success '--run exclude and include' " | |
626 | run_sub_test_lib_test run-neg-inc \ | |
627 | '--run exclude and include' \ | |
628 | --run='"'!3- 5'"' <<-\\EOF && | |
629 | for i in 1 2 3 4 5 6 | |
630 | do | |
631 | test_expect_success \"passing test #\$i\" 'true' | |
632 | done | |
633 | test_done | |
634 | EOF | |
635 | check_sub_test_lib_test run-neg-inc <<-\\EOF | |
636 | > ok 1 - passing test #1 | |
637 | > ok 2 - passing test #2 | |
638 | > ok 3 # skip passing test #3 (--run) | |
639 | > ok 4 # skip passing test #4 (--run) | |
640 | > ok 5 - passing test #5 | |
641 | > ok 6 # skip passing test #6 (--run) | |
642 | > # passed all 6 test(s) | |
643 | > 1..6 | |
644 | EOF | |
645 | " | |
646 | ||
647 | test_expect_success '--run empty selectors' " | |
648 | run_sub_test_lib_test run-empty-sel \ | |
649 | '--run empty selectors' \ | |
650 | --run='1,,3,,,5' <<-\\EOF && | |
651 | for i in 1 2 3 4 5 6 | |
652 | do | |
653 | test_expect_success \"passing test #\$i\" 'true' | |
654 | done | |
655 | test_done | |
656 | EOF | |
657 | check_sub_test_lib_test run-empty-sel <<-\\EOF | |
658 | > ok 1 - passing test #1 | |
659 | > ok 2 # skip passing test #2 (--run) | |
660 | > ok 3 - passing test #3 | |
661 | > ok 4 # skip passing test #4 (--run) | |
662 | > ok 5 - passing test #5 | |
663 | > ok 6 # skip passing test #6 (--run) | |
664 | > # passed all 6 test(s) | |
665 | > 1..6 | |
666 | EOF | |
667 | " | |
668 | ||
669 | test_expect_success '--run invalid range start' " | |
670 | run_sub_test_lib_test_err run-inv-range-start \ | |
671 | '--run invalid range start' \ | |
672 | --run='a-5' <<-\\EOF && | |
673 | test_expect_success \"passing test #1\" 'true' | |
674 | test_done | |
675 | EOF | |
676 | check_sub_test_lib_test_err run-inv-range-start \ | |
677 | <<-\\EOF_OUT 3<<-\\EOF_ERR | |
678 | > FATAL: Unexpected exit with code 1 | |
679 | EOF_OUT | |
680 | > error: --run: invalid non-numeric in range start: 'a-5' | |
681 | EOF_ERR | |
682 | " | |
683 | ||
684 | test_expect_success '--run invalid range end' " | |
685 | run_sub_test_lib_test_err run-inv-range-end \ | |
686 | '--run invalid range end' \ | |
687 | --run='1-z' <<-\\EOF && | |
688 | test_expect_success \"passing test #1\" 'true' | |
689 | test_done | |
690 | EOF | |
691 | check_sub_test_lib_test_err run-inv-range-end \ | |
692 | <<-\\EOF_OUT 3<<-\\EOF_ERR | |
693 | > FATAL: Unexpected exit with code 1 | |
694 | EOF_OUT | |
695 | > error: --run: invalid non-numeric in range end: '1-z' | |
696 | EOF_ERR | |
697 | " | |
698 | ||
699 | test_expect_success '--run invalid selector' " | |
700 | run_sub_test_lib_test_err run-inv-selector \ | |
701 | '--run invalid selector' \ | |
702 | --run='1?' <<-\\EOF && | |
703 | test_expect_success \"passing test #1\" 'true' | |
704 | test_done | |
705 | EOF | |
706 | check_sub_test_lib_test_err run-inv-selector \ | |
707 | <<-\\EOF_OUT 3<<-\\EOF_ERR | |
708 | > FATAL: Unexpected exit with code 1 | |
709 | EOF_OUT | |
710 | > error: --run: invalid non-numeric in test selector: '1?' | |
711 | EOF_ERR | |
712 | " | |
713 | ||
714 | ||
a7bb3940 JS |
715 | test_set_prereq HAVEIT |
716 | haveit=no | |
717 | test_expect_success HAVEIT 'test runs if prerequisite is satisfied' ' | |
1b5b2b64 SL |
718 | test_have_prereq HAVEIT && |
719 | haveit=yes | |
a7bb3940 JS |
720 | ' |
721 | donthaveit=yes | |
722 | test_expect_success DONTHAVEIT 'unmet prerequisite causes test to be skipped' ' | |
1b5b2b64 | 723 | donthaveit=no |
a7bb3940 JS |
724 | ' |
725 | if test $haveit$donthaveit != yesyes | |
726 | then | |
727 | say "bug in test framework: prerequisite tags do not work reliably" | |
93a57246 ÆAB |
728 | exit 1 |
729 | fi | |
730 | ||
731 | test_set_prereq HAVETHIS | |
732 | haveit=no | |
733 | test_expect_success HAVETHIS,HAVEIT 'test runs if prerequisites are satisfied' ' | |
1b5b2b64 SL |
734 | test_have_prereq HAVEIT && |
735 | test_have_prereq HAVETHIS && | |
736 | haveit=yes | |
93a57246 ÆAB |
737 | ' |
738 | donthaveit=yes | |
739 | test_expect_success HAVEIT,DONTHAVEIT 'unmet prerequisites causes test to be skipped' ' | |
1b5b2b64 | 740 | donthaveit=no |
93a57246 | 741 | ' |
ce60653e ÆAB |
742 | donthaveiteither=yes |
743 | test_expect_success DONTHAVEIT,HAVEIT 'unmet prerequisites causes test to be skipped' ' | |
1b5b2b64 | 744 | donthaveiteither=no |
ce60653e ÆAB |
745 | ' |
746 | if test $haveit$donthaveit$donthaveiteither != yesyesyes | |
93a57246 ÆAB |
747 | then |
748 | say "bug in test framework: multiple prerequisite tags do not work reliably" | |
a7bb3940 JS |
749 | exit 1 |
750 | fi | |
41ac414e | 751 | |
bdccd3c1 JK |
752 | test_lazy_prereq LAZY_TRUE true |
753 | havetrue=no | |
754 | test_expect_success LAZY_TRUE 'test runs if lazy prereq is satisfied' ' | |
755 | havetrue=yes | |
756 | ' | |
757 | donthavetrue=yes | |
758 | test_expect_success !LAZY_TRUE 'missing lazy prereqs skip tests' ' | |
759 | donthavetrue=no | |
760 | ' | |
761 | ||
762 | if test "$havetrue$donthavetrue" != yesyes | |
763 | then | |
764 | say 'bug in test framework: lazy prerequisites do not work' | |
765 | exit 1 | |
766 | fi | |
767 | ||
768 | test_lazy_prereq LAZY_FALSE false | |
769 | nothavefalse=no | |
770 | test_expect_success !LAZY_FALSE 'negative lazy prereqs checked' ' | |
771 | nothavefalse=yes | |
772 | ' | |
773 | havefalse=yes | |
774 | test_expect_success LAZY_FALSE 'missing negative lazy prereqs will skip' ' | |
775 | havefalse=no | |
776 | ' | |
777 | ||
778 | if test "$nothavefalse$havefalse" != yesyes | |
779 | then | |
780 | say 'bug in test framework: negative lazy prerequisites do not work' | |
781 | exit 1 | |
782 | fi | |
783 | ||
b6b0afdc JN |
784 | clean=no |
785 | test_expect_success 'tests clean up after themselves' ' | |
1b5b2b64 | 786 | test_when_finished clean=yes |
b6b0afdc JN |
787 | ' |
788 | ||
892e6f7e | 789 | if test $clean != yes |
b6b0afdc | 790 | then |
892e6f7e | 791 | say "bug in test framework: basic cleanup command does not work reliably" |
b6b0afdc JN |
792 | exit 1 |
793 | fi | |
794 | ||
892e6f7e | 795 | test_expect_success 'tests clean up even on failures' " |
565b6fa8 AS |
796 | test_must_fail run_sub_test_lib_test \ |
797 | failing-cleanup 'Failing tests with cleanup commands' <<-\\EOF && | |
1b5b2b64 SL |
798 | test_expect_success 'tests clean up even after a failure' ' |
799 | touch clean-after-failure && | |
800 | test_when_finished rm clean-after-failure && | |
801 | (exit 1) | |
802 | ' | |
803 | test_expect_success 'failure to clean up causes the test to fail' ' | |
804 | test_when_finished \"(exit 2)\" | |
805 | ' | |
806 | test_done | |
1b5b2b64 | 807 | EOF |
565b6fa8 | 808 | check_sub_test_lib_test failing-cleanup <<-\\EOF |
5e5c006e | 809 | > not ok 1 - tests clean up even after a failure |
1b5b2b64 SL |
810 | > # Z |
811 | > # touch clean-after-failure && | |
812 | > # test_when_finished rm clean-after-failure && | |
813 | > # (exit 1) | |
814 | > # Z | |
5e5c006e | 815 | > not ok 2 - failure to clean up causes the test to fail |
1b5b2b64 SL |
816 | > # Z |
817 | > # test_when_finished \"(exit 2)\" | |
818 | > # Z | |
819 | > # failed 2 among 2 test(s) | |
820 | > 1..2 | |
821 | EOF | |
892e6f7e ÆAB |
822 | " |
823 | ||
e1970ce4 JH |
824 | ################################################################ |
825 | # Basics of the basics | |
826 | ||
827 | # updating a new file without --add should fail. | |
1b5b2b64 SL |
828 | test_expect_success 'git update-index without --add should fail adding' ' |
829 | test_must_fail git update-index should-be-empty | |
41ac414e | 830 | ' |
e1970ce4 JH |
831 | |
832 | # and with --add it should succeed, even if it is empty (it used to fail). | |
1b5b2b64 SL |
833 | test_expect_success 'git update-index with --add should succeed' ' |
834 | git update-index --add should-be-empty | |
835 | ' | |
e1970ce4 | 836 | |
1b5b2b64 SL |
837 | test_expect_success 'writing tree out with git write-tree' ' |
838 | tree=$(git write-tree) | |
839 | ' | |
e1970ce4 JH |
840 | |
841 | # we know the shape and contents of the tree and know the object ID for it. | |
5b9ba9bd | 842 | test_expect_success SHA1 'validate object ID of a known tree' ' |
1b5b2b64 SL |
843 | test "$tree" = 7bb943559a305bdd6bdee2cef6e5df2413c3d30a |
844 | ' | |
e1970ce4 JH |
845 | |
846 | # Removing paths. | |
1b5b2b64 SL |
847 | test_expect_success 'git update-index without --remove should fail removing' ' |
848 | rm -f should-be-empty full-of-directories && | |
849 | test_must_fail git update-index should-be-empty | |
41ac414e | 850 | ' |
e1970ce4 | 851 | |
1b5b2b64 SL |
852 | test_expect_success 'git update-index with --remove should be able to remove' ' |
853 | git update-index --remove should-be-empty | |
854 | ' | |
e1970ce4 JH |
855 | |
856 | # Empty tree can be written with recent write-tree. | |
1b5b2b64 SL |
857 | test_expect_success 'git write-tree should be able to write an empty tree' ' |
858 | tree=$(git write-tree) | |
859 | ' | |
e1970ce4 | 860 | |
1b5b2b64 | 861 | test_expect_success 'validate object ID of a known tree' ' |
f9e7d9f8 | 862 | test "$tree" = $EMPTY_TREE |
1b5b2b64 | 863 | ' |
e1970ce4 JH |
864 | |
865 | # Various types of objects | |
1b5b2b64 | 866 | |
1b5b2b64 SL |
867 | test_expect_success 'adding various types of objects with git update-index --add' ' |
868 | mkdir path2 path3 path3/subp3 && | |
869 | paths="path0 path2/file2 path3/file3 path3/subp3/file3" && | |
870 | ( | |
871 | for p in $paths | |
872 | do | |
873 | echo "hello $p" >$p || exit 1 | |
c723a76d | 874 | test_ln_s_add "hello $p" ${p}sym || exit 1 |
1b5b2b64 SL |
875 | done |
876 | ) && | |
877 | find path* ! -type d -print | xargs git update-index --add | |
878 | ' | |
e1970ce4 JH |
879 | |
880 | # Show them and see that matches what we expect. | |
1b5b2b64 SL |
881 | test_expect_success 'showing stage with git ls-files --stage' ' |
882 | git ls-files --stage >current | |
883 | ' | |
884 | ||
5b9ba9bd | 885 | test_expect_success SHA1 'validate git ls-files output for a known tree' ' |
c723a76d | 886 | cat >expected <<-\EOF && |
1b5b2b64 SL |
887 | 100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0 |
888 | 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym | |
889 | 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2 | |
890 | 120000 d8ce161addc5173867a3c3c730924388daedbc38 0 path2/file2sym | |
891 | 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0 path3/file3 | |
892 | 120000 8599103969b43aff7e430efea79ca4636466794f 0 path3/file3sym | |
893 | 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0 path3/subp3/file3 | |
894 | 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0 path3/subp3/file3sym | |
895 | EOF | |
896 | test_cmp expected current | |
897 | ' | |
898 | ||
899 | test_expect_success 'writing tree out with git write-tree' ' | |
900 | tree=$(git write-tree) | |
901 | ' | |
902 | ||
5b9ba9bd | 903 | test_expect_success SHA1 'validate object ID for a known tree' ' |
c723a76d | 904 | test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b |
1b5b2b64 SL |
905 | ' |
906 | ||
907 | test_expect_success 'showing tree with git ls-tree' ' | |
908 | git ls-tree $tree >current | |
909 | ' | |
910 | ||
5b9ba9bd | 911 | test_expect_success SHA1 'git ls-tree output for a known tree' ' |
1b5b2b64 SL |
912 | cat >expected <<-\EOF && |
913 | 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 | |
914 | 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym | |
915 | 040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2 | |
916 | 040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3 | |
917 | EOF | |
918 | test_cmp expected current | |
919 | ' | |
e1970ce4 | 920 | |
246cc52f JH |
921 | # This changed in ls-tree pathspec change -- recursive does |
922 | # not show tree nodes anymore. | |
1b5b2b64 SL |
923 | test_expect_success 'showing tree with git ls-tree -r' ' |
924 | git ls-tree -r $tree >current | |
925 | ' | |
926 | ||
5b9ba9bd | 927 | test_expect_success SHA1 'git ls-tree -r output for a known tree' ' |
c723a76d | 928 | cat >expected <<-\EOF && |
1b5b2b64 SL |
929 | 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 |
930 | 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym | |
931 | 100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2 | |
932 | 120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym | |
933 | 100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3 | |
934 | 120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym | |
935 | 100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3 | |
936 | 120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym | |
937 | EOF | |
938 | test_cmp expected current | |
939 | ' | |
e1970ce4 | 940 | |
fdeb6bf5 | 941 | # But with -r -t we can have both. |
1b5b2b64 SL |
942 | test_expect_success 'showing tree with git ls-tree -r -t' ' |
943 | git ls-tree -r -t $tree >current | |
944 | ' | |
3d12d0cf | 945 | |
5b9ba9bd | 946 | test_expect_success SHA1 'git ls-tree -r output for a known tree' ' |
1b5b2b64 SL |
947 | cat >expected <<-\EOF && |
948 | 100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0 | |
949 | 120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym | |
950 | 040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2 | |
951 | 100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2 | |
952 | 120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym | |
953 | 040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3 | |
954 | 100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3 | |
955 | 120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym | |
956 | 040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2 path3/subp3 | |
957 | 100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3 | |
958 | 120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym | |
959 | EOF | |
960 | test_cmp expected current | |
961 | ' | |
3d12d0cf | 962 | |
1b5b2b64 SL |
963 | test_expect_success 'writing partial tree out with git write-tree --prefix' ' |
964 | ptree=$(git write-tree --prefix=path3) | |
41ac414e | 965 | ' |
3d12d0cf | 966 | |
5b9ba9bd | 967 | test_expect_success SHA1 'validate object ID for a known tree' ' |
c723a76d | 968 | test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3 |
1b5b2b64 SL |
969 | ' |
970 | ||
971 | test_expect_success 'writing partial tree out with git write-tree --prefix' ' | |
972 | ptree=$(git write-tree --prefix=path3/subp3) | |
973 | ' | |
974 | ||
5b9ba9bd | 975 | test_expect_success SHA1 'validate object ID for a known tree' ' |
c723a76d | 976 | test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2 |
1b5b2b64 SL |
977 | ' |
978 | ||
979 | test_expect_success 'put invalid objects into the index' ' | |
980 | rm -f .git/index && | |
981 | cat >badobjects <<-\EOF && | |
982 | 100644 blob 1000000000000000000000000000000000000000 dir/file1 | |
983 | 100644 blob 2000000000000000000000000000000000000000 dir/file2 | |
984 | 100644 blob 3000000000000000000000000000000000000000 dir/file3 | |
985 | 100644 blob 4000000000000000000000000000000000000000 dir/file4 | |
986 | 100644 blob 5000000000000000000000000000000000000000 dir/file5 | |
987 | EOF | |
988 | git update-index --index-info <badobjects | |
989 | ' | |
990 | ||
991 | test_expect_success 'writing this tree without --missing-ok' ' | |
992 | test_must_fail git write-tree | |
993 | ' | |
994 | ||
995 | test_expect_success 'writing this tree with --missing-ok' ' | |
996 | git write-tree --missing-ok | |
997 | ' | |
3d12d0cf JS |
998 | |
999 | ||
e1970ce4 | 1000 | ################################################################ |
1b5b2b64 | 1001 | test_expect_success 'git read-tree followed by write-tree should be idempotent' ' |
99094a7a | 1002 | rm -f .git/index && |
1b5b2b64 SL |
1003 | git read-tree $tree && |
1004 | test -f .git/index && | |
1005 | newtree=$(git write-tree) && | |
1006 | test "$newtree" = "$tree" | |
1007 | ' | |
1008 | ||
5b9ba9bd | 1009 | test_expect_success SHA1 'validate git diff-files output for a know cache/work tree state' ' |
c723a76d | 1010 | cat >expected <<\EOF && |
b6d8f309 JH |
1011 | :100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M path0 |
1012 | :120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M path0sym | |
1013 | :100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M path2/file2 | |
1014 | :120000 120000 d8ce161addc5173867a3c3c730924388daedbc38 0000000000000000000000000000000000000000 M path2/file2sym | |
1015 | :100644 100644 0aa34cae68d0878578ad119c86ca2b5ed5b28376 0000000000000000000000000000000000000000 M path3/file3 | |
1016 | :120000 120000 8599103969b43aff7e430efea79ca4636466794f 0000000000000000000000000000000000000000 M path3/file3sym | |
1017 | :100644 100644 00fb5908cb97c2564a9783c0c64087333b3b464f 0000000000000000000000000000000000000000 M path3/subp3/file3 | |
1018 | :120000 120000 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c 0000000000000000000000000000000000000000 M path3/subp3/file3sym | |
e1970ce4 | 1019 | EOF |
1b5b2b64 SL |
1020 | git diff-files >current && |
1021 | test_cmp current expected | |
1022 | ' | |
e1970ce4 | 1023 | |
1b5b2b64 SL |
1024 | test_expect_success 'git update-index --refresh should succeed' ' |
1025 | git update-index --refresh | |
1026 | ' | |
e1970ce4 | 1027 | |
1b5b2b64 SL |
1028 | test_expect_success 'no diff after checkout and git update-index --refresh' ' |
1029 | git diff-files >current && | |
1030 | cmp -s current /dev/null | |
1031 | ' | |
e1970ce4 | 1032 | |
9af0b8db | 1033 | ################################################################ |
c723a76d | 1034 | P=087704a96baf1c2d1c869a8b084481e121c88b5b |
1b5b2b64 | 1035 | |
5b9ba9bd | 1036 | test_expect_success SHA1 'git commit-tree records the correct tree in a commit' ' |
1b5b2b64 SL |
1037 | commit0=$(echo NO | git commit-tree $P) && |
1038 | tree=$(git show --pretty=raw $commit0 | | |
1039 | sed -n -e "s/^tree //p" -e "/^author /q") && | |
1040 | test "z$tree" = "z$P" | |
1041 | ' | |
1042 | ||
5b9ba9bd | 1043 | test_expect_success SHA1 'git commit-tree records the correct parent in a commit' ' |
1b5b2b64 SL |
1044 | commit1=$(echo NO | git commit-tree $P -p $commit0) && |
1045 | parent=$(git show --pretty=raw $commit1 | | |
1046 | sed -n -e "s/^parent //p" -e "/^author /q") && | |
1047 | test "z$commit0" = "z$parent" | |
1048 | ' | |
1049 | ||
5b9ba9bd | 1050 | test_expect_success SHA1 'git commit-tree omits duplicated parent in a commit' ' |
1b5b2b64 SL |
1051 | commit2=$(echo NO | git commit-tree $P -p $commit0 -p $commit0) && |
1052 | parent=$(git show --pretty=raw $commit2 | | |
1053 | sed -n -e "s/^parent //p" -e "/^author /q" | | |
1054 | sort -u) && | |
1055 | test "z$commit0" = "z$parent" && | |
1056 | numparent=$(git show --pretty=raw $commit2 | | |
1057 | sed -n -e "s/^parent //p" -e "/^author /q" | | |
1058 | wc -l) && | |
1059 | test $numparent = 1 | |
1060 | ' | |
9af0b8db | 1061 | |
81a361be JH |
1062 | test_expect_success 'update-index D/F conflict' ' |
1063 | mv path0 tmp && | |
1064 | mv path2 path0 && | |
1065 | mv tmp path2 && | |
1066 | git update-index --add --replace path2 path0/file2 && | |
1067 | numpath0=$(git ls-files path0 | wc -l) && | |
1068 | test $numpath0 = 1 | |
1069 | ' | |
1070 | ||
7fec10b7 JH |
1071 | test_expect_success 'very long name in the index handled sanely' ' |
1072 | ||
1073 | a=a && # 1 | |
1074 | a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 16 | |
1075 | a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 256 | |
1076 | a=$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a$a && # 4096 | |
1077 | a=${a}q && | |
1078 | ||
1079 | >path4 && | |
1080 | git update-index --add path4 && | |
1081 | ( | |
1082 | git ls-files -s path4 | | |
1083 | sed -e "s/ .*/ /" | | |
75651fd7 | 1084 | tr -d "\012" && |
7fec10b7 JH |
1085 | echo "$a" |
1086 | ) | git update-index --index-info && | |
1087 | len=$(git ls-files "a*" | wc -c) && | |
1088 | test $len = 4098 | |
1089 | ' | |
1090 | ||
e1970ce4 | 1091 | test_done |