Merge branch 'dt/gc-ignore-old-gc-logs'
authorJunio C Hamano <gitster@pobox.com>
Tue, 16 May 2017 02:51:50 +0000 (11:51 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 16 May 2017 02:51:51 +0000 (11:51 +0900)
Attempt to allow us notice "fishy" situation where we fail to
remove the temporary directory used during the test.

* dt/gc-ignore-old-gc-logs:
test-lib: retire $remove_trash variable
test-lib.sh: do not barf under --debug at the end of the test
test-lib: abort when can't remove trash directory

1  2 
t/test-lib.sh
diff --combined t/test-lib.sh
index 13b5696822d7cd054ed00cd5b4111ab39d3606cb,51b59c69cb3f69635dd55f6ecd0947f5b2809f1a..014136fb06dc689a4a2a2744cedcd0f2fda37d6d
@@@ -342,7 -342,6 +342,7 @@@ f
  
  exec 5>&1
  exec 6<&0
 +exec 7>&2
  if test "$verbose_log" = "t"
  then
        exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3
@@@ -625,9 -624,9 +625,9 @@@ test_run_ () 
                trace=
                # 117 is magic because it is unlikely to match the exit
                # code of other programs
 -              test_eval_ "(exit 117) && $1"
 -              if test "$?" != 117; then
 -                      error "bug in the test script: broken &&-chain: $1"
 +              if test "OK-117" != "$(test_eval_ "(exit 117) && $1${LF}${LF}echo OK-\$?" 3>&1)"
 +              then
 +                      error "bug in the test script: broken &&-chain or run-away HERE-DOC: $1"
                fi
                trace=$trace_tmp
        fi
@@@ -761,10 -760,15 +761,15 @@@ test_done () 
                        say "1..$test_count$skip_all"
                fi
  
-               test -d "$remove_trash" &&
-               cd "$(dirname "$remove_trash")" &&
-               rm -rf "$(basename "$remove_trash")"
+               if test -z "$debug"
+               then
+                       test -d "$TRASH_DIRECTORY" ||
+                       error "Tests passed but trash directory already removed before test cleanup; aborting"
  
+                       cd "$TRASH_DIRECTORY/.." &&
+                       rm -fr "$TRASH_DIRECTORY" ||
+                       error "Tests passed but test cleanup failed; aborting"
+               fi
                test_at_end_hook_
  
                exit 0 ;;
@@@ -919,7 -923,6 +924,6 @@@ case "$TRASH_DIRECTORY" i
  /*) ;; # absolute path is good
   *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
  esac
- test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
  rm -fr "$TRASH_DIRECTORY" || {
        GIT_EXIT_OK=t
        echo >&5 "FATAL: Cannot prepare test area"
@@@ -967,8 -970,7 +971,8 @@@ yes () 
  }
  
  # Fix some commands on Windows
 -case $(uname -s) in
 +uname_s=$(uname -s)
 +case $uname_s in
  *MINGW*)
        # Windows has its own (incompatible) sort and find
        sort () {
@@@ -1143,7 -1145,6 +1147,7 @@@ test_lazy_prereq SANITY 
        return $status
  '
  
 +test FreeBSD != $uname_s || GIT_UNZIP=${GIT_UNZIP:-/usr/local/bin/unzip}
  GIT_UNZIP=${GIT_UNZIP:-unzip}
  test_lazy_prereq UNZIP '
        "$GIT_UNZIP" -v