t / t6030-bisect-porcelain.shon commit fix importing of subversion tars (46f6178)
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Christian Couder
   4#
   5test_description='Tests git-bisect functionality'
   6
   7exec </dev/null
   8
   9. ./test-lib.sh
  10
  11add_line_into_file()
  12{
  13    _line=$1
  14    _file=$2
  15
  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."
  23    fi
  24
  25    git-commit -m "$MSG" $_file
  26}
  27
  28HASH1=
  29HASH3=
  30HASH4=
  31
  32test_expect_success \
  33    'set up basic repo with 1 file (hello) and 4 commits' \
  34    'add_line_into_file "1: Hello World" hello &&
  35     add_line_into_file "2: A new day for git" hello &&
  36     add_line_into_file "3: Another new day for git" hello &&
  37     add_line_into_file "4: Ciao for now" hello &&
  38     HASH1=$(git rev-list HEAD | tail -1) &&
  39     HASH3=$(git rev-list HEAD | head -2 | tail -1) &&
  40     HASH4=$(git rev-list HEAD | head -1)'
  41
  42test_expect_success 'bisect starts with only one bad' '
  43        git bisect reset &&
  44        git bisect start &&
  45        git bisect bad $HASH4 &&
  46        git bisect next
  47'
  48
  49test_expect_success 'bisect does not start with only one good' '
  50        git bisect reset &&
  51        git bisect start &&
  52        git bisect good $HASH1 || return 1
  53
  54        if git bisect next
  55        then
  56                echo Oops, should have failed.
  57                false
  58        else
  59                :
  60        fi
  61'
  62
  63test_expect_success 'bisect start with one bad and good' '
  64        git bisect reset &&
  65        git bisect start &&
  66        git bisect good $HASH1 &&
  67        git bisect bad $HASH4 &&
  68        git bisect next
  69'
  70
  71# We want to automatically find the commit that
  72# introduced "Another" into hello.
  73test_expect_success \
  74    '"git bisect run" simple case' \
  75    'echo "#"\!"/bin/sh" > test_script.sh &&
  76     echo "grep Another hello > /dev/null" >> test_script.sh &&
  77     echo "test \$? -ne 0" >> test_script.sh &&
  78     chmod +x test_script.sh &&
  79     git bisect start &&
  80     git bisect good $HASH1 &&
  81     git bisect bad $HASH4 &&
  82     git bisect run ./test_script.sh > my_bisect_log.txt &&
  83     grep "$HASH3 is first bad commit" my_bisect_log.txt &&
  84     git bisect reset'
  85
  86# We want to automatically find the commit that
  87# introduced "Ciao" into hello.
  88test_expect_success \
  89    '"git bisect run" with more complex "git bisect start"' \
  90    'echo "#"\!"/bin/sh" > test_script.sh &&
  91     echo "grep Ciao hello > /dev/null" >> test_script.sh &&
  92     echo "test \$? -ne 0" >> test_script.sh &&
  93     chmod +x test_script.sh &&
  94     git bisect start $HASH4 $HASH1 &&
  95     git bisect run ./test_script.sh > my_bisect_log.txt &&
  96     grep "$HASH4 is first bad commit" my_bisect_log.txt &&
  97     git bisect reset'
  98
  99#
 100#
 101test_done
 102