From: Junio C Hamano <gitster@pobox.com>
To: "SZEDER Gábor" <szeder.dev@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] t7800-difftool: don't accidentally match tmp dirs
Date: Sat, 09 Jan 2021 13:40:09 -0800 [thread overview]
Message-ID: <xmqqft39g56u.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20210109170513.31084-1-szeder.dev@gmail.com> ("SZEDER Gábor"'s message of "Sat, 9 Jan 2021 18:05:13 +0100")
SZEDER Gábor <szeder.dev@gmail.com> writes:
> In a bunch of test cases in 't7800-difftool.sh' we 'grep' for specific
> filenames in 'git difftool's output, and those test cases are prone to
> occasional failures because those filenames might be part of the name
> of difftool's temporary directory as well, e.g.:
>
> +git difftool --dir-diff --no-symlinks --extcmd ls v1
> +grep sub output
> +test_line_count = 2 sub-output
> test_line_count: line count for sub-output != 2
> /tmp/git-difftool.Ssubfq/left/:
> sub
> /tmp/git-difftool.Ssubfq/right/:
> sub
> error: last command exited with $?=1
> not ok 50 - difftool --dir-diff v1 from subdirectory --no-symlinks
>
> Fix this by tightening the 'grep' patterns looking for those
> interesting filenames to match only lines where a filename stands on
> its own.
OK. I thought that your previous "we know not just we want to see
sub and file anywhere in the output, but we want them to appear in
this order" attempt was nicer, especially when dealing with the
directory diff output. That was why I suggested to "normalize" the
lines that report the directory path with a sed script, instead of
removing them with "grep -v", and change the condition to tell if a
line is a directory from "^/" to "/:$".
But the approach taken with this round is much simpler. When we
only care about 'sub' and 'file' in the output, for example, we used
to just grep for these strings, allowing substring matches. Now we
make sure the lines we consider matches contain these tokens we want
to see and nothing else. It focuses on only fixing the bug, without
attempting to "improve" the tests while at it. And it is certainly
simpler to explain the change between the version before this patch
and the version with this patch.
Thanks.
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
> t/t7800-difftool.sh | 38 +++++++++++++++++++-------------------
> 1 file changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
> index a578b35761..32291fb67b 100755
> --- a/t/t7800-difftool.sh
> +++ b/t/t7800-difftool.sh
> @@ -440,20 +440,20 @@ run_dir_diff_test () {
>
> run_dir_diff_test 'difftool -d' '
> git difftool -d $symlinks --extcmd ls branch >output &&
> - grep sub output &&
> - grep file output
> + grep "^sub$" output &&
> + grep "^file$" output
> '
>
> run_dir_diff_test 'difftool --dir-diff' '
> git difftool --dir-diff $symlinks --extcmd ls branch >output &&
> - grep sub output &&
> - grep file output
> + grep "^sub$" output &&
> + grep "^file$" output
> '
>
> run_dir_diff_test 'difftool --dir-diff ignores --prompt' '
> git difftool --dir-diff $symlinks --prompt --extcmd ls branch >output &&
> - grep sub output &&
> - grep file output
> + grep "^sub$" output &&
> + grep "^file$" output
> '
>
> run_dir_diff_test 'difftool --dir-diff branch from subdirectory' '
> @@ -462,11 +462,11 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory' '
> git difftool --dir-diff $symlinks --extcmd ls branch >output &&
> # "sub" must only exist in "right"
> # "file" and "file2" must be listed in both "left" and "right"
> - grep sub output >sub-output &&
> + grep "^sub$" output >sub-output &&
> test_line_count = 1 sub-output &&
> - grep file"$" output >file-output &&
> + grep "^file$" output >file-output &&
> test_line_count = 2 file-output &&
> - grep file2 output >file2-output &&
> + grep "^file2$" output >file2-output &&
> test_line_count = 2 file2-output
> )
> '
> @@ -477,11 +477,11 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory' '
> git difftool --dir-diff $symlinks --extcmd ls v1 >output &&
> # "sub" and "file" exist in both v1 and HEAD.
> # "file2" is unchanged.
> - grep sub output >sub-output &&
> + grep "^sub$" output >sub-output &&
> test_line_count = 2 sub-output &&
> - grep file output >file-output &&
> + grep "^file$" output >file-output &&
> test_line_count = 2 file-output &&
> - ! grep file2 output
> + ! grep "^file2$" output
> )
> '
>
> @@ -491,9 +491,9 @@ run_dir_diff_test 'difftool --dir-diff branch from subdirectory w/ pathspec' '
> git difftool --dir-diff $symlinks --extcmd ls branch -- .>output &&
> # "sub" only exists in "right"
> # "file" and "file2" must not be listed
> - grep sub output >sub-output &&
> + grep "^sub$" output >sub-output &&
> test_line_count = 1 sub-output &&
> - ! grep file output
> + ! grep "^file$" output
> )
> '
>
> @@ -503,9 +503,9 @@ run_dir_diff_test 'difftool --dir-diff v1 from subdirectory w/ pathspec' '
> git difftool --dir-diff $symlinks --extcmd ls v1 -- .>output &&
> # "sub" exists in v1 and HEAD
> # "file" is filtered out by the pathspec
> - grep sub output >sub-output &&
> + grep "^sub$" output >sub-output &&
> test_line_count = 2 sub-output &&
> - ! grep file output
> + ! grep "^file$" output
> )
> '
>
> @@ -518,8 +518,8 @@ run_dir_diff_test 'difftool --dir-diff from subdirectory with GIT_DIR set' '
> cd sub &&
> git difftool --dir-diff $symlinks --extcmd ls \
> branch -- sub >output &&
> - grep sub output &&
> - ! grep file output
> + grep "^sub$" output &&
> + ! grep "^file$" output
> )
> '
>
> @@ -527,7 +527,7 @@ run_dir_diff_test 'difftool --dir-diff when worktree file is missing' '
> test_when_finished git reset --hard &&
> rm file2 &&
> git difftool --dir-diff $symlinks --extcmd ls branch master >output &&
> - grep file2 output
> + grep "^file2$" output
> '
>
> run_dir_diff_test 'difftool --dir-diff with unmerged files' '
prev parent reply other threads:[~2021-01-09 21:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-24 9:24 [PATCH] t7800-difftool: don't accidentally match tmp dirs SZEDER Gábor
2021-01-07 6:24 ` Junio C Hamano
2021-01-08 9:20 ` SZEDER Gábor
2021-01-08 15:23 ` Johannes Schindelin
2021-01-08 20:10 ` Junio C Hamano
2021-01-09 17:05 ` [PATCH v2] " SZEDER Gábor
2021-01-09 21:40 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqft39g56u.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=szeder.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).