@matheusbsbs / matheus-bagliano / commits / 5d27485944
Fork 0

t4150 (am): futureproof against failing tests

Most tests in t4150 begin by navigating to a sane state and applying some patch: git checkout first && git am patch1 If a previous test left behind unmerged files or a .git/rebase-apply directory, they are untouched and the test fails, causing later tests to fail, too. This is not a problem in practice because none of the tests leave a mess behind. But as a futureproofing measure, it is still best to avoid the problem and clean up at the start of each test. In particular, this simplifies the process of adding new tests that are known to fail. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Jul 23, 2010 at 12:04 UTC 5d274859444260142a77b844ab616f07bf80aaa5
1 file changed +47 -1
t/t4150-am.sh
+47 -1
@@ -122,6 +122,8 @@ test_expect_success setup '
122 '
123
124 test_expect_success 'am applies patch correctly' '
125 + rm -fr .git/rebase-apply &&
126 + git reset --hard &&
127 git checkout first &&
128 test_tick &&
129 git am <patch1 &&
@@ -132,6 +134,8 @@ test_expect_success 'am applies patch correctly' '
134 '
135
136 test_expect_success 'am applies patch e-mail not in a mbox' '
137 + rm -fr .git/rebase-apply &&
138 + git reset --hard &&
139 git checkout first &&
140 git am patch1.eml &&
141 ! test -d .git/rebase-apply &&
@@ -141,6 +145,8 @@ test_expect_success 'am applies patch e-mail not in a mbox' '
145 '
146
147 test_expect_success 'am applies patch e-mail not in a mbox with CRLF' '
148 + rm -fr .git/rebase-apply &&
149 + git reset --hard &&
150 git checkout first &&
151 git am patch1-crlf.eml &&
152 ! test -d .git/rebase-apply &&
@@ -165,6 +171,8 @@ compare () {
171
172 test_expect_success 'am changes committer and keeps author' '
173 test_tick &&
174 + rm -fr .git/rebase-apply &&
175 + git reset --hard &&
176 git checkout first &&
177 git am patch2 &&
178 ! test -d .git/rebase-apply &&
@@ -178,6 +186,8 @@ test_expect_success 'am changes committer and keeps author' '
186 '
187
188 test_expect_success 'am --signoff adds Signed-off-by: line' '
189 + rm -fr .git/rebase-apply &&
190 + git reset --hard &&
191 git checkout -b master2 first &&
192 git am --signoff <patch2 &&
193 printf "%s\n" "$signoff" >expected &&
@@ -198,6 +208,8 @@ test_expect_success 'am stays in branch' '
208 test_expect_success 'am --signoff does not add Signed-off-by: line if already there' '
209 git format-patch --stdout HEAD^ >patch3 &&
210 sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2," patch3 >patch4
211 + rm -fr .git/rebase-apply &&
212 + git reset --hard &&
213 git checkout HEAD^ &&
214 git am --signoff patch4 &&
215 git cat-file commit HEAD >actual &&
@@ -211,6 +223,8 @@ test_expect_success 'am without --keep removes Re: and [PATCH] stuff' '
223 '
224
225 test_expect_success 'am --keep really keeps the subject' '
226 + rm -fr .git/rebase-apply &&
227 + git reset --hard &&
228 git checkout HEAD^ &&
229 git am --keep patch4 &&
230 ! test -d .git/rebase-apply &&
@@ -219,6 +233,8 @@ test_expect_success 'am --keep really keeps the subject' '
233 '
234
235 test_expect_success 'am -3 falls back to 3-way merge' '
236 + rm -fr .git/rebase-apply &&
237 + git reset --hard &&
238 git checkout -b lorem2 master2 &&
239 sed -n -e "3,\$p" msg >file &&
240 head -n 9 msg >>file &&
@@ -231,6 +247,7 @@ test_expect_success 'am -3 falls back to 3-way merge' '
247 '
248
249 test_expect_success 'am -3 -q is quiet' '
250 + rm -fr .git/rebase-apply &&
251 git reset master2 --hard &&
252 sed -n -e "3,\$p" msg >file &&
253 head -n 9 msg >>file &&
@@ -242,6 +259,8 @@ test_expect_success 'am -3 -q is quiet' '
259 '
260
261 test_expect_success 'am pauses on conflict' '
262 + rm -fr .git/rebase-apply &&
263 + git reset --hard &&
264 git checkout lorem2^^ &&
265 test_must_fail git am lorem-move.patch &&
266 test -d .git/rebase-apply
@@ -257,6 +276,8 @@ test_expect_success 'am --skip works' '
276
277 test_expect_success 'am --resolved works' '
278 echo goodbye >expected &&
279 + rm -fr .git/rebase-apply &&
280 + git reset --hard &&
281 git checkout lorem2^^ &&
282 test_must_fail git am lorem-move.patch &&
283 test -d .git/rebase-apply &&
@@ -268,6 +289,8 @@ test_expect_success 'am --resolved works' '
289 '
290
291 test_expect_success 'am takes patches from a Pine mailbox' '
292 + rm -fr .git/rebase-apply &&
293 + git reset --hard &&
294 git checkout first &&
295 cat pine patch1 | git am &&
296 ! test -d .git/rebase-apply &&
@@ -275,11 +298,16 @@ test_expect_success 'am takes patches from a Pine mailbox' '
298 '
299
300 test_expect_success 'am fails on mail without patch' '
301 + rm -fr .git/rebase-apply &&
302 + git reset --hard &&
303 test_must_fail git am <failmail &&
279 - rm -r .git/rebase-apply/
304 + git am --abort &&
305 + ! test -d .git/rebase-apply
306 '
307
308 test_expect_success 'am fails on empty patch' '
309 + rm -fr .git/rebase-apply &&
310 + git reset --hard &&
311 echo "---" >>failmail &&
312 test_must_fail git am <failmail &&
313 git am --skip &&
@@ -288,6 +316,8 @@ test_expect_success 'am fails on empty patch' '
316
317 test_expect_success 'am works from stdin in subdirectory' '
318 rm -fr subdir &&
319 + rm -fr .git/rebase-apply &&
320 + git reset --hard &&
321 git checkout first &&
322 (
323 mkdir -p subdir &&
@@ -299,6 +329,8 @@ test_expect_success 'am works from stdin in subdirectory' '
329
330 test_expect_success 'am works from file (relative path given) in subdirectory' '
331 rm -fr subdir &&
332 + rm -fr .git/rebase-apply &&
333 + git reset --hard &&
334 git checkout first &&
335 (
336 mkdir -p subdir &&
@@ -310,6 +342,8 @@ test_expect_success 'am works from file (relative path given) in subdirectory' '
342
343 test_expect_success 'am works from file (absolute path given) in subdirectory' '
344 rm -fr subdir &&
345 + rm -fr .git/rebase-apply &&
346 + git reset --hard &&
347 git checkout first &&
348 P=$(pwd) &&
349 (
@@ -321,6 +355,8 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '
355 '
356
357 test_expect_success 'am --committer-date-is-author-date' '
358 + rm -fr .git/rebase-apply &&
359 + git reset --hard &&
360 git checkout first &&
361 test_tick &&
362 git am --committer-date-is-author-date patch1 &&
@@ -331,6 +367,8 @@ test_expect_success 'am --committer-date-is-author-date' '
367 '
368
369 test_expect_success 'am without --committer-date-is-author-date' '
370 + rm -fr .git/rebase-apply &&
371 + git reset --hard &&
372 git checkout first &&
373 test_tick &&
374 git am patch1 &&
@@ -345,6 +383,8 @@ test_expect_success 'am without --committer-date-is-author-date' '
383 # by test_tick that uses -0700 timezone; if this feature does not
384 # work, we will see that instead of +0000.
385 test_expect_success 'am --ignore-date' '
386 + rm -fr .git/rebase-apply &&
387 + git reset --hard &&
388 git checkout first &&
389 test_tick &&
390 git am --ignore-date patch1 &&
@@ -355,6 +395,8 @@ test_expect_success 'am --ignore-date' '
395
396 test_expect_success 'am into an unborn branch' '
397 git rev-parse first^{tree} >expected &&
398 + rm -fr .git/rebase-apply &&
399 + git reset --hard &&
400 rm -fr subdir &&
401 mkdir subdir &&
402 git format-patch --numbered-files -o subdir -1 first &&
@@ -371,6 +413,8 @@ test_expect_success 'am into an unborn branch' '
413 '
414
415 test_expect_success 'am newline in subject' '
416 + rm -fr .git/rebase-apply &&
417 + git reset --hard &&
418 git checkout first &&
419 test_tick &&
420 sed -e "s/second/second \\\n foo/" patch1 >patchnl &&
@@ -379,6 +423,8 @@ test_expect_success 'am newline in subject' '
423 '
424
425 test_expect_success 'am -q is quiet' '
426 + rm -fr .git/rebase-apply &&
427 + git reset --hard &&
428 git checkout first &&
429 test_tick &&
430 git am -q <patch1 >output.out 2>&1 &&