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 <martin.agren@gmail.com>
Signed-off-by: Aaron Lipman <alipman88@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Aaron Lipman 2020-08-07 17:58:34 -04:00 committed by Junio C Hamano
parent 47ae905ffb
commit 15a4802a69
1 changed files with 38 additions and 48 deletions

View File

@ -243,32 +243,30 @@ test_expect_success 'bisect skip: with commit both bad and skipped' '
' '


# We want to automatically find the commit that # We want to automatically find the commit that
# introduced "Another" into hello. # added "Another" into hello.
test_expect_success \ test_expect_success '"git bisect run" simple case' '
'"git bisect run" simple case' \ write_script test_script.sh <<-\EOF &&
'echo "#"\!"/bin/sh" > test_script.sh && ! grep Another hello >/dev/null
echo "grep Another hello > /dev/null" >> test_script.sh && EOF
echo "test \$? -ne 0" >> test_script.sh && git bisect start &&
chmod +x test_script.sh && git bisect good $HASH1 &&
git bisect start && git bisect bad $HASH4 &&
git bisect good $HASH1 && git bisect run ./test_script.sh >my_bisect_log.txt &&
git bisect bad $HASH4 && grep "$HASH3 is the first bad commit" my_bisect_log.txt &&
git bisect run ./test_script.sh > my_bisect_log.txt && git bisect reset
grep "$HASH3 is the first bad commit" my_bisect_log.txt && '
git bisect reset'


# We want to automatically find the commit that # We want to automatically find the commit that
# introduced "Ciao" into hello. # added "Ciao" into hello.
test_expect_success \ test_expect_success '"git bisect run" with more complex "git bisect start"' '
'"git bisect run" with more complex "git bisect start"' \ write_script test_script.sh <<-\EOF &&
'echo "#"\!"/bin/sh" > test_script.sh && ! grep Ciao hello >/dev/null
echo "grep Ciao hello > /dev/null" >> test_script.sh && EOF
echo "test \$? -ne 0" >> test_script.sh && git bisect start $HASH4 $HASH1 &&
chmod +x test_script.sh && git bisect run ./test_script.sh >my_bisect_log.txt &&
git bisect start $HASH4 $HASH1 && grep "$HASH4 is the first bad commit" my_bisect_log.txt &&
git bisect run ./test_script.sh > my_bisect_log.txt && git bisect reset
grep "$HASH4 is the first bad commit" my_bisect_log.txt && '
git bisect reset'


# $HASH1 is good, $HASH5 is bad, we skip $HASH3 # $HASH1 is good, $HASH5 is bad, we skip $HASH3
# but $HASH4 is good, # but $HASH4 is good,
@ -295,24 +293,17 @@ HASH6=
test_expect_success 'bisect run & skip: cannot tell between 2' ' test_expect_success 'bisect run & skip: cannot tell between 2' '
add_line_into_file "6: Yet a line." hello && add_line_into_file "6: Yet a line." hello &&
HASH6=$(git rev-parse --verify HEAD) && HASH6=$(git rev-parse --verify HEAD) &&
echo "#"\!"/bin/sh" > test_script.sh && write_script test_script.sh <<-\EOF &&
echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh && sed -ne \$p hello | grep Ciao >/dev/null && exit 125
echo "grep line hello > /dev/null" >> test_script.sh && ! grep line hello >/dev/null
echo "test \$? -ne 0" >> test_script.sh && EOF
chmod +x test_script.sh &&
git bisect start $HASH6 $HASH1 && git bisect start $HASH6 $HASH1 &&
if git bisect run ./test_script.sh > my_bisect_log.txt test_expect_code 2 git bisect run ./test_script.sh >my_bisect_log.txt &&
then grep "first bad commit could be any of" my_bisect_log.txt &&
echo Oops, should have failed. ! grep $HASH3 my_bisect_log.txt &&
false ! grep $HASH6 my_bisect_log.txt &&
else grep $HASH4 my_bisect_log.txt &&
test $? -eq 2 && grep $HASH5 my_bisect_log.txt
grep "first bad commit could be any of" my_bisect_log.txt &&
! grep $HASH3 my_bisect_log.txt &&
! grep $HASH6 my_bisect_log.txt &&
grep $HASH4 my_bisect_log.txt &&
grep $HASH5 my_bisect_log.txt
fi
' '


HASH7= HASH7=
@ -320,14 +311,13 @@ test_expect_success 'bisect run & skip: find first bad' '
git bisect reset && git bisect reset &&
add_line_into_file "7: Should be the last line." hello && add_line_into_file "7: Should be the last line." hello &&
HASH7=$(git rev-parse --verify HEAD) && HASH7=$(git rev-parse --verify HEAD) &&
echo "#"\!"/bin/sh" > test_script.sh && write_script test_script.sh <<-\EOF &&
echo "sed -ne \\\$p hello | grep Ciao > /dev/null && exit 125" >> test_script.sh && sed -ne \$p hello | grep Ciao >/dev/null && exit 125
echo "sed -ne \\\$p hello | grep day > /dev/null && exit 125" >> test_script.sh && sed -ne \$p hello | grep day >/dev/null && exit 125
echo "grep Yet hello > /dev/null" >> test_script.sh && ! grep Yet hello >/dev/null
echo "test \$? -ne 0" >> test_script.sh && EOF
chmod +x test_script.sh &&
git bisect start $HASH7 $HASH1 && git bisect start $HASH7 $HASH1 &&
git bisect run ./test_script.sh > my_bisect_log.txt && git bisect run ./test_script.sh >my_bisect_log.txt &&
grep "$HASH6 is the first bad commit" my_bisect_log.txt grep "$HASH6 is the first bad commit" my_bisect_log.txt
' '