git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 5/6] completion: refactor __gitcomp related tests

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 16, 2012, 19:13 UTC
Message-ID
<7v8va1mkcv.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1352644558-9410-6-git-send-email-felipe.contreras@gmail.com>

Not asking for a re-roll but am asking for clarification so that I can locally update before queuing.

Felipe Contreras <felipe.contreras@gmail.com> writes:
> Lots of duplicated code!
... removed, you mean?
Show 25 quoted lines
> No functional changes.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  t/t9902-completion.sh | 76 ++++++++++++++++++---------------------------------
>  1 file changed, 27 insertions(+), 49 deletions(-)
>
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index 59cdbfd..66c7af6 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -71,87 +71,65 @@ test_completion ()
>  
>  newline=$'\n'
>  
> -test_expect_success '__gitcomp - trailing space - options' '
> -	sed -e "s/Z$//" >expected <<-\EOF &&
> -	--reuse-message=Z
> -	--reedit-message=Z
> -	--reset-author Z
> -	EOF
> +# Test __gitcomp.
> +# Arguments are:
> +# 1: typed text so far (cur)
> +# *: arguments to pass to __gitcomp

s/\*/remainder/, perhaps? I think you shift $1 out and do not pass it to __gitcomp.

And expected output is from the standard input just like test_completion?

Show 25 quoted lines
> +test_gitcomp ()
> +{
> +	sed -e 's/Z$//' > expected &&
>  	(
>  		local -a COMPREPLY &&
> -		cur="--re" &&
> -		__gitcomp "--dry-run --reuse-message= --reedit-message=
> -				--reset-author" &&
> +		cur="$1" &&
> +		shift &&
> +		__gitcomp "$@" &&
>  		IFS="$newline" &&
>  		echo "${COMPREPLY[*]}" > out
>  	) &&
>  	test_cmp expected out
> +}
> +
> +test_expect_success '__gitcomp - trailing space - options' '
> +	test_gitcomp "--re" "--dry-run --reuse-message= --reedit-message=
> +		--reset-author" <<-EOF
> +	--reuse-message=Z
> +	--reedit-message=Z
> +	--reset-author Z
> +	EOF
>  '
Nice shrinkage.
Previous: Felipe ContrerasNext: Felipe Contreras
Message 12 of 16 in “completion: test consolidations”
  1. 0/6 completion: test consolidationsFelipe Contreras, Nov 11, 2012
  2. 1/6 completion: add comment for test_completion()Felipe Contreras, Nov 11, 2012
  3. SZEDER GáborNov 16, 2012
  4. Felipe ContrerasNov 16, 2012
  5. Felipe ContrerasNov 16, 2012
  6. 2/6 completion: standardize final space marker in testsFelipe Contreras, Nov 11, 2012
  7. 3/6 completion: simplify tests using test_completion_long()Felipe Contreras, Nov 11, 2012
  8. 4/6 completion: consolidate test_completion*() testsFelipe Contreras, Nov 11, 2012
  9. Junio C HamanoNov 16, 2012
  10. Felipe ContrerasNov 17, 2012
  11. 5/6 completion: refactor __gitcomp related testsFelipe Contreras, Nov 11, 2012
  12. Junio C HamanoNov 16, 2012
  13. Felipe ContrerasNov 16, 2012
  14. SZEDER GáborNov 16, 2012
  15. Junio C HamanoNov 16, 2012
  16. 6/6 completion: simplify __gitcomp() test helperFelipe Contreras, Nov 11, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.