Skip to content

Commit 15a4802

Browse files
alipman88gitster
authored andcommitted
t6030: modernize "git bisect run" tests
Enforce consistent styling for tests on "git bisect run": - Use "write_script" to abstract away platform-specific details. - Favor current whitespace conventions. - While at it, change "introduced" to "added" in the comments to make them read better. Helped-by: Martin Ågren <[email protected]> Signed-off-by: Aaron Lipman <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 47ae905 commit 15a4802

File tree

1 file changed

+38
-48
lines changed

1 file changed

+38
-48
lines changed

t/t6030-bisect-porcelain.sh

Lines changed: 38 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -243,32 +243,30 @@ test_expect_success 'bisect skip: with commit both bad and skipped' '
243243
'
244244

245245
# 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+
'
259258

260259
# 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+
'
272270

273271
# $HASH1 is good, $HASH5 is bad, we skip $HASH3
274272
# but $HASH4 is good,
@@ -295,39 +293,31 @@ HASH6=
295293
test_expect_success 'bisect run & skip: cannot tell between 2' '
296294
add_line_into_file "6: Yet a line." hello &&
297295
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
303300
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
316307
'
317308

318309
HASH7=
319310
test_expect_success 'bisect run & skip: find first bad' '
320311
git bisect reset &&
321312
add_line_into_file "7: Should be the last line." hello &&
322313
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
329319
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 &&
331321
grep "$HASH6 is the first bad commit" my_bisect_log.txt
332322
'
333323

0 commit comments

Comments
 (0)