@@ -243,32 +243,30 @@ test_expect_success 'bisect skip: with commit both bad and skipped' '
243
243
'
244
244
245
245
# We want to automatically find the commit that
246
- # introduced "Another" into hello.
247
- test_expect_success \
248
- ' "git bisect run" simple case' \
249
- ' echo "#"\!"/bin/sh" > test_script.sh &&
250
- echo "grep Another hello > /dev/null" >> test_script.sh &&
251
- echo "test \$? -ne 0" >> test_script.sh &&
252
- chmod +x test_script.sh &&
253
- git bisect start &&
254
- git bisect good $HASH1 &&
255
- git bisect bad $HASH4 &&
256
- git bisect run ./test_script.sh > my_bisect_log.txt &&
257
- grep "$HASH3 is the first bad commit" my_bisect_log.txt &&
258
- git bisect reset'
246
+ # added "Another" into hello.
247
+ test_expect_success ' "git bisect run" simple case' '
248
+ write_script test_script.sh <<-\EOF &&
249
+ ! grep Another hello >/dev/null
250
+ EOF
251
+ git bisect start &&
252
+ git bisect good $HASH1 &&
253
+ git bisect bad $HASH4 &&
254
+ git bisect run ./test_script.sh >my_bisect_log.txt &&
255
+ grep "$HASH3 is the first bad commit" my_bisect_log.txt &&
256
+ git bisect reset
257
+ '
259
258
260
259
# We want to automatically find the commit that
261
- # introduced "Ciao" into hello.
262
- test_expect_success \
263
- ' "git bisect run" with more complex "git bisect start"' \
264
- ' echo "#"\!"/bin/sh" > test_script.sh &&
265
- echo "grep Ciao hello > /dev/null" >> test_script.sh &&
266
- echo "test \$? -ne 0" >> test_script.sh &&
267
- chmod +x test_script.sh &&
268
- git bisect start $HASH4 $HASH1 &&
269
- git bisect run ./test_script.sh > my_bisect_log.txt &&
270
- grep "$HASH4 is the first bad commit" my_bisect_log.txt &&
271
- git bisect reset'
260
+ # added "Ciao" into hello.
261
+ test_expect_success ' "git bisect run" with more complex "git bisect start"' '
262
+ write_script test_script.sh <<-\EOF &&
263
+ ! grep Ciao hello >/dev/null
264
+ EOF
265
+ git bisect start $HASH4 $HASH1 &&
266
+ git bisect run ./test_script.sh >my_bisect_log.txt &&
267
+ grep "$HASH4 is the first bad commit" my_bisect_log.txt &&
268
+ git bisect reset
269
+ '
272
270
273
271
# $HASH1 is good, $HASH5 is bad, we skip $HASH3
274
272
# but $HASH4 is good,
@@ -295,39 +293,31 @@ HASH6=
295
293
test_expect_success ' bisect run & skip: cannot tell between 2' '
296
294
add_line_into_file "6: Yet a line." hello &&
297
295
HASH6=$(git rev-parse --verify HEAD) &&
298
- echo "#"\!"/bin/sh" > test_script.sh &&
299
- echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
300
- echo "grep line hello > /dev/null" >> test_script.sh &&
301
- echo "test \$? -ne 0" >> test_script.sh &&
302
- chmod +x test_script.sh &&
296
+ write_script test_script.sh <<-\EOF &&
297
+ sed -ne \$p hello | grep Ciao >/dev/null && exit 125
298
+ ! grep line hello >/dev/null
299
+ EOF
303
300
git bisect start $HASH6 $HASH1 &&
304
- if git bisect run ./test_script.sh > my_bisect_log.txt
305
- then
306
- echo Oops, should have failed.
307
- false
308
- else
309
- test $? -eq 2 &&
310
- grep "first bad commit could be any of" my_bisect_log.txt &&
311
- ! grep $HASH3 my_bisect_log.txt &&
312
- ! grep $HASH6 my_bisect_log.txt &&
313
- grep $HASH4 my_bisect_log.txt &&
314
- grep $HASH5 my_bisect_log.txt
315
- fi
301
+ test_expect_code 2 git bisect run ./test_script.sh >my_bisect_log.txt &&
302
+ grep "first bad commit could be any of" my_bisect_log.txt &&
303
+ ! grep $HASH3 my_bisect_log.txt &&
304
+ ! grep $HASH6 my_bisect_log.txt &&
305
+ grep $HASH4 my_bisect_log.txt &&
306
+ grep $HASH5 my_bisect_log.txt
316
307
'
317
308
318
309
HASH7=
319
310
test_expect_success ' bisect run & skip: find first bad' '
320
311
git bisect reset &&
321
312
add_line_into_file "7: Should be the last line." hello &&
322
313
HASH7=$(git rev-parse --verify HEAD) &&
323
- echo "#"\!"/bin/sh" > test_script.sh &&
324
- echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
325
- echo "sed -ne \\\$p hello | grep day > /dev/null && exit 125" >> test_script.sh &&
326
- echo "grep Yet hello > /dev/null" >> test_script.sh &&
327
- echo "test \$? -ne 0" >> test_script.sh &&
328
- chmod +x test_script.sh &&
314
+ write_script test_script.sh <<-\EOF &&
315
+ sed -ne \$p hello | grep Ciao >/dev/null && exit 125
316
+ sed -ne \$p hello | grep day >/dev/null && exit 125
317
+ ! grep Yet hello >/dev/null
318
+ EOF
329
319
git bisect start $HASH7 $HASH1 &&
330
- git bisect run ./test_script.sh > my_bisect_log.txt &&
320
+ git bisect run ./test_script.sh >my_bisect_log.txt &&
331
321
grep "$HASH6 is the first bad commit" my_bisect_log.txt
332
322
'
333
323
0 commit comments