@@ -279,53 +279,68 @@ $ git bisect start HEAD origin -- # HEAD is bad, origin is good
279
279
$ git bisect run make test # "make test" builds and tests
280
280
------------
281
281
282
- * Automatically bisect a broken test suite :
282
+ * Automatically bisect a broken test case :
283
283
+
284
284
------------
285
285
$ cat ~/test.sh
286
286
#!/bin/sh
287
- make || exit 125 # this skips broken builds
288
- make test # "make test" runs the test suite
289
- $ git bisect start v1.3 v1.1 -- # v1.3 is bad, v1.1 is good
287
+ make || exit 125 # this skips broken builds
288
+ ~/check_test_case.sh # does the test case pass?
289
+ $ git bisect start HEAD HEAD~10 -- # culprit is among the last 10
290
290
$ git bisect run ~/test.sh
291
291
------------
292
292
+
293
293
Here we use a "test.sh" custom script. In this script, if "make"
294
294
fails, we skip the current commit.
295
+ "check_test_case.sh" should "exit 0" if the test case passes,
296
+ and "exit 1" otherwise.
295
297
+
296
- It is safer to use a custom script outside the repository to prevent
297
- interactions between the bisect, make and test processes and the
298
- script.
299
- +
300
- "make test" should "exit 0", if the test suite passes, and
301
- "exit 1" otherwise.
298
+ It is safer if both "test.sh" and "check_test_case.sh" are
299
+ outside the repository to prevent interactions between the bisect,
300
+ make and test processes and the scripts.
302
301
303
- * Automatically bisect a broken test case :
302
+ * Automatically bisect with temporary modifications (hot-fix) :
304
303
+
305
304
------------
306
305
$ cat ~/test.sh
307
306
#!/bin/sh
308
- make || exit 125 # this skips broken builds
309
- ~/check_test_case.sh # does the test case passes ?
310
- $ git bisect start HEAD HEAD~10 -- # culprit is among the last 10
311
- $ git bisect run ~/test.sh
307
+
308
+ # tweak the working tree by merging the hot-fix branch
309
+ # and then attempt a build
310
+ if git merge --no-commit hot-fix &&
311
+ make
312
+ then
313
+ # run project specific test and report its status
314
+ ~/check_test_case.sh
315
+ status=$?
316
+ else
317
+ # tell the caller this is untestable
318
+ status=125
319
+ fi
320
+
321
+ # undo the tweak to allow clean flipping to the next commit
322
+ git reset --hard
323
+
324
+ # return control
325
+ exit $status
312
326
------------
313
327
+
314
- Here "check_test_case.sh" should "exit 0" if the test case passes ,
315
- and "exit 1" otherwise.
316
- +
317
- It is safer if both "test.sh" and "check_test_case.sh" scripts are
318
- outside the repository to prevent interactions between the bisect,
319
- make and test processes and the scripts.
328
+ This applies modifications from a hot-fix branch before each test run ,
329
+ e.g. in case your build or test environment changed so that older
330
+ revisions may need a fix which newer ones have already. (Make sure the
331
+ hot-fix branch is based off a commit which is contained in all revisions
332
+ which you are bisecting, so that the merge does not pull in too much, or
333
+ use `git cherry-pick` instead of `git merge`.)
320
334
321
- * Automatically bisect a broken test suite :
335
+ * Automatically bisect a broken test case :
322
336
+
323
337
------------
324
338
$ git bisect start HEAD HEAD~10 -- # culprit is among the last 10
325
339
$ git bisect run sh -c "make || exit 125; ~/check_test_case.sh"
326
340
------------
327
341
+
328
- Does the same as the previous example, but on a single line.
342
+ This shows that you can do without a run script if you write the test
343
+ on a single line.
329
344
330
345
Author
331
346
------
0 commit comments