mirror of
https://github.com/git/git
synced 2024-08-28 20:20:07 +00:00
t7001-mv.sh: modernizing test script using functions
Test script to verify the presence/absence of files, paths, directories, symlinks and other features in 'git mv' command are using the command format: 'test (-e|f|d|h|...)' Replace them with helper functions of format: 'test_path_is_*' Replacing idiomatic helper functions: '! test_path_is_*' with 'test_path_is_missing' This uses values of 'test_path_bar' in place of '! test_path_foo' to bring in the helpful factor of indicating the failure of tests after the mv command has been used, that is, it echoes if the feature/test_path exists. Signed-off-by: Debra Obondo <debraobondo@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
This commit is contained in:
parent
63bba4fdd8
commit
7cccf5b6c9
|
@ -60,8 +60,8 @@ test_expect_success 'checking the commit' '
|
||||||
|
|
||||||
test_expect_success 'mv --dry-run does not move file' '
|
test_expect_success 'mv --dry-run does not move file' '
|
||||||
git mv -n path0/COPYING MOVED &&
|
git mv -n path0/COPYING MOVED &&
|
||||||
test -f path0/COPYING &&
|
test_path_is_file path0/COPYING &&
|
||||||
test ! -f MOVED
|
test_path_is_missing MOVED
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'checking -k on non-existing file' '
|
test_expect_success 'checking -k on non-existing file' '
|
||||||
|
@ -71,25 +71,25 @@ test_expect_success 'checking -k on non-existing file' '
|
||||||
test_expect_success 'checking -k on untracked file' '
|
test_expect_success 'checking -k on untracked file' '
|
||||||
>untracked1 &&
|
>untracked1 &&
|
||||||
git mv -k untracked1 path0 &&
|
git mv -k untracked1 path0 &&
|
||||||
test -f untracked1 &&
|
test_path_is_file untracked1 &&
|
||||||
test ! -f path0/untracked1
|
test_path_is_missing path0/untracked1
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'checking -k on multiple untracked files' '
|
test_expect_success 'checking -k on multiple untracked files' '
|
||||||
>untracked2 &&
|
>untracked2 &&
|
||||||
git mv -k untracked1 untracked2 path0 &&
|
git mv -k untracked1 untracked2 path0 &&
|
||||||
test -f untracked1 &&
|
test_path_is_file untracked1 &&
|
||||||
test -f untracked2 &&
|
test_path_is_file untracked2 &&
|
||||||
test ! -f path0/untracked1 &&
|
test_path_is_missing path0/untracked1 &&
|
||||||
test ! -f path0/untracked2
|
test_path_is_missing path0/untracked2
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'checking -f on untracked file with existing target' '
|
test_expect_success 'checking -f on untracked file with existing target' '
|
||||||
>path0/untracked1 &&
|
>path0/untracked1 &&
|
||||||
test_must_fail git mv -f untracked1 path0 &&
|
test_must_fail git mv -f untracked1 path0 &&
|
||||||
test ! -f .git/index.lock &&
|
test_path_is_missing .git/index.lock &&
|
||||||
test -f untracked1 &&
|
test_path_is_file untracked1 &&
|
||||||
test -f path0/untracked1
|
test_path_is_file path0/untracked1
|
||||||
'
|
'
|
||||||
|
|
||||||
# clean up the mess in case bad things happen
|
# clean up the mess in case bad things happen
|
||||||
|
@ -215,8 +215,8 @@ test_expect_success 'absolute pathname' '
|
||||||
git add sub/file &&
|
git add sub/file &&
|
||||||
|
|
||||||
git mv sub "$(pwd)/in" &&
|
git mv sub "$(pwd)/in" &&
|
||||||
! test -d sub &&
|
test_path_is_missing sub &&
|
||||||
test -d in &&
|
test_path_is_dir in &&
|
||||||
git ls-files --error-unmatch in/file
|
git ls-files --error-unmatch in/file
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
@ -234,8 +234,8 @@ test_expect_success 'absolute pathname outside should fail' '
|
||||||
git add sub/file &&
|
git add sub/file &&
|
||||||
|
|
||||||
test_must_fail git mv sub "$out/out" &&
|
test_must_fail git mv sub "$out/out" &&
|
||||||
test -d sub &&
|
test_path_is_dir sub &&
|
||||||
! test -d ../in &&
|
test_path_is_missing ../in &&
|
||||||
git ls-files --error-unmatch sub/file
|
git ls-files --error-unmatch sub/file
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
@ -295,8 +295,8 @@ test_expect_success 'git mv should overwrite symlink to a file' '
|
||||||
git add moved &&
|
git add moved &&
|
||||||
test_must_fail git mv moved symlink &&
|
test_must_fail git mv moved symlink &&
|
||||||
git mv -f moved symlink &&
|
git mv -f moved symlink &&
|
||||||
! test -e moved &&
|
test_path_is_missing moved &&
|
||||||
test -f symlink &&
|
test_path_is_file symlink &&
|
||||||
test "$(cat symlink)" = 1 &&
|
test "$(cat symlink)" = 1 &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
git diff-files --quiet
|
git diff-files --quiet
|
||||||
|
@ -312,13 +312,13 @@ test_expect_success 'git mv should overwrite file with a symlink' '
|
||||||
git add moved &&
|
git add moved &&
|
||||||
test_must_fail git mv symlink moved &&
|
test_must_fail git mv symlink moved &&
|
||||||
git mv -f symlink moved &&
|
git mv -f symlink moved &&
|
||||||
! test -e symlink &&
|
test_path_is_missing symlink &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
git diff-files --quiet
|
git diff-files --quiet
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success SYMLINKS 'check moved symlink' '
|
test_expect_success SYMLINKS 'check moved symlink' '
|
||||||
test -h moved
|
test_path_is_symlink moved
|
||||||
'
|
'
|
||||||
|
|
||||||
rm -f moved symlink
|
rm -f moved symlink
|
||||||
|
@ -352,7 +352,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm
|
||||||
) &&
|
) &&
|
||||||
mkdir mod &&
|
mkdir mod &&
|
||||||
git mv sub mod/sub &&
|
git mv sub mod/sub &&
|
||||||
! test -e sub &&
|
test_path_is_missing sub &&
|
||||||
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
||||||
git -C mod/sub status &&
|
git -C mod/sub status &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
|
@ -372,7 +372,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu
|
||||||
) &&
|
) &&
|
||||||
mkdir mod &&
|
mkdir mod &&
|
||||||
git mv sub mod/sub &&
|
git mv sub mod/sub &&
|
||||||
! test -e sub &&
|
test_path_is_missing sub &&
|
||||||
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
||||||
git -C mod/sub status &&
|
git -C mod/sub status &&
|
||||||
echo mod/sub >expected &&
|
echo mod/sub >expected &&
|
||||||
|
@ -389,7 +389,7 @@ test_expect_success 'git mv moves a submodule with gitfile' '
|
||||||
entry="$(git ls-files --stage sub | cut -f 1)" &&
|
entry="$(git ls-files --stage sub | cut -f 1)" &&
|
||||||
mkdir mod &&
|
mkdir mod &&
|
||||||
git -C mod mv ../sub/ . &&
|
git -C mod mv ../sub/ . &&
|
||||||
! test -e sub &&
|
test_path_is_missing sub &&
|
||||||
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
||||||
git -C mod/sub status &&
|
git -C mod/sub status &&
|
||||||
echo mod/sub >expected &&
|
echo mod/sub >expected &&
|
||||||
|
@ -408,7 +408,7 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' '
|
||||||
mkdir mod &&
|
mkdir mod &&
|
||||||
git mv sub mod/sub 2>actual.err &&
|
git mv sub mod/sub 2>actual.err &&
|
||||||
test_must_be_empty actual.err &&
|
test_must_be_empty actual.err &&
|
||||||
! test -e sub &&
|
test_path_is_missing sub &&
|
||||||
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
||||||
git -C mod/sub status &&
|
git -C mod/sub status &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
|
@ -423,13 +423,13 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta
|
||||||
entry="$(git ls-files --stage sub | cut -f 1)" &&
|
entry="$(git ls-files --stage sub | cut -f 1)" &&
|
||||||
mkdir mod &&
|
mkdir mod &&
|
||||||
test_must_fail git mv sub mod/sub 2>actual.err &&
|
test_must_fail git mv sub mod/sub 2>actual.err &&
|
||||||
test -s actual.err &&
|
test_file_not_empty actual.err &&
|
||||||
test -e sub &&
|
test_path_exists sub &&
|
||||||
git diff-files --quiet -- sub &&
|
git diff-files --quiet -- sub &&
|
||||||
git add .gitmodules &&
|
git add .gitmodules &&
|
||||||
git mv sub mod/sub 2>actual.err &&
|
git mv sub mod/sub 2>actual.err &&
|
||||||
test_must_be_empty actual.err &&
|
test_must_be_empty actual.err &&
|
||||||
! test -e sub &&
|
test_path_is_missing sub &&
|
||||||
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
||||||
git -C mod/sub status &&
|
git -C mod/sub status &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
|
@ -447,7 +447,7 @@ test_expect_success 'mv issues a warning when section is not found in .gitmodule
|
||||||
mkdir mod &&
|
mkdir mod &&
|
||||||
git mv sub mod/sub 2>actual.err &&
|
git mv sub mod/sub 2>actual.err &&
|
||||||
test_cmp expect.err actual.err &&
|
test_cmp expect.err actual.err &&
|
||||||
! test -e sub &&
|
test_path_is_missing sub &&
|
||||||
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
|
||||||
git -C mod/sub status &&
|
git -C mod/sub status &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
|
@ -460,7 +460,7 @@ test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' '
|
||||||
git submodule update &&
|
git submodule update &&
|
||||||
mkdir mod &&
|
mkdir mod &&
|
||||||
git mv -n sub mod/sub 2>actual.err &&
|
git mv -n sub mod/sub 2>actual.err &&
|
||||||
test -f sub/.git &&
|
test_path_is_file sub/.git &&
|
||||||
git diff-index --exit-code HEAD &&
|
git diff-index --exit-code HEAD &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
git diff-files --quiet -- sub .gitmodules
|
git diff-files --quiet -- sub .gitmodules
|
||||||
|
@ -474,10 +474,10 @@ test_expect_success 'checking out a commit before submodule moved needs manual u
|
||||||
git status -s sub2 >actual &&
|
git status -s sub2 >actual &&
|
||||||
echo "?? sub2/" >expected &&
|
echo "?? sub2/" >expected &&
|
||||||
test_cmp expected actual &&
|
test_cmp expected actual &&
|
||||||
! test -f sub/.git &&
|
test_path_is_missing sub/.git &&
|
||||||
test -f sub2/.git &&
|
test_path_is_file sub2/.git &&
|
||||||
git submodule update &&
|
git submodule update &&
|
||||||
test -f sub/.git &&
|
test_path_is_file sub/.git &&
|
||||||
rm -rf sub2 &&
|
rm -rf sub2 &&
|
||||||
git diff-index --exit-code HEAD &&
|
git diff-index --exit-code HEAD &&
|
||||||
git update-index --refresh &&
|
git update-index --refresh &&
|
||||||
|
|
Loading…
Reference in a new issue