@matheusbsbs / matheus-bagliano / commits / 50aee99512
Fork 0

Create test case for fast-import.

Now that its easier to craft test cases (thanks to 'data <<') we should start to verify fast-import works as expected. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 18, 2007 at 13:26 UTC 50aee995121a103fe2698574e7f1d56660a5b89b
1 file changed +184
t/t9300-fast-import.sh new
+184
@@ -0,0 +1,184 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2007 Shawn Pearce
4 +#
5 +
6 +test_description='test git-fast-import utility'
7 +. ./test-lib.sh
8 +. ../diff-lib.sh ;# test-lib chdir's into trash
9 +
10 +###
11 +### series A
12 +###
13 +
14 +test_tick
15 +cat >input <<INPUT_END
16 +blob
17 +mark :2
18 +data <<EOF
19 +file2
20 +second line of EOF
21 +EOF
22 +
23 +blob
24 +mark :3
25 +data <<END
26 +EOF
27 +in 3rd file
28 + END
29 +END
30 +
31 +blob
32 +mark :4
33 +data 4
34 +abcd
35 +commit refs/heads/master
36 +mark :5
37 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
38 +data <<COMMIT
39 +initial
40 +COMMIT
41 +
42 +M 644 :2 file2
43 +M 644 :3 file3
44 +M 755 :4 file4
45 +
46 +INPUT_END
47 +test_expect_success \
48 + 'A: create pack from stdin' \
49 + 'git-fast-import --export-marks=marks.out <input &&
50 + git-whatchanged master'
51 +test_expect_success \
52 + 'A: verify pack' \
53 + 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
54 +
55 +cat >expect <<EOF
56 +author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
57 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
58 +
59 +initial
60 +EOF
61 +test_expect_success \
62 + 'A: verify commit' \
63 + 'git-cat-file commit master | sed 1d >actual &&
64 + diff -u expect actual'
65 +
66 +cat >expect <<EOF
67 +100644 blob file2
68 +100644 blob file3
69 +100755 blob file4
70 +EOF
71 +test_expect_success \
72 + 'A: verify tree' \
73 + 'git-cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
74 + diff -u expect actual'
75 +
76 +cat >expect <<EOF
77 +file2
78 +second line of EOF
79 +EOF
80 +test_expect_success \
81 + 'A: verify file2' \
82 + 'git-cat-file blob master:file2 >actual && diff -u expect actual'
83 +
84 +cat >expect <<END
85 +EOF
86 +in 3rd file
87 + END
88 +END
89 +test_expect_success \
90 + 'A: verify file3' \
91 + 'git-cat-file blob master:file3 >actual && diff -u expect actual'
92 +
93 +printf abcd >expect
94 +test_expect_success \
95 + 'A: verify file4' \
96 + 'git-cat-file blob master:file4 >actual && diff -u expect actual'
97 +
98 +cat >expect <<EOF
99 +:2 `git-rev-parse --verify master:file2`
100 +:3 `git-rev-parse --verify master:file3`
101 +:4 `git-rev-parse --verify master:file4`
102 +:5 `git-rev-parse --verify master^0`
103 +EOF
104 +test_expect_success \
105 + 'A: verify marks output' \
106 + 'diff -u expect marks.out'
107 +
108 +###
109 +### series B
110 +###
111 +
112 +test_tick
113 +cat >input <<INPUT_END
114 +commit refs/heads/branch
115 +mark :1
116 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
117 +data <<COMMIT
118 +corrupt
119 +COMMIT
120 +
121 +from refs/heads/master
122 +M 755 0000000000000000000000000000000000000001 zero1
123 +
124 +INPUT_END
125 +test_expect_failure \
126 + 'B: fail on invalid blob sha1' \
127 + 'git-fast-import <input'
128 +rm -f .git/objects/pack_* .git/objects/index_*
129 +
130 +###
131 +### series C
132 +###
133 +
134 +newf=`echo hi newf | git-hash-object -w --stdin`
135 +oldf=`git-rev-parse --verify master:file2`
136 +test_tick
137 +cat >input <<INPUT_END
138 +commit refs/heads/branch
139 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
140 +data <<COMMIT
141 +second
142 +COMMIT
143 +
144 +from refs/heads/master
145 +M 644 $oldf file2/oldf
146 +M 755 $newf file2/newf
147 +D file3
148 +
149 +INPUT_END
150 +test_expect_success \
151 + 'C: incremental import create pack from stdin' \
152 + 'git-fast-import <input &&
153 + git-whatchanged branch'
154 +test_expect_success \
155 + 'C: verify pack' \
156 + 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
157 +test_expect_success \
158 + 'C: validate reuse existing blob' \
159 + 'test $newf = `git-rev-parse --verify branch:file2/newf`
160 + test $oldf = `git-rev-parse --verify branch:file2/oldf`'
161 +
162 +cat >expect <<EOF
163 +parent `git-rev-parse --verify master^0`
164 +author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
165 +committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
166 +
167 +second
168 +EOF
169 +test_expect_success \
170 + 'C: verify commit' \
171 + 'git-cat-file commit branch | sed 1d >actual &&
172 + diff -u expect actual'
173 +
174 +cat >expect <<EOF
175 +:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
176 +:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
177 +:100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
178 +EOF
179 +git-diff-tree -M -r master branch >actual
180 +test_expect_success \
181 + 'C: validate rename result' \
182 + 'compare_diff_raw expect actual'
183 +
184 +test_done