Automatic bisect
- Git course
- Advanced
- Lesson 7/56
- 4 min
Learn automatic testing with bisect run.
Automated bisect
Instead of testing every commit manually during a bisect search, you can run a test command with git bisect run. Git executes that command automatically on each selected revision. It uses the test's exit status to classify the commit as good or bad.
git bisect run npm testThe test command must produce reliable and repeatable results for every revision.
Test exit codes
git bisect run interprets the result using the test command's exit status. Usually, 0 indicates a successful test, while codes from 1 to 127 indicate a failure. Special exit codes are also available for cases where a test cannot be run, so configure the test command carefully.
git bisect run ./test.shThe test script should run under consistent conditions on each revision and report its result using an appropriate exit code.
Practice Run an automated bisect test
Assume the bisect search has started and the good/bad boundaries have already been defined. Run npm test automatically throughout the search.
Starter code
# Belirlenen aralıkta testi otomatik çalıştırExpected output
Running 'npm test' for each selected revision.
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which option tells Git which test command to run on each commit during an automated bisect?
- git bisect log
- git bisect reset
- git bisect run Correct answer
- git bisect start
Explanation: git bisect run automatically executes the specified test command during the search.
2 Run a test script automatically
git bisect ____
git bisect run ./test.sh
Explanation: The run option executes the specified test script on commits in the bisect search.
3 Automated testing workflow
| Term | Meaning |
|---|---|
git bisect run |
Runs the test command automatically |
Test betiği |
Checks application behavior |
Çıkış kodu 0 |
Indicates that the test passed |
Çıkış kodu 1 |
Indicates that the test failed |