Merge branch 'mg/test-installed'
authorJunio C Hamano <gitster@pobox.com>
Sun, 22 Mar 2009 06:24:40 +0000 (23:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 22 Mar 2009 06:24:40 +0000 (23:24 -0700)
* mg/test-installed:
test-lib.sh: Allow running the test suite against installed git
test-lib.sh: Test for presence of git-init in the right path.

1  2 
t/test-lib.sh
diff --combined t/test-lib.sh
index 638cca41e3bb08da342a5ed115a0d1f779f63fbb,a70b633dd9b6691e7cb2b603e4ec0350c2095418..7ff75644c056f8fc9ea3017ca369e6f58161f4e5
@@@ -238,25 -238,18 +238,25 @@@ test_merge () 
        git tag "$1"
  }
  
 +# This function helps systems where core.filemode=false is set.
 +# Use it instead of plain 'chmod +x' to set or unset the executable bit
 +# of a file in the working directory and add it to the index.
 +
 +test_chmod () {
 +      chmod "$@" &&
 +      git update-index --add "--chmod=$@"
 +}
 +
  # You are not expected to call test_ok_ and test_failure_ directly, use
  # the text_expect_* functions instead.
  
  test_ok_ () {
 -      test_count=$(expr "$test_count" + 1)
 -      test_success=$(expr "$test_success" + 1)
 +      test_success=$(($test_success + 1))
        say_color "" "  ok $test_count: $@"
  }
  
  test_failure_ () {
 -      test_count=$(expr "$test_count" + 1)
 -      test_failure=$(expr "$test_failure" + 1);
 +      test_failure=$(($test_failure + 1))
        say_color error "FAIL $test_count: $1"
        shift
        echo "$@" | sed -e 's/^/        /'
  }
  
  test_known_broken_ok_ () {
 -      test_count=$(expr "$test_count" + 1)
        test_fixed=$(($test_fixed+1))
        say_color "" "  FIXED $test_count: $@"
  }
  
  test_known_broken_failure_ () {
 -      test_count=$(expr "$test_count" + 1)
        test_broken=$(($test_broken+1))
        say_color skip "  still broken $test_count: $@"
  }
@@@ -284,11 -279,12 +284,11 @@@ test_run_ () 
  }
  
  test_skip () {
 -      this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
 -      this_test="$this_test.$(expr "$test_count" + 1)"
 +      test_count=$(($test_count+1))
        to_skip=
        for skp in $GIT_SKIP_TESTS
        do
 -              case "$this_test" in
 +              case $this_test.$test_count in
                $skp)
                        to_skip=t
                esac
        case "$to_skip" in
        t)
                say_color skip >&3 "skipping test: $@"
 -              test_count=$(expr "$test_count" + 1)
                say_color skip "skip $test_count: $1"
                : true
                ;;
@@@ -373,7 -370,7 +373,7 @@@ test_external () 
        then
                # Announce the script to reduce confusion about the
                # test output that follows.
 -              say_color "" " run $(expr "$test_count" + 1): $descr ($*)"
 +              say_color "" " run $test_count: $descr ($*)"
                # Run command; redirect its stderr to &4 as in
                # test_run_, but keep its stdout on our stdout even in
                # non-verbose mode.
@@@ -457,7 -454,7 +457,7 @@@ test_create_repo () 
        repo="$1"
        mkdir -p "$repo"
        cd "$repo" || error "Cannot setup test environment"
-       "$GIT_EXEC_PATH/git" init "--template=$owd/../templates/blt/" >&3 2>&4 ||
+       "$GIT_EXEC_PATH/git-init" "--template=$owd/../templates/blt/" >&3 2>&4 ||
        error "cannot run git init -- have you built things yet?"
        mv .git/hooks .git/hooks-disabled
        cd "$owd"
@@@ -517,8 -514,16 +517,16 @@@ test_done () 
  TEST_DIRECTORY=$(pwd)
  if test -z "$valgrind"
  then
-       PATH=$TEST_DIRECTORY/..:$PATH
-       GIT_EXEC_PATH=$TEST_DIRECTORY/..
+       if test -z "$GIT_TEST_INSTALLED"
+       then
+               PATH=$TEST_DIRECTORY/..:$PATH
+               GIT_EXEC_PATH=$TEST_DIRECTORY/..
+       else
+               GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||
+               error "Cannot run git from $GIT_TEST_INSTALLED."
+               PATH=$GIT_TEST_INSTALLED:$TEST_DIRECTORY/..:$PATH
+               GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
+       fi
  else
        make_symlink () {
                test -h "$2" &&
@@@ -616,8 -621,7 +624,8 @@@ test_create_repo "$test
  # in subprocesses like git equals our $PWD (for pathname comparisons).
  cd -P "$test" || exit 1
  
 -this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
 +this_test=${0##*/}
 +this_test=${this_test%%-*}
  for skp in $GIT_SKIP_TESTS
  do
        to_skip=