Merge branch 'cg/t3903-modernize'
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_*
This commit is contained in:
@ -390,10 +390,11 @@ test_expect_success SYMLINKS 'stash file to symlink' '
|
|||||||
rm file &&
|
rm file &&
|
||||||
ln -s file2 file &&
|
ln -s file2 file &&
|
||||||
git stash save "file to symlink" &&
|
git stash save "file to symlink" &&
|
||||||
test -f file &&
|
test_path_is_file_not_symlink file &&
|
||||||
test bar = "$(cat file)" &&
|
test bar = "$(cat file)" &&
|
||||||
git stash apply &&
|
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)' '
|
test_expect_success SYMLINKS 'stash file to symlink (stage rm)' '
|
||||||
@ -401,10 +402,11 @@ test_expect_success SYMLINKS 'stash file to symlink (stage rm)' '
|
|||||||
git rm file &&
|
git rm file &&
|
||||||
ln -s file2 file &&
|
ln -s file2 file &&
|
||||||
git stash save "file to symlink (stage rm)" &&
|
git stash save "file to symlink (stage rm)" &&
|
||||||
test -f file &&
|
test_path_is_file_not_symlink file &&
|
||||||
test bar = "$(cat file)" &&
|
test bar = "$(cat file)" &&
|
||||||
git stash apply &&
|
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)' '
|
test_expect_success SYMLINKS 'stash file to symlink (full stage)' '
|
||||||
@ -413,10 +415,11 @@ test_expect_success SYMLINKS 'stash file to symlink (full stage)' '
|
|||||||
ln -s file2 file &&
|
ln -s file2 file &&
|
||||||
git add file &&
|
git add file &&
|
||||||
git stash save "file to symlink (full stage)" &&
|
git stash save "file to symlink (full stage)" &&
|
||||||
test -f file &&
|
test_path_is_file_not_symlink file &&
|
||||||
test bar = "$(cat file)" &&
|
test bar = "$(cat file)" &&
|
||||||
git stash apply &&
|
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
|
# This test creates a commit with a symlink used for the following tests
|
||||||
@ -487,7 +490,7 @@ test_expect_failure 'stash directory to file' '
|
|||||||
rm -fr dir &&
|
rm -fr dir &&
|
||||||
echo bar >dir &&
|
echo bar >dir &&
|
||||||
git stash save "directory to file" &&
|
git stash save "directory to file" &&
|
||||||
test -d dir &&
|
test_path_is_dir dir &&
|
||||||
test foo = "$(cat dir/file)" &&
|
test foo = "$(cat dir/file)" &&
|
||||||
test_must_fail git stash apply &&
|
test_must_fail git stash apply &&
|
||||||
test bar = "$(cat dir)" &&
|
test bar = "$(cat dir)" &&
|
||||||
@ -500,10 +503,10 @@ test_expect_failure 'stash file to directory' '
|
|||||||
mkdir file &&
|
mkdir file &&
|
||||||
echo foo >file/file &&
|
echo foo >file/file &&
|
||||||
git stash save "file to directory" &&
|
git stash save "file to directory" &&
|
||||||
test -f file &&
|
test_path_is_file file &&
|
||||||
test bar = "$(cat file)" &&
|
test bar = "$(cat file)" &&
|
||||||
git stash apply &&
|
git stash apply &&
|
||||||
test -f file/file &&
|
test_path_is_file file/file &&
|
||||||
test foo = "$(cat file/file)"
|
test foo = "$(cat file/file)"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -856,6 +856,16 @@ test_path_is_file () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_path_is_file_not_symlink () {
|
||||||
|
test "$#" -ne 1 && BUG "1 param"
|
||||||
|
test_path_is_file "$1" &&
|
||||||
|
if test -h "$1"
|
||||||
|
then
|
||||||
|
echo "$1 shouldn't be a symbolic link"
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
test_path_is_dir () {
|
test_path_is_dir () {
|
||||||
test "$#" -ne 1 && BUG "1 param"
|
test "$#" -ne 1 && BUG "1 param"
|
||||||
if ! test -d "$1"
|
if ! test -d "$1"
|
||||||
@ -865,6 +875,16 @@ test_path_is_dir () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_path_is_dir_not_symlink () {
|
||||||
|
test "$#" -ne 1 && BUG "1 param"
|
||||||
|
test_path_is_dir "$1" &&
|
||||||
|
if test -h "$1"
|
||||||
|
then
|
||||||
|
echo "$1 shouldn't be a symbolic link"
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
test_path_exists () {
|
test_path_exists () {
|
||||||
test "$#" -ne 1 && BUG "1 param"
|
test "$#" -ne 1 && BUG "1 param"
|
||||||
if ! test -e "$1"
|
if ! test -e "$1"
|
||||||
@ -874,6 +894,15 @@ test_path_exists () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_path_is_symlink () {
|
||||||
|
test "$#" -ne 1 && BUG "1 param"
|
||||||
|
if ! test -h "$1"
|
||||||
|
then
|
||||||
|
echo "Symbolic link $1 doesn't exist"
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Check if the directory exists and is empty as expected, barf otherwise.
|
# Check if the directory exists and is empty as expected, barf otherwise.
|
||||||
test_dir_is_empty () {
|
test_dir_is_empty () {
|
||||||
test "$#" -ne 1 && BUG "1 param"
|
test "$#" -ne 1 && BUG "1 param"
|
||||||
|
Reference in New Issue
Block a user