Skip to content

Commit

Permalink
t7001-mv.sh: modernizing test script
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fobiasic07 committed Nov 3, 2022
1 parent b977c4a commit 30a7dfa
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions t/t7001-mv.sh
Expand Up @@ -61,7 +61,7 @@ test_expect_success 'checking the commit' '
test_expect_success 'mv --dry-run does not move file' '
git mv -n path0/COPYING MOVED &&
test_path_is_file path0/COPYING &&
! test_path_is_file MOVED
test_path_is_missing MOVED
'

test_expect_success 'checking -k on non-existing file' '
Expand All @@ -72,22 +72,22 @@ test_expect_success 'checking -k on untracked file' '
>untracked1 &&
git mv -k untracked1 path0 &&
test_path_is_file untracked1 &&
! test_path_is_file path0/untracked1
test_path_is_missing path0/untracked1
'

test_expect_success 'checking -k on multiple untracked files' '
>untracked2 &&
git mv -k untracked1 untracked2 path0 &&
test_path_is_file untracked1 &&
test_path_is_file untracked2 &&
! test_path_is_file path0/untracked1 &&
! test_path_is_file path0/untracked2
test_path_is_missing path0/untracked1 &&
test_path_is_missing path0/untracked2
'

test_expect_success 'checking -f on untracked file with existing target' '
>path0/untracked1 &&
test_must_fail git mv -f untracked1 path0 &&
! test_path_is_file .git/index.lock &&
test_path_is_missing .git/index.lock &&
test_path_is_file untracked1 &&
test_path_is_file path0/untracked1
'
Expand Down Expand Up @@ -215,7 +215,7 @@ test_expect_success 'absolute pathname' '
git add sub/file &&
git mv sub "$(pwd)/in" &&
! test_path_is_dir sub &&
test_path_is_missing sub &&
test_path_is_dir in &&
git ls-files --error-unmatch in/file
)
Expand All @@ -235,7 +235,7 @@ test_expect_success 'absolute pathname outside should fail' '
test_must_fail git mv sub "$out/out" &&
test_path_is_dir sub &&
! test_path_is_dir ../in &&
test_path_is_missing ../in &&
git ls-files --error-unmatch sub/file
)
'
Expand Down Expand Up @@ -295,7 +295,7 @@ test_expect_success 'git mv should overwrite symlink to a file' '
git add moved &&
test_must_fail git mv moved symlink &&
git mv -f moved symlink &&
! test_path_exists moved &&
test_path_is_missing moved &&
test_path_is_file symlink &&
test "$(cat symlink)" = 1 &&
git update-index --refresh &&
Expand All @@ -312,7 +312,7 @@ test_expect_success 'git mv should overwrite file with a symlink' '
git add moved &&
test_must_fail git mv symlink moved &&
git mv -f symlink moved &&
! test_path_exists symlink &&
test_path_is_missing symlink &&
git update-index --refresh &&
git diff-files --quiet
'
Expand Down Expand Up @@ -352,7 +352,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm
) &&
mkdir mod &&
git mv sub mod/sub &&
! test_path_exists sub &&
test_path_is_missing sub &&
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -372,7 +372,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu
) &&
mkdir mod &&
git mv sub mod/sub &&
! test_path_exists sub &&
test_path_is_missing sub &&
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
echo mod/sub >expected &&
Expand All @@ -389,7 +389,7 @@ test_expect_success 'git mv moves a submodule with gitfile' '
entry="$(git ls-files --stage sub | cut -f 1)" &&
mkdir mod &&
git -C mod mv ../sub/ . &&
! test_path_exists sub &&
test_path_is_missing sub &&
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
echo mod/sub >expected &&
Expand All @@ -408,7 +408,7 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' '
mkdir mod &&
git mv sub mod/sub 2>actual.err &&
test_must_be_empty actual.err &&
! test_path_exists sub &&
test_path_is_missing sub &&
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -429,7 +429,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta
git add .gitmodules &&
git mv sub mod/sub 2>actual.err &&
test_must_be_empty actual.err &&
! test_path_exists sub &&
test_path_is_missing sub &&
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -447,7 +447,7 @@ test_expect_success 'mv issues a warning when section is not found in .gitmodule
mkdir mod &&
git mv sub mod/sub 2>actual.err &&
test_cmp expect.err actual.err &&
! test_path_exists sub &&
test_path_is_missing sub &&
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -474,7 +474,7 @@ test_expect_success 'checking out a commit before submodule moved needs manual u
git status -s sub2 >actual &&
echo "?? sub2/" >expected &&
test_cmp expected actual &&
! test_path_is_file sub/.git &&
test_path_is_missing sub/.git &&
test_path_is_file sub2/.git &&
git submodule update &&
test_path_is_file sub/.git &&
Expand Down

0 comments on commit 30a7dfa

Please sign in to comment.