git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Britton Leo Kerin <britton.kerin@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v4 8/8] completion: add tests for git-bisect
Date: Thu, 1 Feb 2024 10:55:46 +0100	[thread overview]
Message-ID: <Zbtqomb-S270SMba@tanuki> (raw)
In-Reply-To: <20240128223447.342493-9-britton.kerin@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4911 bytes --]

On Sun, Jan 28, 2024 at 01:34:47PM -0900, Britton Leo Kerin wrote:
> There aren't any tests for completion of git bisect and it's
> subcommands.
> 
> Add tests.

I think it would be nice if you added relevant tests directly in the
commits that introduce the new completions. E.g. add a test for the
bisect terms in the same commit where you introduce the completion for
it.

Like that you can easily add tests one by one, which decreases the
review load. Also, it serves to demonstrate both that the functionality
works and helps the reviewer to understand better what exactly you are
adding by having a nice example.

Patrick

> ---
>  t/t9902-completion.sh | 135 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 135 insertions(+)
> 
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index aa9a614de3..698e278450 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -1259,6 +1259,141 @@ test_expect_success 'git switch - with no options, complete local branches and u
>  	EOF
>  '
>  
> +test_expect_success 'git bisect - when not bisecting, complete only replay and start subcommands' '
> +	test_completion "git bisect " <<-\EOF
> +	replay Z
> +	start Z
> +	EOF
> +'
> +
> +test_expect_success 'git bisect - complete options to start subcommand' '
> +	test_completion "git bisect start --" <<-\EOF
> +	--term-new Z
> +	--term-bad Z
> +	--term-old Z
> +	--term-good Z
> +	--no-checkout Z
> +	--first-parent Z
> +	EOF
> +'
> +
> +test_expect_success 'setup for git-bisect tests requiring a repo' '
> +	git init git-bisect &&
> +	(
> +		cd git-bisect &&
> +		echo "initial contents" >file &&
> +		git add file &&
> +		git commit -am "Initial commit" &&
> +		git tag initial &&
> +		echo "new line" >>file &&
> +		git commit -am "First change" &&
> +		echo "another new line" >>file &&
> +		git commit -am "Second change" &&
> +		git tag final
> +	)
> +'
> +
> +test_expect_success 'git bisect - start subcommand arguments before double-dash are completed as revs' '
> +	(
> +		cd git-bisect &&
> +		test_completion "git bisect start " <<-\EOF
> +		HEAD Z
> +		final Z
> +		initial Z
> +		master Z
> +		EOF
> +	)
> +'
> +
> +# Note that these arguments are <pathspec>s, which in practice the fallback
> +# completion (not the git completion) later ends up completing as paths.
> +test_expect_success 'git bisect - start subcommand arguments after double-dash are not completed' '
> +	(
> +		cd git-bisect &&
> +		test_completion "git bisect start final initial -- " ""
> +	)
> +'
> +
> +test_expect_success 'setup for git-bisect tests requiring ongoing bisection' '
> +	(
> +		cd git-bisect &&
> +		git bisect start --term-new=custom_new --term-old=custom_old final initial
> +	)
> +'
> +
> +test_expect_success 'git-bisect - when bisecting all subcommands are candidates' '
> +	(
> +		cd git-bisect &&
> +		test_completion "git bisect " <<-\EOF
> +		start Z
> +		bad Z
> +		custom_new Z
> +		custom_old Z
> +		new Z
> +		good Z
> +		old Z
> +		terms Z
> +		skip Z
> +		reset Z
> +		visualize Z
> +		replay Z
> +		log Z
> +		run Z
> +		help Z
> +		EOF
> +	)
> +'
> +test_expect_success 'git-bisect - options to terms subcommand are candidates' '
> +	(
> +		cd git-bisect &&
> +		test_completion "git bisect terms --" <<-\EOF
> +		--term-bad Z
> +		--term-good Z
> +		--term-new Z
> +		--term-old Z
> +		EOF
> +	)
> +'
> +
> +test_expect_success 'git-bisect - git-log options to visualize subcommand are candidates' '
> +	(
> +		cd git-bisect &&
> +		# The completion used for git-log and here does not complete
> +		# every git-log option, so rather than hope to stay in sync
> +		# with exactly what it does we will just spot-test here.
> +		test_completion "git bisect visualize --sta" <<-\EOF &&
> +		--stat Z
> +		EOF
> +		test_completion "git bisect visualize --summar" <<-\EOF
> +		--summary Z
> +		EOF
> +	)
> +'
> +
> +test_expect_success 'git-bisect - view subcommand is not a candidate' '
> +	(
> +		cd git-bisect &&
> +		test_completion "git bisect vi" <<-\EOF
> +		visualize Z
> +		EOF
> +	)
> +'
> +
> +test_expect_success 'git-bisect - existing view subcommand is recognized and enables completion of git-log options' '
> +	(
> +		cd git-bisect &&
> +		# The completion used for git-log and here does not complete
> +		# every git-log option, so rather than hope to stay in sync
> +		# with exactly what it does we will just spot-test here.
> +		test_completion "git bisect view --sta" <<-\EOF &&
> +		--stat Z
> +		EOF
> +		test_completion "git bisect view --summar" <<-\EOF
> +		--summary Z
> +		EOF
> +	)
> +'
> +
>  test_expect_success 'git checkout - completes refs and unique remote branches for DWIM' '
>  	test_completion "git checkout " <<-\EOF
>  	HEAD Z
> -- 
> 2.43.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2024-02-01  9:55 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 19:57 [RFC PATCH 0/6] completion: improvements for git-bisect Britton Leo Kerin
2024-01-10  2:03 ` [PATCH v2 0/5] " Britton Leo Kerin
2024-01-18 20:43   ` [PATCH v3 " Britton Leo Kerin
2024-01-18 20:43     ` [PATCH v3 1/5] completion: complete new old actions, start opts Britton Leo Kerin
2024-01-19  7:04       ` Patrick Steinhardt
2024-01-18 20:43     ` [PATCH v3 2/5] completion: git-log opts to bisect visualize Britton Leo Kerin
2024-01-19  7:04       ` Patrick Steinhardt
2024-01-18 20:43     ` [PATCH v3 3/5] completion: move to maintain define-before-use Britton Leo Kerin
2024-01-19  7:04       ` Patrick Steinhardt
2024-01-18 20:43     ` [PATCH v3 4/5] completion: custom git-bisect terms Britton Leo Kerin
2024-01-19  7:04       ` Patrick Steinhardt
2024-01-18 20:43     ` [PATCH v3 5/5] completion: git-bisect view recognized but not completed Britton Leo Kerin
2024-01-19  7:05       ` Patrick Steinhardt
2024-01-19  7:05     ` [PATCH v3 0/5] completion: improvements for git-bisect Patrick Steinhardt
2024-01-19 18:27       ` Junio C Hamano
2024-01-26  0:23       ` Britton Kerin
2024-01-28 22:34     ` [PATCH v4 0/8] " Britton Leo Kerin
2024-01-28 22:34       ` [PATCH v4 1/8] completion: bisect: complete bad, new, old, and help subcommands Britton Leo Kerin
2024-02-01  9:55         ` Patrick Steinhardt
2024-01-28 22:34       ` [PATCH v4 2/8] completion: bisect: complete custom terms and related options Britton Leo Kerin
2024-02-01  9:55         ` Patrick Steinhardt
2024-01-28 22:34       ` [PATCH v4 3/8] completion: bisect: complete missing --first-parent and --no-checkout options Britton Leo Kerin
2024-01-28 22:34       ` [PATCH v4 4/8] completion: new function __git_complete_log_opts Britton Leo Kerin
2024-01-28 22:34       ` [PATCH v4 5/8] completion: log: use __git_complete_log_opts Britton Leo Kerin
2024-02-01  9:55         ` Patrick Steinhardt
2024-01-28 22:34       ` [PATCH v4 6/8] completion: bisect: complete log opts for visualize subcommand Britton Leo Kerin
2024-01-28 22:34       ` [PATCH v4 7/8] completion: bisect: recognize but do not complete view subcommand Britton Leo Kerin
2024-01-28 22:34       ` [PATCH v4 8/8] completion: add tests for git-bisect Britton Leo Kerin
2024-01-30  5:47         ` Junio C Hamano
2024-02-01  9:55         ` Patrick Steinhardt [this message]
2024-02-01  9:55       ` [PATCH v4 0/8] completion: improvements " Patrick Steinhardt
2024-02-06  2:09       ` [PATCH v5 0/7] " Britton Leo Kerin
2024-02-06  2:09         ` [PATCH v5 1/7] completion: tests: always use 'master' for default initial branch name Britton Leo Kerin
2024-02-06  2:09         ` [PATCH v5 2/7] completion: bisect: complete bad, new, old, and help subcommands Britton Leo Kerin
2024-02-06  7:40           ` Patrick Steinhardt
2024-02-06  2:09         ` [PATCH v5 3/7] completion: bisect: complete custom terms and related options Britton Leo Kerin
2024-02-06  7:40           ` Patrick Steinhardt
2024-02-06  2:09         ` [PATCH v5 4/7] completion: bisect: complete missing --first-parent and --no-checkout options Britton Leo Kerin
2024-02-06  2:09         ` [PATCH v5 5/7] completion: new function __git_complete_log_opts Britton Leo Kerin
2024-02-06  7:40           ` Patrick Steinhardt
2024-02-06  2:09         ` [PATCH v5 6/7] completion: bisect: complete log opts for visualize subcommand Britton Leo Kerin
2024-02-06  2:09         ` [PATCH v5 7/7] completion: bisect: recognize but do not complete view subcommand Britton Leo Kerin
2024-02-06  7:40         ` [PATCH v5 0/7] completion: improvements for git-bisect Patrick Steinhardt
2024-02-06 21:50         ` [PATCH v6 " Britton Leo Kerin
2024-02-06 21:50           ` [PATCH v6 1/7] completion: tests: always use 'master' for default initial branch name Britton Leo Kerin
2024-02-06 21:50           ` [PATCH v6 2/7] completion: bisect: complete bad, new, old, and help subcommands Britton Leo Kerin
2024-02-06 21:50           ` [PATCH v6 3/7] completion: bisect: complete custom terms and related options Britton Leo Kerin
2024-02-06 21:50           ` [PATCH v6 4/7] completion: bisect: complete missing --first-parent and --no-checkout options Britton Leo Kerin
2024-02-06 21:50           ` [PATCH v6 5/7] completion: new function __git_complete_log_opts Britton Leo Kerin
2024-02-06 21:50           ` [PATCH v6 6/7] completion: bisect: complete log opts for visualize subcommand Britton Leo Kerin
2024-02-06 21:50           ` [PATCH v6 7/7] completion: bisect: recognize but do not complete view subcommand Britton Leo Kerin
2024-02-06 22:58           ` [PATCH v6 0/7] completion: improvements for git-bisect Junio C Hamano
2024-02-07  5:26             ` Patrick Steinhardt
     [not found] ` <20240110020347.673155-1-britton.kerin@gmail.com>
2024-01-10  2:03   ` [PATCH v2 1/5] completion: complete new old actions, start opts Britton Leo Kerin
2024-01-10  2:03   ` [PATCH v2 2/5] completion: git-log opts to bisect visualize Britton Leo Kerin
2024-01-10  2:03   ` [PATCH v2 3/5] completion: move to maintain define-before-use Britton Leo Kerin
2024-01-10  2:03   ` [PATCH v2 4/5] completion: custom git-bisect terms Britton Leo Kerin
2024-01-10  2:03   ` [PATCH v2 5/5] " Britton Leo Kerin

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=Zbtqomb-S270SMba@tanuki \
    --to=ps@pks.im \
    --cc=britton.kerin@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).