git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, "Manlio Perillo" <manlio.perillo@gmail.com>,
	"Matthieu Moy" <Matthieu.Moy@imag.fr>,
	"SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: [PATCH v2 1/9] completion: add file completion tests
Date: Sat, 27 Apr 2013 14:24:31 -0700	[thread overview]
Message-ID: <7vehdvu0og.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1367093407-8898-2-git-send-email-felipe.contreras@gmail.com> (Felipe Contreras's message of "Sat, 27 Apr 2013 15:09:59 -0500")

Felipe Contreras <felipe.contreras@gmail.com> writes:

> The commit fea16b4 (git-completion.bash: add support for path
> completion) introduced quite a few changes, without the usual tests.
>
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  t/t9902-completion.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 68 insertions(+)
>
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index 6d9d141..385e1e4 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -347,4 +347,72 @@ test_expect_success 'send-email' '
>  	test_completion "git send-email ma" "master "
>  '
>  
> +test_expect_success 'complete files' '
> +	git init tmp && cd tmp &&
> +	test_when_finished "cd .. && rm -rf tmp" &&

Hmm, this construct is not very nice.

Later part of the code can be modified carelessly and chdir around
even more, and "cd .." may end up at an unexpected place.  Can't
this be done in a way to make later reviews of patches that come
after this change lands doable without looking at the whole 70
lines?  For example, if the test ran the whole "these are done in a
subdirectry" part, starting from the "cd tmp", inside a subshell,
and "rm -rf tmp" is done in the original shell that ran "git init
tmp" to create it, it would make it much harder to make mistakes for
anybody who add new code to the body of the test to affect the
clean-up part.

> +
> +	echo "expected" > .gitignore &&
> +	echo "out" >> .gitignore &&

Style: we tend to omit SP between redireciton operator and targets.

> +	git add .gitignore &&
> +	test_completion "git commit " ".gitignore" &&
> +
> +	git commit -m ignore &&
> +
> +	touch new &&
> +	test_completion "git add " "new" &&
> +
> +	git add new &&
> +	git commit -a -m new &&
> +	test_completion "git add " "" &&
> +
> +	git mv new modified &&
> +	echo modify > modified &&
> +	test_completion "git add " "modified" &&
> +
> +	touch untracked &&
> +
> +	: TODO .gitignore should not be here &&
> +	test_completion "git rm " <<-\EOF &&
> +	.gitignore
> +	modified
> +	EOF
> +
> +	test_completion "git clean " "untracked" &&
> +
> +	: TODO .gitignore should not be here &&
> +	test_completion "git mv " <<-\EOF &&
> +	.gitignore
> +	modified
> +	EOF
> +
> +	mkdir dir &&
> +	touch dir/file-in-dir &&
> +	git add dir/file-in-dir &&
> +	git commit -m dir &&
> +
> +	mkdir untracked-dir &&
> +
> +	: TODO .gitignore should not be here &&
> +	test_completion "git mv modified " <<-\EOF &&
> +	.gitignore
> +	dir
> +	modified
> +	untracked
> +	untracked-dir
> +	EOF
> +
> +	test_completion "git commit " "modified" &&
> +
> +	: TODO .gitignore should not be here &&
> +	test_completion "git ls-files " <<-\EOF
> +	.gitignore
> +	dir
> +	modified
> +	EOF
> +
> +	touch momified &&
> +	test_completion "git add mom" "momified"
> +'
> +
>  test_done

  reply	other threads:[~2013-04-27 21:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 20:09 [PATCH v2 0/9] completion: general cleanups Felipe Contreras
2013-04-27 20:09 ` [PATCH v2 1/9] completion: add file completion tests Felipe Contreras
2013-04-27 21:24   ` Junio C Hamano [this message]
2013-04-27 20:10 ` [PATCH v2 2/9] completion: document tilde expansion failure in tests Felipe Contreras
2013-04-27 20:10 ` [PATCH v2 3/9] completion; remove unuseful comments Felipe Contreras
2013-04-27 20:10 ` [PATCH v2 4/9] completion: use __gitcompadd for __gitcomp_file Felipe Contreras
2013-04-27 20:10 ` [PATCH v2 5/9] completion: refactor diff_index wrappers Felipe Contreras
2013-04-27 21:29   ` Junio C Hamano
2013-04-27 20:10 ` [PATCH v2 6/9] completion: refactor __git_complete_index_file() Felipe Contreras
2013-04-27 20:10 ` [PATCH v2 7/9] completion: add hack to enable file mode in bash < 4 Felipe Contreras
2013-04-27 20:10 ` [PATCH v2 8/9] completion: add space after completed filename Felipe Contreras
2013-04-27 20:10 ` [PATCH v2 9/9] completion: remove __git_index_file_list_filter() Felipe Contreras
2013-04-28  1:41   ` Eric Sunshine
2013-04-28  1:45     ` Felipe Contreras
2013-04-27 21:34 ` [PATCH v2 0/9] completion: general cleanups Junio C Hamano

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=7vehdvu0og.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Matthieu.Moy@imag.fr \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=manlio.perillo@gmail.com \
    --cc=szeder@ira.uka.de \
    /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).