Re: [PATCH 1/2] t7002: set test prerequisite "external-grep" if supported
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Jan 7, 2010, 14:26 UTC
- Message-ID
- <fcaeb9bf1001070626we21617dt1b76af19a3c4a88d@mail.gmail.com>
- In-Reply-To
- <4B45E9E7.1040905@viscovery.net>
On 1/7/10, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 52 quoted lines
> Nguyen Thai Ngoc Duy schrieb: > > > On 1/7/10, Junio C Hamano <gitster@pobox.com> wrote: > >> So by writing the test to check the desired outcome, instead of writing it > >> for the particular implementation of using external grep optimization, you > >> will catch both kinds of breakages. > >> > >> Perhaps something like this (untested, of course)? > >> > >> test_expect_success 'strings in work tree files are not found for skip-wt paths' ' > >> no="no such string in the index" && > >> test_must_fail git grep -e "$no" --cached file && > >> git update-index --skip-worktree file && > >> echo "$no" >file && > >> test_must_fail git grep -e "$no" file && > >> git update-index --no-skip-worktree file && > >> git grep -e "$no" file > >> ' > >> > > > > Very well reasoned. I'd say go for it! > > > > Tested-by: me > > > The test is not quite complete. Not only do you want to test that the > worktree file is not looked at, but that the index version is used: > > > test_expect_success 'for skip-wt paths, strings are found in index, not in > worktree' ' > yes="this string is in the index" && > > no="no such string in the index" && > > echo "$yes" >file && > git update-index file && > echo "$no" >file && > git grep -e "$yes" --cached file && > > test_must_fail git grep -e "$no" --cached file && > git update-index --skip-worktree file && > > git grep -e "$yes" file && > > test_must_fail git grep -e "$no" file && > git update-index --no-skip-worktree file && > > test_must_fail git grep -e "$yes" file && > > git grep -e "$no" file > '
Can we get rid of preparing $yes and do "grep -e foo file" instead? There are lots of foo from setup test. It's not as strict as your test because foo is also in worktree. But we have $no for testing worktree already.
-- Duy