bisect: add test cases to check that "git bisect start" is atomic
This patch adds some test cases to check that "git bisect start" doesn't leave us in a bad state, especially when it fails. These test cases show that "git bisect start" is not atomic when it fails and leave some files like .git/BISECT_START, and in some cases some refs, over. The test failures should be fixed in latter commits. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
May 23, 2008 at 00:38 UTC
d3aca58562ee5c4af5266affd942c58dcb9f064d
1 file changed
+43
t/t6030-bisect-porcelain.sh
+43
@@ -126,6 +126,49 @@ test_expect_success 'bisect reset removes packed refs' '
126
test -z "$(git for-each-ref "refs/heads/bisect")"
127
'
128
129
+test_expect_success 'bisect start: back in good branch' '
130
+ git branch > branch.output &&
131
+ grep "* other" branch.output > /dev/null &&
132
+ git bisect start $HASH4 $HASH1 -- &&
133
+ git bisect good &&
134
+ git bisect start $HASH4 $HASH1 -- &&
135
+ git bisect bad &&
136
+ git bisect reset &&
137
+ git branch > branch.output &&
138
+ grep "* other" branch.output > /dev/null
139
+'
140
+
141
+test_expect_failure 'bisect start: no ".git/BISECT_START" if junk rev' '
142
+ git bisect start $HASH4 $HASH1 -- &&
143
+ git bisect good &&
144
+ test_must_fail git bisect start $HASH4 foo -- &&
145
+ git branch > branch.output &&
146
+ grep "* other" branch.output > /dev/null &&
147
+ test_must_fail test -e .git/BISECT_START
148
+'
149
+
150
+test_expect_failure 'bisect start: no ".git/BISECT_START" if mistaken rev' '
151
+ git bisect start $HASH4 $HASH1 -- &&
152
+ git bisect good &&
153
+ test_must_fail git bisect start $HASH1 $HASH4 -- &&
154
+ git branch > branch.output &&
155
+ grep "* other" branch.output > /dev/null &&
156
+ test_must_fail test -e .git/BISECT_START
157
+'
158
+
159
+test_expect_failure 'bisect start: no ".git/BISECT_START" if checkout error' '
160
+ echo "temp stuff" > hello &&
161
+ test_must_fail git bisect start $HASH4 $HASH1 -- &&
162
+ git branch &&
163
+ git branch > branch.output &&
164
+ grep "* other" branch.output > /dev/null &&
165
+ test_must_fail test -e .git/BISECT_START &&
166
+ test -z "$(git for-each-ref "refs/bisect/*")"
167
+'
168
+
169
+# This cleanup is needed whatever the result of the above test.
170
+git checkout HEAD hello
171
+
172
# $HASH1 is good, $HASH4 is bad, we skip $HASH3
173
# but $HASH2 is bad,
174
# so we should find $HASH2 as the first bad commit