War on whitespace
[git/mergetool.git] / t / t6030-bisect-porcelain.sh
blob03cdba5808aef6fbec2d95f771e6551396ff94cf
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 test_tick
26 git-commit --quiet -m "$MSG" $_file
29 HASH1=
30 HASH2=
31 HASH3=
32 HASH4=
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' '
46 git bisect reset &&
47 git bisect start &&
48 git bisect bad $HASH4 &&
49 git bisect next
52 test_expect_success 'bisect does not start with only one good' '
53 git bisect reset &&
54 git bisect start &&
55 git bisect good $HASH1 || return 1
57 if git bisect next
58 then
59 echo Oops, should have failed.
60 false
61 else
66 test_expect_success 'bisect start with one bad and good' '
67 git bisect reset &&
68 git bisect start &&
69 git bisect good $HASH1 &&
70 git bisect bad $HASH4 &&
71 git bisect next
74 # We want to automatically find the commit that
75 # introduced "Another" into hello.
76 test_expect_success \
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 &&
82 git bisect start &&
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 &&
87 git bisect reset'
89 # We want to automatically find the commit that
90 # introduced "Ciao" into hello.
91 test_expect_success \
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 &&
100 git bisect reset'
104 test_done