@matheusbsbs / matheus-bagliano / commits / 801cfae8fd
Fork 0

t1010: add mktree test

So far mktree (which has always been a quick hack) had no test. At least give it a bit of test coverage. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 10, 2009 at 11:18 UTC 801cfae8fd683761ae268cab8cec08e4b0f5a35b
1 file changed +61
t/t1010-mktree.sh new
+61
@@ -0,0 +1,61 @@
1 +#!/bin/sh
2 +
3 +test_description='git mktree'
4 +
5 +. ./test-lib.sh
6 +
7 +test_expect_success setup '
8 + for d in a a. a0
9 + do
10 + mkdir "$d" && echo "$d/one" >"$d/one" &&
11 + git add "$d"
12 + done &&
13 + echo one >one &&
14 + git add one &&
15 + git write-tree >tree &&
16 + git ls-tree $(cat tree) >top &&
17 + git ls-tree -r $(cat tree) >all &&
18 + test_tick &&
19 + git commit -q -m one &&
20 + H=$(git rev-parse HEAD) &&
21 + git update-index --add --cacheinfo 160000 $H sub &&
22 + test_tick &&
23 + git commit -q -m two &&
24 + git rev-parse HEAD^{tree} >tree.withsub &&
25 + git ls-tree HEAD >top.withsub &&
26 + git ls-tree -r HEAD >all.withsub
27 +'
28 +
29 +test_expect_success 'ls-tree piped to mktree (1)' '
30 + git mktree <top >actual &&
31 + test_cmp tree actual
32 +'
33 +
34 +test_expect_success 'ls-tree piped to mktree (2)' '
35 + git mktree <top.withsub >actual &&
36 + test_cmp tree.withsub actual
37 +'
38 +
39 +test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
40 + perl -e "print reverse <>" <top |
41 + git mktree >actual &&
42 + test_cmp tree actual
43 +'
44 +
45 +test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
46 + perl -e "print reverse <>" <top.withsub |
47 + git mktree >actual &&
48 + test_cmp tree.withsub actual
49 +'
50 +
51 +test_expect_failure 'mktree reads ls-tree -r output (1)' '
52 + git mktree <all >actual &&
53 + test_cmp tree actual
54 +'
55 +
56 +test_expect_failure 'mktree reads ls-tree -r output (2)' '
57 + git mktree <all.withsub >actual &&
58 + test_cmp tree.withsub actual
59 +'
60 +
61 +test_done