git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rubén Justo" <rjusto@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH v2] completion: fix __git_complete_worktree_paths
Date: Tue, 27 Feb 2024 19:09:39 +0100	[thread overview]
Message-ID: <0928d29b-41df-40a4-9536-4a8d097faa83@gmail.com> (raw)
In-Reply-To: <Zd2bnJZtgW2tFMFn@tanuki>

On Tue, Feb 27, 2024 at 09:21:48AM +0100, Patrick Steinhardt wrote:

> > +test_expect_success '__git_complete_worktree_paths - not a git repository' '
> > +	(
> > +		cd non-repo &&
> > +		GIT_CEILING_DIRECTORIES="$ROOT" &&
> > +		export GIT_CEILING_DIRECTORIES &&
> > +		test_completion "git worktree remove " "" 2>err &&
> > +		test_must_be_empty err
> > +	)
> > +'
> 
> If I understand correctly, we assume that the repo isn't detected here,
> and thus we will fail to complete the command. We don't want an error
> message though, which we assert.

Correct.

> But do we also want to assert that
> there is no output on stdout?

To me, the check makes sense;  to notice if we leak a message in such a
circumstance, for instance.  I can drop it if you think it does not add
value.

The test for stderr is my main goal here.

> 
> > +
> > +test_expect_success '__git_complete_worktree_paths with -C' '
> > +	test_when_finished "rm -rf to_delete" &&
> 
> What does this delete? I don't see "to_delete" being created as part of
> this test.

Good eyes.  It's noise.  I'll drop this line.  Thanks.

> 
> > +	git -C otherrepo worktree add --orphan otherrepo_wt &&
> > +	run_completion "git -C otherrepo worktree remove " &&
> > +	grep otherrepo_wt out
> 
> And as far as I can see, we don't write to "out" in this test, either.
> So I think we're accidentally relying on state by the first test here.

The function run_completion leaves the result of the completion in the
file "out".  So we're checking here if "otherrepo_wt" is present in what
"git -C otherrepo worktree remove <TAB>" returns.

Maybe a new function: grep_completion, similar to test_completion, could
make this clearer?

> 
> Patrick

Thanks.

> 
> > +'
> > +
> >  test_expect_success 'git switch - with no options, complete local branches and unique remote branch names for DWIM logic' ' ow
> >  	test_completion "git switch " <<-\EOF
> >  	branch-in-other Z
> > -- 
> > 2.44.0.1.g0da3aa8f7f
> > 



  reply	other threads:[~2024-02-27 18:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25  8:16 [PATCH] completion: fix __git_complete_worktree_paths Rubén Justo
2024-02-25 23:53 ` [PATCH v2] " Rubén Justo
2024-02-27  8:21   ` Patrick Steinhardt
2024-02-27 18:09     ` Rubén Justo [this message]
2024-02-27 21:06   ` [PATCH v3] " Rubén Justo

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=0928d29b-41df-40a4-9536-4a8d097faa83@gmail.com \
    --to=rjusto@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /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).