Skip to content

Commit

Permalink
Use test_path_is_* functions in test script
Browse files Browse the repository at this point in the history
Test script to verify the presence/absence of files, paths,
directories,symboliclinks and many other features in mv command
are using

'test -(e|f|s|h|...).

Replace them with helper functions of format

'test_path_is_*'

Signed-off-by: Debra Obondo <debraobondo@gmail.com>

Update t7001-mv.sh

Adding idiomatic expressions for intenally negated (sub) commands

Update t7001-mv.sh

Adding the idiomatic expression for test_path_exists
  • Loading branch information
fobiasic07 committed Oct 28, 2022
1 parent a00b908 commit 4880fdd
Showing 1 changed file with 109 additions and 0 deletions.
109 changes: 109 additions & 0 deletions t/t7001-mv.sh
Expand Up @@ -61,7 +61,15 @@ 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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
test_path_is_file MOVED
================================
! test_path_is_file MOVED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 034c75ddae (Update t7001-mv.sh)
================================
test_path_is_file MOVED
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
'

test_expect_success 'checking -k on non-existing file' '
Expand All @@ -72,22 +80,35 @@ test_expect_success 'checking -k on untracked file' '
>untracked1 &&
git mv -k untracked1 path0 &&
test_path_is_file untracked1 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_is_file path0/untracked1
================================
test_path_is_file path0/untracked1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
'

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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_is_file path0/untracked1 &&
! test_path_is_file path0/untracked2
================================
test_path_is_file path0/untracked1 &&
test_path_is_file path0/untracked2
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
'

test_expect_success 'checking -f on untracked file with existing target' '
>path0/untracked1 &&
test_must_fail git mv -f untracked1 path0 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_is_file .git/index.lock &&
================================
test_path_is_file .git/index.lock &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
test_path_is_file untracked1 &&
test_path_is_file path0/untracked1
'
Expand Down Expand Up @@ -215,7 +236,15 @@ test_expect_success 'absolute pathname' '
git add sub/file &&
git mv sub "$(pwd)/in" &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_is_dir sub &&
================================
test_path_is_dir sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_is_dir sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test_path_is_dir in &&
git ls-files --error-unmatch in/file
)
Expand All @@ -235,7 +264,15 @@ test_expect_success 'absolute pathname outside should fail' '
test_must_fail git mv sub "$out/out" &&
test_path_is_dir sub &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_is_dir ../in &&
================================
test_path_is_dir ../in &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_is_dir ../in &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
git ls-files --error-unmatch sub/file
)
'
Expand Down Expand Up @@ -295,7 +332,15 @@ 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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists moved &&
================================
test_path_exists moved &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists moved &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test_path_is_file symlink &&
test "$(cat symlink)" = 1 &&
git update-index --refresh &&
Expand All @@ -312,7 +357,15 @@ 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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists symlink &&
================================
test_path_exists symlink &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists symlink &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
git update-index --refresh &&
git diff-files --quiet
'
Expand Down Expand Up @@ -352,7 +405,15 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm
) &&
mkdir mod &&
git mv sub mod/sub &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists sub &&
================================
test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -372,7 +433,15 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu
) &&
mkdir mod &&
git mv sub mod/sub &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists sub &&
================================
test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
echo mod/sub >expected &&
Expand All @@ -389,7 +458,15 @@ 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/ . &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists sub &&
================================
test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
echo mod/sub >expected &&
Expand All @@ -408,7 +485,15 @@ 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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists sub &&
================================
test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -429,7 +514,15 @@ 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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists sub &&
================================
test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 33620b81d5 (Update t7001-mv.sh)
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -447,7 +540,15 @@ 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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_exists sub &&
================================
test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_exists sub &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" &&
git -C mod/sub status &&
git update-index --refresh &&
Expand All @@ -474,7 +575,15 @@ 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 &&
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HEAD
! test_path_is_file sub/.git &&
================================
test_path_is_file sub/.git &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6653ffb489 (Use test_path_is_* functions in test script)
================================
! test_path_is_file sub/.git &&
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> a00b90851e (Update t7001-mv.sh)
test_path_is_file sub2/.git &&
git submodule update &&
test_path_is_file sub/.git &&
Expand Down

0 comments on commit 4880fdd

Please sign in to comment.