All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Labnan via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Labnann <khalid.masum.92@gmail.com>
Subject: Re: [PATCH] t3501: use test_path_is_* functions
Date: Thu, 31 Mar 2022 00:11:48 +0200	[thread overview]
Message-ID: <220331.86bkxnt77a.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <pull.1195.git.1648676585765.gitgitgadget@gmail.com>


On Wed, Mar 30 2022, Labnan via GitGitGadget wrote:

> From: Labnann <khalid.masum.92@gmail.com>
>
> Two test -f are present in t3501. They can be replaced with appropriate
> helper function: test_path_is_file
>
> Signed-off-by: Labnann <khalid.masum.92@gmail.com>

Thanks for contributing to git, this is a much needed area of
improvement.

> diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
> index 8617efaaf1e..45492a7ed09 100755
> --- a/t/t3501-revert-cherry-pick.sh
> +++ b/t/t3501-revert-cherry-pick.sh
> @@ -67,7 +67,7 @@ test_expect_success 'cherry-pick after renaming branch' '
>  	git checkout rename2 &&
>  	git cherry-pick added &&
>  	test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
> -	test -f opos &&
> +	test_path_is_file opos &&
>  	grep "Add extra line at the end" opos &&
>  	git reflog -1 | grep cherry-pick

While perfect shouldn't be the enemy of the good, I think it would also
be a very nice use of review bandwidth to end up with some good
end-state here if possible.

I.e. a pre-existing issue here is:

 * We are hiding the exit code of git due to using "test", see
   c419562860e (checkout tests: don't ignore "git <cmd>" exit code,
   2022-03-07) for one example of how to fixthat.

 * The "test -f" here is really redundant to begin with, because we'd
   get an error from "grep" if opos didn't exist.

 * Ditto ignoring the exit code of "git reflog -1".

> @@ -78,7 +78,7 @@ test_expect_success 'revert after renaming branch' '
>  	git checkout rename1 &&
>  	git revert added &&
>  	test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
> -	test -f spoo &&
> +	test_path_is_file spoo &&
>  	! grep "Add extra line at the end" spoo &&


Same issues here, except that the "test -f" aka "test_path_is_file"
isn't redundant, as the grep is inverted.

It seems to me (other issues aside) that what this test actually wants
to express is something like this:
	
	diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
	index 8617efaaf1e..00096b75376 100755
	--- a/t/t3501-revert-cherry-pick.sh
	+++ b/t/t3501-revert-cherry-pick.sh
	@@ -78,8 +78,9 @@ test_expect_success 'revert after renaming branch' '
	 	git checkout rename1 &&
	 	git revert added &&
	 	test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
	-	test -f spoo &&
	-	! grep "Add extra line at the end" spoo &&
	+	git rev-parse initial:oops >expect &&
	+	git rev-parse HEAD:spoo >actual &&
	+	test_cmp expect actual &&
	 	git reflog -1 | grep revert
	 
	 '

I.e. we did a revert of a file we had so that it's the same as in
"initial", but now it's at a different path, which we can exhaustively
do by checking the blob OIDs.

>  	git reflog -1 | grep revert
>  
>
> base-commit: 805e0a68082a217f0112db9ee86a022227a9c81b


  reply	other threads:[~2022-03-30 22:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30 21:43 [PATCH] t3501: use test_path_is_* functions Labnan via GitGitGadget
2022-03-30 22:11 ` Ævar Arnfjörð Bjarmason [this message]
2022-03-31 19:15   ` [PATCH v2 0/3][GSoC] t3501: remove test and test -f Labnann
2022-03-31 19:15     ` [PATCH v2 1/3] t3501: use test_path_is_* functions Labnann
2022-03-31 19:15     ` [PATCH v2 2/3] t3501: don't ignore "git <cmd>" exit code Labnann
2022-04-01 18:10       ` Junio C Hamano
2022-03-31 19:15     ` [PATCH v2 3/3] t3501: test cherry-pick revert with oids Labnann
2022-04-01 18:24       ` Junio C Hamano
2022-04-02 19:24     ` [PATCH v3 0/1][GSoC] t3501: remove redundant file checking and stop ignoring git <cmd> exit code Labnann
2022-04-02 19:24       ` [PATCH v3 1/1] t3501: remove redundant file check " Labnann
2022-04-04 15:54         ` Junio C Hamano
2022-04-05 13:47       ` [PATCH v4 0/1][GSoC] t3501: remove test -f " Khalid Masum
2022-04-05 13:47         ` [PATCH v4 1/1] " Khalid Masum
2022-04-05 15:06       ` [PATCH v4 0/1][GSoC] " Khalid Masum
2022-04-05 15:06         ` [PATCH v4 1/1] " Khalid Masum
2022-04-22 11:26 ` [PATCH v2] " Labnan via GitGitGadget

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=220331.86bkxnt77a.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=khalid.masum.92@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.