Merge branch 'rj/tap-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Sep 2012 18:53:45 +0000 (11:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Sep 2012 18:53:45 +0000 (11:53 -0700)
* rj/tap-fix:
test-lib.sh: Suppress the "passed all ..." message if no tests run
test-lib.sh: Add check for invalid use of 'skip_all' facility
test-lib.sh: Fix some shell coding style violations
t4016-*.sh: Skip all tests rather than each test
t3902-*.sh: Skip all tests rather than each test
t3300-*.sh: Fix a TAP parse error

1  2 
t/test-lib.sh
diff --combined t/test-lib.sh
index 78c428619e99ea0225f61a1fe257e444d464ad0b,600ed835ee4da183c61101af3628925061b94823..f8e3733ea06478d4eccb483ef6c2e6b196bde02f
@@@ -100,12 -100,12 +100,12 @@@ unset CDPAT
  unset GREP_OPTIONS
  
  case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
      1|2|true)
-               echo "* warning: Some tests will not work if GIT_TRACE" \
-                       "is set as to trace on STDERR ! *"
-               echo "* warning: Please set GIT_TRACE to something" \
-                       "other than 1, 2 or true ! *"
-               ;;
+ 1|2|true)
+       echo "* warning: Some tests will not work if GIT_TRACE" \
+               "is set as to trace on STDERR ! *"
+       echo "* warning: Please set GIT_TRACE to something" \
+               "other than 1, 2 or true ! *"
+       ;;
  esac
  
  # Convenience
        esac
  done
  
- if test -n "$color"; then
+ if test -n "$color"
+ then
        say_color () {
                (
                TERM=$ORIGINAL_TERM
                export TERM
                case "$1" in
-                       error) tput bold; tput setaf 1;; # bold red
-                       skip)  tput bold; tput setaf 2;; # bold green
-                       pass)  tput setaf 2;;            # green
-                       info)  tput setaf 3;;            # brown
-                       *) test -n "$quiet" && return;;
+               error)
+                       tput bold; tput setaf 1;; # bold red
+               skip)
+                       tput bold; tput setaf 2;; # bold green
+               pass)
+                       tput setaf 2;;            # green
+               info)
+                       tput setaf 3;;            # brown
+               *)
+                       test -n "$quiet" && return;;
                esac
                shift
                printf "%s" "$*"
@@@ -298,7 -304,8 +304,8 @@@ test_run_ () 
        then
                test_eval_ "$test_cleanup"
        fi
-       if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then
+       if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
+       then
                echo ""
        fi
        return "$eval_ret"
@@@ -346,7 -353,8 +353,8 @@@ test_at_end_hook_ () 
  test_done () {
        GIT_EXIT_OK=t
  
-       if test -z "$HARNESS_ACTIVE"; then
+       if test -z "$HARNESS_ACTIVE"
+       then
                test_results_dir="$TEST_OUTPUT_DIRECTORY/test-results"
                mkdir -p "$test_results_dir"
                test_results_path="$test_results_dir/${0%.sh}-$$.counts"
        case "$test_failure" in
        0)
                # Maybe print SKIP message
+               if test -n "$skip_all" && test $test_count -gt 0
+               then
+                       error "Can't use skip_all after running some tests"
+               fi
                [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all"
  
-               if test $test_external_has_tap -eq 0; then
-                       say_color pass "# passed all $msg"
+               if test $test_external_has_tap -eq 0
+               then
+                       if test $test_count -gt 0
+                       then
+                               say_color pass "# passed all $msg"
+                       fi
                        say "1..$test_count$skip_all"
                fi
  
                exit 0 ;;
  
        *)
-               if test $test_external_has_tap -eq 0; then
+               if test $test_external_has_tap -eq 0
+               then
                        say_color error "# failed $test_failure among $msg"
                        say "1..$test_count"
                fi
@@@ -471,22 -488,26 +488,26 @@@ the
        PATH=$GIT_VALGRIND/bin:$PATH
        GIT_EXEC_PATH=$GIT_VALGRIND/bin
        export GIT_VALGRIND
- elif test -n "$GIT_TEST_INSTALLED" ; then
+ elif test -n "$GIT_TEST_INSTALLED"
+ then
        GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path)  ||
        error "Cannot run git from $GIT_TEST_INSTALLED."
        PATH=$GIT_TEST_INSTALLED:$GIT_BUILD_DIR:$PATH
        GIT_EXEC_PATH=${GIT_TEST_EXEC_PATH:-$GIT_EXEC_PATH}
  else # normal case, use ../bin-wrappers only unless $with_dashes:
        git_bin_dir="$GIT_BUILD_DIR/bin-wrappers"
-       if ! test -x "$git_bin_dir/git" ; then
-               if test -z "$with_dashes" ; then
+       if ! test -x "$git_bin_dir/git"
+       then
+               if test -z "$with_dashes"
+               then
                        say "$git_bin_dir/git is not executable; using GIT_EXEC_PATH"
                fi
                with_dashes=t
        fi
        PATH="$git_bin_dir:$PATH"
        GIT_EXEC_PATH=$GIT_BUILD_DIR
-       if test -n "$with_dashes" ; then
+       if test -n "$with_dashes"
+       then
                PATH="$GIT_BUILD_DIR:$PATH"
        fi
  fi
@@@ -521,7 -542,8 +542,8 @@@ the
        }
  fi
  
- if ! test -x "$GIT_BUILD_DIR"/test-chmtime; then
+ if ! test -x "$GIT_BUILD_DIR"/test-chmtime
+ then
        echo >&2 'You need to build test-chmtime:'
        echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
        exit 1
@@@ -544,7 -566,8 +566,8 @@@ rm -fr "$test" || 
  HOME="$TRASH_DIRECTORY"
  export HOME
  
- if test -z "$TEST_NO_CREATE_REPO"; then
+ if test -z "$TEST_NO_CREATE_REPO"
+ then
        test_create_repo "$test"
  else
        mkdir -p "$test"
@@@ -659,29 -682,9 +682,29 @@@ test_i18ngrep () 
        fi
  }
  
 -# 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
 +test_lazy_prereq SYMLINKS '
 +      # test whether the filesystem supports symbolic links
 +      ln -s x y && test -h y
 +'
 +
 +test_lazy_prereq CASE_INSENSITIVE_FS '
 +      echo good >CamelCase &&
 +      echo bad >camelcase &&
 +      test "$(cat CamelCase)" != good
 +'
 +
 +test_lazy_prereq UTF8_NFD_TO_NFC '
 +      # check whether FS converts nfd unicode to nfc
 +      auml=$(printf "\303\244")
 +      aumlcdiar=$(printf "\141\314\210")
 +      >"$auml" &&
 +      case "$(echo *)" in
 +      "$aumlcdiar")
 +              true ;;
 +      *)
 +              false ;;
 +      esac
 +'
  
  # When the tests are run as root, permission tests will report that
  # things are writable when they shouldn't be.