* [PATCH] t2028: tighten grep expression to make "move worktree" test more robust
@ 2018-04-03  9:25 Eric Sunshine
  2018-04-03 15:21 ` Duy Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sunshine @ 2018-04-03  9:25 UTC (permalink / raw)
  To: git; +Cc: Jens Krüger, Eric Sunshine
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>
---
t2028 in 2.17.0 can be fooled into failing depending upon the path of
the test's trash directory. The problem is with the test being too
loose, not with Git itself. Problem report and diagnosis here[1].
[1]: https://public-inbox.org/git/26a00c2b-c588-68d5-7085-22310c20e6df@frm2.tum.de/T/#m994cdb29f141656b0ab48dd0d152432c7e86fc20
 t/t2028-worktree-move.sh | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/t/t2028-worktree-move.sh b/t/t2028-worktree-move.sh
index 5d5b3632ba..5f7d45b7b7 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
-- 
2.17.0.484.g0c8726318c
^ permalink raw reply related	[flat|nested] 2+ messages in thread
* Re: [PATCH] t2028: tighten grep expression to make "move worktree" test more robust
  2018-04-03  9:25 [PATCH] t2028: tighten grep expression to make "move worktree" test more robust Eric Sunshine
@ 2018-04-03 15:21 ` Duy Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Duy Nguyen @ 2018-04-03 15:21 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git Mailing List, Jens Krüger
On Tue, Apr 3, 2018 at 11:25 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 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>
> ---
>
> t2028 in 2.17.0 can be fooled into failing depending upon the path of
> the test's trash directory. The problem is with the test being too
> loose, not with Git itself. Problem report and diagnosis here[1].
>
> [1]: https://public-inbox.org/git/26a00c2b-c588-68d5-7085-22310c20e6df@frm2.tum.de/T/#m994cdb29f141656b0ab48dd0d152432c7e86fc20
Thanks both. It was great to scroll to the latest mails and saw that I
didn't have to do anything else :)
-- 
Duy
^ permalink raw reply	[flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-03 15:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03  9:25 [PATCH] t2028: tighten grep expression to make "move worktree" test more robust Eric Sunshine
2018-04-03 15:21 ` Duy Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).