]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'cg/t3903-modernize'
authorJunio C Hamano <gitster@pobox.com>
Mon, 7 Mar 2022 05:25:30 +0000 (21:25 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Mar 2022 05:25:30 +0000 (21:25 -0800)
Test modernization.

* cg/t3903-modernize:
  tests: make the code more readable
  tests: allow testing if a path is truly a file or a directory
  t/t3903-stash.sh: replace test [-d|-f] with test_path_is_*

1  2 
t/t3903-stash.sh

diff --combined t/t3903-stash.sh
index b149e2af44185d5a78ff7eff1e2c0efb67f35f4d,185518152017a57599f1c15280ccd14ba27297a7..d5ecee4fcc0911ea70312f1ada30d64a4c9776cd
@@@ -390,10 -390,11 +390,11 @@@ test_expect_success SYMLINKS 'stash fil
        rm file &&
        ln -s file2 file &&
        git stash save "file to symlink" &&
-       test -f file &&
+       test_path_is_file_not_symlink file &&
        test bar = "$(cat file)" &&
        git stash apply &&
-       case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
+       test_path_is_symlink file &&
+       test "$(test_readlink file)" = file2
  '
  
  test_expect_success SYMLINKS 'stash file to symlink (stage rm)' '
        git rm file &&
        ln -s file2 file &&
        git stash save "file to symlink (stage rm)" &&
-       test -f file &&
+       test_path_is_file_not_symlink file &&
        test bar = "$(cat file)" &&
        git stash apply &&
-       case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
+       test_path_is_symlink file &&
+       test "$(test_readlink file)" = file2
  '
  
  test_expect_success SYMLINKS 'stash file to symlink (full stage)' '
        ln -s file2 file &&
        git add file &&
        git stash save "file to symlink (full stage)" &&
-       test -f file &&
+       test_path_is_file_not_symlink file &&
        test bar = "$(cat file)" &&
        git stash apply &&
-       case "$(ls -l file)" in *" file -> file2") :;; *) false;; esac
+       test_path_is_symlink file &&
+       test "$(test_readlink file)" = file2
  '
  
  # This test creates a commit with a symlink used for the following tests
@@@ -487,7 -490,7 +490,7 @@@ test_expect_failure 'stash directory t
        rm -fr dir &&
        echo bar >dir &&
        git stash save "directory to file" &&
-       test -d dir &&
+       test_path_is_dir dir &&
        test foo = "$(cat dir/file)" &&
        test_must_fail git stash apply &&
        test bar = "$(cat dir)" &&
@@@ -500,10 -503,10 +503,10 @@@ test_expect_failure 'stash file to dire
        mkdir file &&
        echo foo >file/file &&
        git stash save "file to directory" &&
-       test -f file &&
+       test_path_is_file file &&
        test bar = "$(cat file)" &&
        git stash apply &&
-       test -f file/file &&
+       test_path_is_file file/file &&
        test foo = "$(cat file/file)"
  '
  
@@@ -1272,6 -1275,7 +1275,6 @@@ test_expect_success 'stash works when u
        >2 &&
        git add 2 &&
        test_config user.useconfigonly true &&
 -      test_config stash.usebuiltin true &&
        (
                sane_unset GIT_AUTHOR_NAME &&
                sane_unset GIT_AUTHOR_EMAIL &&
@@@ -1322,6 -1326,20 +1325,6 @@@ test_expect_success 'stash handles skip
        git rev-parse --verify refs/stash:A.t
  '
  
 -test_expect_success 'stash -c stash.useBuiltin=false warning ' '
 -      expected="stash.useBuiltin support has been removed" &&
 -
 -      git -c stash.useBuiltin=false stash 2>err &&
 -      test_i18ngrep "$expected" err &&
 -      env GIT_TEST_STASH_USE_BUILTIN=false git stash 2>err &&
 -      test_i18ngrep "$expected" err &&
 -
 -      git -c stash.useBuiltin=true stash 2>err &&
 -      test_must_be_empty err &&
 -      env GIT_TEST_STASH_USE_BUILTIN=true git stash 2>err &&
 -      test_must_be_empty err
 -'
 -
  test_expect_success 'git stash succeeds despite directory/file change' '
        test_create_repo directory_file_switch_v1 &&
        (