@matheusbsbs / matheus-bagliano / commits / 484cf6c3f1
Fork 0

format-patch: threading test reactivation

t4014 tests format-patch --thread since 7d812145, but the tests were ineffective right from the start at least for bash and dash. The loops of the form for ...; do something || break; done introduced by 7d812145 and 5d02294 always exit with status 0, even if 'something' failed, because 'break' returns 0 unless there was no loop to break. We take a rather different approach that uses an admittedly heinous inline Perl script to mangle all interesting information into a format that is invariant between runs. We can then test the full patch sequence in one go (with --stdout), doing away with the loop problem. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Rast committed Feb 19, 2009 at 22:26 UTC 484cf6c3f1169786c45ccda54c9961ef66465c03
1 file changed +103 -39
t/t4014-format-patch.sh
+103 -39
@@ -138,56 +138,120 @@ test_expect_success 'multiple files' '
138 ls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch
139 '
140
141 -test_expect_success 'thread' '
141 +check_threading () {
142 + expect="$1" &&
143 + shift &&
144 + (git format-patch --stdout "$@"; echo $? > status.out) |
145 + # Prints everything between the Message-ID and In-Reply-To,
146 + # and replaces all Message-ID-lookalikes by a sequence number
147 + perl -ne '
148 + if (/^(message-id|references|in-reply-to)/i) {
149 + $printing = 1;
150 + } elsif (/^\S/) {
151 + $printing = 0;
152 + }
153 + if ($printing) {
154 + $h{$1}=$i++ if (/<([^>]+)>/ and !exists $h{$1});
155 + for $k (keys %h) {s/$k/$h{$k}/};
156 + print;
157 + }
158 + print "---\n" if /^From /i;
159 + ' > actual &&
160 + test 0 = "$(cat status.out)" &&
161 + test_cmp "$expect" actual
162 +}
163 +
164 +cat >> expect.no-threading <<EOF
165 +---
166 +---
167 +---
168 +EOF
169
143 - rm -rf patches/ &&
170 +test_expect_success 'no threading' '
171 git checkout side &&
145 - git format-patch --thread -o patches/ master &&
146 - FIRST_MID=$(grep "Message-Id:" patches/0001-* | sed "s/^[^<]*\(<[^>]*>\).*$/\1/") &&
147 - for i in patches/0002-* patches/0003-*
148 - do
149 - grep "References: $FIRST_MID" $i &&
150 - grep "In-Reply-To: $FIRST_MID" $i || break
151 - done
172 + check_threading expect.no-threading master
173 '
174
154 -test_expect_success 'thread in-reply-to' '
175 +cat > expect.thread <<EOF
176 +---
177 +Message-Id: <0>
178 +---
179 +Message-Id: <1>
180 +In-Reply-To: <0>
181 +References: <0>
182 +---
183 +Message-Id: <2>
184 +In-Reply-To: <0>
185 +References: <0>
186 +EOF
187
156 - rm -rf patches/ &&
157 - git checkout side &&
158 - git format-patch --in-reply-to="<test.message>" --thread -o patches/ master &&
159 - FIRST_MID="<test.message>" &&
160 - for i in patches/*
161 - do
162 - grep "References: $FIRST_MID" $i &&
163 - grep "In-Reply-To: $FIRST_MID" $i || break
164 - done
188 +test_expect_success 'thread' '
189 + check_threading expect.thread --thread master
190 '
191
167 -test_expect_success 'thread cover-letter' '
192 +cat > expect.in-reply-to <<EOF
193 +---
194 +Message-Id: <0>
195 +In-Reply-To: <1>
196 +References: <1>
197 +---
198 +Message-Id: <2>
199 +In-Reply-To: <1>
200 +References: <1>
201 +---
202 +Message-Id: <3>
203 +In-Reply-To: <1>
204 +References: <1>
205 +EOF
206
169 - rm -rf patches/ &&
170 - git checkout side &&
171 - git format-patch --cover-letter --thread -o patches/ master &&
172 - FIRST_MID=$(grep "Message-Id:" patches/0000-* | sed "s/^[^<]*\(<[^>]*>\).*$/\1/") &&
173 - for i in patches/0001-* patches/0002-* patches/0003-*
174 - do
175 - grep "References: $FIRST_MID" $i &&
176 - grep "In-Reply-To: $FIRST_MID" $i || break
177 - done
207 +test_expect_success 'thread in-reply-to' '
208 + check_threading expect.in-reply-to --in-reply-to="<test.message>" \
209 + --thread master
210 '
211
180 -test_expect_success 'thread cover-letter in-reply-to' '
212 +cat > expect.cover-letter <<EOF
213 +---
214 +Message-Id: <0>
215 +---
216 +Message-Id: <1>
217 +In-Reply-To: <0>
218 +References: <0>
219 +---
220 +Message-Id: <2>
221 +In-Reply-To: <0>
222 +References: <0>
223 +---
224 +Message-Id: <3>
225 +In-Reply-To: <0>
226 +References: <0>
227 +EOF
228
182 - rm -rf patches/ &&
183 - git checkout side &&
184 - git format-patch --cover-letter --in-reply-to="<test.message>" --thread -o patches/ master &&
185 - FIRST_MID="<test.message>" &&
186 - for i in patches/*
187 - do
188 - grep "References: $FIRST_MID" $i &&
189 - grep "In-Reply-To: $FIRST_MID" $i || break
190 - done
229 +test_expect_success 'thread cover-letter' '
230 + check_threading expect.cover-letter --cover-letter --thread master
231 +'
232 +
233 +cat > expect.cl-irt <<EOF
234 +---
235 +Message-Id: <0>
236 +In-Reply-To: <1>
237 +References: <1>
238 +---
239 +Message-Id: <2>
240 +In-Reply-To: <1>
241 +References: <1>
242 +---
243 +Message-Id: <3>
244 +In-Reply-To: <1>
245 +References: <1>
246 +---
247 +Message-Id: <4>
248 +In-Reply-To: <1>
249 +References: <1>
250 +EOF
251 +
252 +test_expect_success 'thread cover-letter in-reply-to' '
253 + check_threading expect.cl-irt --cover-letter \
254 + --in-reply-to="<test.message>" --thread master
255 '
256
257 test_expect_success 'excessive subject' '