delay progress display when checking out files
[git/dscho.git] / t / t6030-bisect-porcelain.sh
blob13e937923658868c16fee6aefc52c8f180cafdfb
1 #!/bin/sh
3 # Copyright (c) 2007 Christian Couder
5 test_description='Tests git-bisect functionality'
7 exec </dev/null
9 . ./test-lib.sh
11 add_line_into_file()
13 _line=$1
14 _file=$2
16 if [ -f "$_file" ]; then
17 echo "$_line" >> $_file || return $?
18 MSG="Add <$_line> into <$_file>."
19 else
20 echo "$_line" > $_file || return $?
21 git add $_file || return $?
22 MSG="Create file <$_file> with <$_line> inside."
25 git-commit -m "$MSG" $_file
28 HASH1=
29 HASH3=
30 HASH4=
32 test_expect_success \
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' '
43 git bisect reset &&
44 git bisect start &&
45 git bisect bad $HASH4 &&
46 git bisect next
49 test_expect_success 'bisect does not start with only one good' '
50 git bisect reset &&
51 git bisect start &&
52 git bisect good $HASH1 || return 1
54 if git bisect next
55 then
56 echo Oops, should have failed.
57 false
58 else
63 test_expect_success 'bisect start with one bad and good' '
64 git bisect reset &&
65 git bisect start &&
66 git bisect good $HASH1 &&
67 git bisect bad $HASH4 &&
68 git bisect next
71 # We want to automatically find the commit that
72 # introduced "Another" into hello.
73 test_expect_success \
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 &&
79 git bisect start &&
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 &&
84 git bisect reset'
86 # We want to automatically find the commit that
87 # introduced "Ciao" into hello.
88 test_expect_success \
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 &&
97 git bisect reset'
101 test_done