Last active
February 4, 2016 23:10
-
-
Save lifeisfoo/d4339402efbd956f8216 to your computer and use it in GitHub Desktop.
A script that generate a repository with random commits and one bug (return code) in one of them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mkdir git-bisect-test | |
cd git-bisect-test | |
git init | |
echo "#!bin/sh\n" > script.sh | |
echo "exit 0" >> script.sh | |
git add script.sh | |
git commit -a -m "initial commit" | |
COUNTER=0 | |
COMMITS_COUNT=$(($RANDOM % 100)) | |
BUG_INDEX=$(($RANDOM % $COMMITS_COUNT)) | |
while [ $COUNTER -lt $COMMITS_COUNT ]; do | |
if [ $COUNTER = $BUG_INDEX ]; then | |
echo "#!/bin/sh\n" > script.sh | |
echo "exit 3" >> script.sh | |
else | |
echo "#" >> script.sh | |
fi | |
let COUNTER=COUNTER+1 | |
git commit -a -m 'dunno' | |
done | |
FIRST_PARENT=`git rev-list HEAD | tail -n 1` | |
echo "\n" | |
echo "START BISECT WITH 'git bisect start HEAD $FIRST_PARENT'\n" | |
echo "THEN START AUTOMATE TEST 'git bisect run sh script.sh'\n" | |
echo "OR USE AN EXTERNAL SCRIPT FILE 'git bisect run ../test.sh'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment