Merge branch 'js/windows-tests'
authorJunio C Hamano <gitster@pobox.com>
Tue, 24 Mar 2009 21:42:50 +0000 (14:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Mar 2009 21:42:50 +0000 (14:42 -0700)
* js/windows-tests:
t0060: fix whitespace in "wc -c" invocation
t5503: GIT_DEBUG_SEND_PACK is not supported on MinGW
t7004: Use prerequisite tags to skip tests that need gpg
Use prerequisites to skip tests that need unzip
t3700: Skip a test with backslashes in pathspec
Skip tests that require a filesystem that obeys POSIX permissions
t0060: Fix tests on Windows
Use prerequisite tags to skip tests that depend on symbolic links
t9100, t9129: Use prerequisite tags for UTF-8 tests
t5302: Use prerequisite tags to skip 64-bit offset tests
Skip tests that fail if the executable bit is not handled by the filesystem
t3600: Use test prerequisite tags
test-lib: Infrastructure to test and check for prerequisites
t0050: Check whether git init detected symbolic link support correctly
Tests on Windows: $(pwd) must return Windows-style paths
test-lib: Work around missing sum on Windows
test-lib: Work around incompatible sort and find on Windows

Conflicts:
t/t3000-ls-files-others.sh

1  2 
t/t1300-repo-config.sh
t/t3000-ls-files-others.sh
t/test-lib.sh
diff --combined t/t1300-repo-config.sh
index 9c81e041b9f688ebeffacce06b3ff94e153bb9b2,64663e1886f7b5670c03f9add1b955c4b15a4830..43ea283242c4afc25e53d4a8c894140793649717
@@@ -118,14 -118,7 +118,14 @@@ EO
  
  test_expect_success 'multiple unset is correct' 'cmp .git/config expect'
  
 -mv .git/config2 .git/config
 +cp .git/config2 .git/config
 +
 +test_expect_success '--replace-all missing value' '
 +      test_must_fail git config --replace-all beta.haha &&
 +      test_cmp .git/config2 .git/config
 +'
 +
 +rm .git/config2
  
  test_expect_success '--replace-all' \
        'git config --replace-all beta.haha gamma'
@@@ -733,7 -726,7 +733,7 @@@ echo >>resul
  
  test_expect_success '--null --get-regexp' 'cmp result expect'
  
- test_expect_success 'symlinked configuration' '
+ test_expect_success SYMLINKS 'symlinked configuration' '
  
        ln -s notyet myconfig &&
        GIT_CONFIG=myconfig git config test.frotz nitfol &&
index 379d963ceafd64fa989fdfd1bba4e420e479bbf8,b7e03063161337248df90c6e88d2c06bf2377bd9..86291e839942e6842bf1d2b40f2d7f7c1d8d4a9f
@@@ -13,13 -13,17 +13,18 @@@ filesystem
      path2/file2 - a file in a directory
      path3-junk  - a file to confuse things
      path3/file3 - a file in a directory
 +    path4       - an empty directory
  '
  . ./test-lib.sh
  
  date >path0
- ln -s xyzzy path1
+ if test_have_prereq SYMLINKS
+ then
+       ln -s xyzzy path1
+ else
+       date > path1
+ fi
 -mkdir path2 path3
 +mkdir path2 path3 path4
  date >path2/file2
  date >path2-junk
  date >path3/file3
@@@ -29,7 -33,6 +34,7 @@@ git update-index --add path3-junk path3
  cat >expected1 <<EOF
  expected1
  expected2
 +expected3
  output
  path0
  path1
@@@ -37,8 -40,6 +42,8 @@@ path2-jun
  path2/file2
  EOF
  sed -e 's|path2/file2|path2/|' <expected1 >expected2
 +cat <expected2 >expected3
 +echo path4/ >>expected2
  
  test_expect_success \
      'git ls-files --others to show output.' \
@@@ -57,12 -58,4 +62,12 @@@ test_expect_success 
      'git ls-files --others --directory should not get confused.' \
      'test_cmp expected2 output'
  
 +test_expect_success \
 +    'git ls-files --others --directory --no-empty-directory to show output.' \
 +    'git ls-files --others --directory --no-empty-directory >output'
 +
 +test_expect_success \
 +    '--no-empty-directory hides empty directory' \
 +    'test_cmp expected3 output'
 +
  test_done
diff --combined t/test-lib.sh
index 7ff75644c056f8fc9ea3017ca369e6f58161f4e5,b4b626e83774519fc4560239231756ca22df43fe..8de5ee1b580b3f1354428f44c3389239ce0b0894
@@@ -247,6 -247,31 +247,31 @@@ test_chmod () 
        git update-index --add "--chmod=$@"
  }
  
+ # Use test_set_prereq to tell that a particular prerequisite is available.
+ # The prerequisite can later be checked for in two ways:
+ #
+ # - Explicitly using test_have_prereq.
+ #
+ # - Implicitly by specifying the prerequisite tag in the calls to
+ #   test_expect_{success,failure,code}.
+ #
+ # The single parameter is the prerequisite tag (a simple word, in all
+ # capital letters by convention).
+ test_set_prereq () {
+       satisfied="$satisfied$1 "
+ }
+ satisfied=" "
+ test_have_prereq () {
+       case $satisfied in
+       *" $1 "*)
+               : yes, have it ;;
+       *)
+               ! : nope ;;
+       esac
+ }
  # You are not expected to call test_ok_ and test_failure_ directly, use
  # the text_expect_* functions instead.
  
@@@ -293,6 -318,11 +318,11 @@@ test_skip () 
                        to_skip=t
                esac
        done
+       if test -z "$to_skip" && test -n "$prereq" &&
+          ! test_have_prereq "$prereq"
+       then
+               to_skip=t
+       fi
        case "$to_skip" in
        t)
                say_color skip >&3 "skipping test: $@"
  }
  
  test_expect_failure () {
+       test "$#" = 3 && { prereq=$1; shift; } || prereq=
        test "$#" = 2 ||
-       error "bug in the test script: not 2 parameters to test-expect-failure"
+       error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
        if ! test_skip "$@"
        then
                say >&3 "checking known breakage: $2"
  }
  
  test_expect_success () {
+       test "$#" = 3 && { prereq=$1; shift; } || prereq=
        test "$#" = 2 ||
-       error "bug in the test script: not 2 parameters to test-expect-success"
+       error "bug in the test script: not 2 or 3 parameters to test-expect-success"
        if ! test_skip "$@"
        then
                say >&3 "expecting success: $2"
  }
  
  test_expect_code () {
+       test "$#" = 4 && { prereq=$1; shift; } || prereq=
        test "$#" = 3 ||
-       error "bug in the test script: not 3 parameters to test-expect-code"
+       error "bug in the test script: not 3 or 4 parameters to test-expect-code"
        if ! test_skip "$@"
        then
                say >&3 "expecting exit code $1: $3"
  # Usage: test_external description command arguments...
  # Example: test_external 'Perl API' perl ../path/to/test.pl
  test_external () {
-       test "$#" -eq 3 ||
-       error >&5 "bug in the test script: not 3 parameters to test_external"
+       test "$#" = 4 && { prereq=$1; shift; } || prereq=
+       test "$#" = 3 ||
+       error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
        descr="$1"
        shift
        if ! test_skip "$descr" "$@"
@@@ -457,7 -491,7 +491,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,16 -551,8 +551,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" &&
                test_done
        esac
  done
+ # Fix some commands on Windows
+ case $(uname -s) in
+ *MINGW*)
+       # Windows has its own (incompatible) sort and find
+       sort () {
+               /usr/bin/sort "$@"
+       }
+       find () {
+               /usr/bin/find "$@"
+       }
+       sum () {
+               md5sum "$@"
+       }
+       # git sees Windows-style pwd
+       pwd () {
+               builtin pwd -W
+       }
+       # no POSIX permissions
+       # backslashes in pathspec are converted to '/'
+       ;;
+ *)
+       test_set_prereq POSIXPERM
+       test_set_prereq BSLASHPSPEC
+       ;;
+ esac
+ # test whether the filesystem supports symbolic links
+ ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
+ rm -f y