summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2018-04-03 09:25:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-05 07:08:33 (GMT)
commitb1801b85a32e21a7e83d165b029b5115ab0f8167 (patch)
tree707b0e2305042a24ec5862e1db4d6a25f217806e /t
parent7f19def0fc254829839495f7fb44a7d99b161d3d (diff)
downloadgit-b1801b85a32e21a7e83d165b029b5115ab0f8167.zip
git-b1801b85a32e21a7e83d165b029b5115ab0f8167.tar.gz
git-b1801b85a32e21a7e83d165b029b5115ab0f8167.tar.bz2
t2028: tighten grep expression to make "move worktree" test more robust
Following a rename of worktree "source" to "destination", the "move worktree" test uses grep to verify that the output of "git worktree list --porcelain" does not contain "source" (and does contain "destination"). Unfortunately, the grep expression is too loose and can match unexpectedly. For example, if component of the test trash directory path matches "source" (e.g. "/home/me/sources/git/t/trash*"), then the test will be fooled into thinking that "source" still exists. Tighten the expression to avoid such accidental matches. While at it, drop an unused variable ("toplevel") from the test and tighten a similarly too-loose expression in a related test. Reported-by: Jens Krüger <Jens.Krueger@frm2.tum.de> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t2028-worktree-move.sh7
1 files changed, 3 insertions, 4 deletions
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh
index 5d5b363..5f7d45b 100755
--- a/t/t2028-worktree-move.sh
+++ b/t/t2028-worktree-move.sh
@@ -72,12 +72,11 @@ test_expect_success 'move locked worktree' '
'
test_expect_success 'move worktree' '
- toplevel="$(pwd)" &&
git worktree move source destination &&
test_path_is_missing source &&
git worktree list --porcelain >out &&
- grep "^worktree.*/destination" out &&
- ! grep "^worktree.*/source" out &&
+ grep "^worktree.*/destination$" out &&
+ ! grep "^worktree.*/source$" out &&
git -C destination log --format=%s >actual2 &&
echo init >expected2 &&
test_cmp expected2 actual2
@@ -93,7 +92,7 @@ test_expect_success 'move worktree to another dir' '
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 &&
+ grep "^worktree.*/some-dir/destination$" out &&
git -C some-dir/destination log --format=%s >actual2 &&
echo init >expected2 &&
test_cmp expected2 actual2