summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2018-03-04 00:26:47 -0500
committerJunio C Hamano <gitster@pobox.com>2018-03-06 14:35:42 -0800
commit7f19def0fc254829839495f7fb44a7d99b161d3d (patch)
tree16af5374bf916960456ab7b3c2a84448f6c3e567
parentee6763af0a3b97225803c6c908a29de40336cf38 (diff)
downloadgit-nd/worktree-move.tar.gz
t2028: fix minor error and issues in newly-added "worktree move" testsnd/worktree-move
Recently-added "git worktree move" tests include a minor error and a few small issues. Specifically: * checking non-existence of wrong file ("source" instead of "destination") * unneeded redirect (">empty") * unused variable ("toplevel") * restoring a worktree location by means of a separate test somewhat distant from the test which moved it rather than using test_when_finished() to restore it in a self-contained fashion * having git command on the left-hand-side of a pipe ("git foo | grep") Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Acked-by: Duy Nguyen <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t2028-worktree-move.sh19
1 files changed, 9 insertions, 10 deletions
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh
index 082368d8c6..5d5b3632ba 100755
--- a/t/t2028-worktree-move.sh
+++ b/t/t2028-worktree-move.sh
@@ -7,7 +7,8 @@ test_description='test git worktree move, remove, lock and unlock'
test_expect_success 'setup' '
test_commit init &&
git worktree add source &&
- git worktree list --porcelain | grep "^worktree" >actual &&
+ git worktree list --porcelain >out &&
+ grep "^worktree" out >actual &&
cat <<-EOF >expected &&
worktree $(pwd)
worktree $(pwd)/source
@@ -74,8 +75,9 @@ test_expect_success 'move worktree' '
toplevel="$(pwd)" &&
git worktree move source destination &&
test_path_is_missing source &&
- git worktree list --porcelain | grep "^worktree.*/destination" &&
- ! git worktree list --porcelain | grep "^worktree.*/source" >empty &&
+ git worktree list --porcelain >out &&
+ grep "^worktree.*/destination" out &&
+ ! grep "^worktree.*/source" out &&
git -C destination log --format=%s >actual2 &&
echo init >expected2 &&
test_cmp expected2 actual2
@@ -86,11 +88,12 @@ test_expect_success 'move main worktree' '
'
test_expect_success 'move worktree to another dir' '
- toplevel="$(pwd)" &&
mkdir some-dir &&
git worktree move destination some-dir &&
- test_path_is_missing source &&
- git worktree list --porcelain | grep "^worktree.*/some-dir/destination" &&
+ test_when_finished "git worktree move some-dir/destination destination" &&
+ test_path_is_missing destination &&
+ git worktree list --porcelain >out &&
+ grep "^worktree.*/some-dir/destination" out &&
git -C some-dir/destination log --format=%s >actual2 &&
echo init >expected2 &&
test_cmp expected2 actual2
@@ -100,10 +103,6 @@ test_expect_success 'remove main worktree' '
test_must_fail git worktree remove .
'
-test_expect_success 'move some-dir/destination back' '
- git worktree move some-dir/destination destination
-'
-
test_expect_success 'remove locked worktree' '
git worktree lock destination &&
test_when_finished "git worktree unlock destination" &&