3 # Copyright (c) 2007 Christian Couder
5 test_description
='Tests git-bisect functionality'
16 if [ -f "$_file" ]; then
17 echo "$_line" >> $_file ||
return $?
18 MSG
="Add <$_line> into <$_file>."
20 echo "$_line" > $_file ||
return $?
21 git add
$_file ||
return $?
22 MSG
="Create file <$_file> with <$_line> inside."
26 git-commit
--quiet -m "$MSG" $_file
34 test_expect_success
'set up basic repo with 1 file (hello) and 4 commits' '
35 add_line_into_file "1: Hello World" hello &&
36 HASH1=$(git rev-parse --verify HEAD) &&
37 add_line_into_file "2: A new day for git" hello &&
38 HASH2=$(git rev-parse --verify HEAD) &&
39 add_line_into_file "3: Another new day for git" hello &&
40 HASH3=$(git rev-parse --verify HEAD) &&
41 add_line_into_file "4: Ciao for now" hello &&
42 HASH4=$(git rev-parse --verify HEAD)
45 test_expect_success
'bisect starts with only one bad' '
48 git bisect bad $HASH4 &&
52 test_expect_success
'bisect does not start with only one good' '
55 git bisect good $HASH1 || return 1
59 echo Oops, should have failed.
66 test_expect_success
'bisect start with one bad and good' '
69 git bisect good $HASH1 &&
70 git bisect bad $HASH4 &&
74 # We want to automatically find the commit that
75 # introduced "Another" into hello.
77 '"git bisect run" simple case' \
78 'echo "#"\!"/bin/sh" > test_script.sh &&
79 echo "grep Another hello > /dev/null" >> test_script.sh &&
80 echo "test \$? -ne 0" >> test_script.sh &&
81 chmod +x test_script.sh &&
83 git bisect good $HASH1 &&
84 git bisect bad $HASH4 &&
85 git bisect run ./test_script.sh > my_bisect_log.txt &&
86 grep "$HASH3 is first bad commit" my_bisect_log.txt &&
89 # We want to automatically find the commit that
90 # introduced "Ciao" into hello.
92 '"git bisect run" with more complex "git bisect start"' \
93 'echo "#"\!"/bin/sh" > test_script.sh &&
94 echo "grep Ciao hello > /dev/null" >> test_script.sh &&
95 echo "test \$? -ne 0" >> test_script.sh &&
96 chmod +x test_script.sh &&
97 git bisect start $HASH4 $HASH1 &&
98 git bisect run ./test_script.sh > my_bisect_log.txt &&
99 grep "$HASH4 is first bad commit" my_bisect_log.txt &&