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."
25 git-commit -m "$MSG" $_file
33 'set up basic repo with 1 file (hello) and 4 commits' \
34 'add_line_into_file "1: Hello World" hello &&
35 add_line_into_file "2: A new day for git" hello &&
36 add_line_into_file "3: Another new day for git" hello &&
37 add_line_into_file "4: Ciao for now" hello &&
38 HASH1=$(git rev-list HEAD | tail -1) &&
39 HASH3=$(git rev-list HEAD | head -2 | tail -1) &&
40 HASH4=$(git rev-list HEAD | head -1)'
42 test_expect_success 'bisect starts with only one bad' '
45 git bisect bad $HASH4 &&
49 test_expect_success 'bisect does not start with only one good' '
52 git bisect good $HASH1 || return 1
56 echo Oops, should have failed.
63 test_expect_success 'bisect start with one bad and good' '
66 git bisect good $HASH1 &&
67 git bisect bad $HASH4 &&
71 # We want to automatically find the commit that
72 # introduced "Another" into hello.
74 '"git bisect run" simple case' \
75 'echo "#"\!"/bin/sh" > test_script.sh &&
76 echo "grep Another hello > /dev/null" >> test_script.sh &&
77 echo "test \$? -ne 0" >> test_script.sh &&
78 chmod +x test_script.sh &&
80 git bisect good $HASH1 &&
81 git bisect bad $HASH4 &&
82 git bisect run ./test_script.sh > my_bisect_log.txt &&
83 grep "$HASH3 is first bad commit" my_bisect_log.txt &&
86 # We want to automatically find the commit that
87 # introduced "Ciao" into hello.
89 '"git bisect run" with more complex "git bisect start"' \
90 'echo "#"\!"/bin/sh" > test_script.sh &&
91 echo "grep Ciao hello > /dev/null" >> test_script.sh &&
92 echo "test \$? -ne 0" >> test_script.sh &&
93 chmod +x test_script.sh &&
94 git bisect start $HASH4 $HASH1 &&
95 git bisect run ./test_script.sh > my_bisect_log.txt &&
96 grep "$HASH4 is first bad commit" my_bisect_log.txt &&