From: Jens Lehmann <Jens.Lehmann@web.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Teach checkout the -n|--dry-run option
Date: Sun, 08 May 2011 23:41:46 +0200 [thread overview]
Message-ID: <4DC70E1A.6060702@web.de> (raw)
In-Reply-To: <7vwri0ric1.fsf@alter.siamese.dyndns.org>
Am 08.05.2011 23:30, schrieb Junio C Hamano:
> Jens Lehmann <Jens.Lehmann@web.de> writes:
>
>> diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
>> index ca8a409..bcfb5e6 100755
>> --- a/t/t1000-read-tree-m-3way.sh
>> +++ b/t/t1000-read-tree-m-3way.sh
>> @@ -259,6 +259,8 @@ test_expect_success \
>> "rm -f .git/index AA &&
>> cp .orig-A/AA AA &&
>> git update-index --add AA &&
>> + git read-tree -n -m $tree_O $tree_A $tree_B &&
>> + test_must_fail check_result &&
>
> That's a rather sloppy way to test that the command did not do anything to
> compare one possible outcome, instead of verifying that the result is
> identical to the original condition, no?
>
> How about
>
> ...
> git update_index --add AA &&
> git ls-files -s >pre-dry-run &&
> git read-tree -n -m $tree_O $tree_A $tree_B &&
> git ls-files -s >post-dry-run &&
> test_cmp pre-dry-run post-dry-run &&
> ...
Yeah, that is much better than my first sketch.
> We also should be checking that the command reports it is going to fail
> when it should as well. Always remember to check both sides of the coin.
>
>> git read-tree -m $tree_O $tree_A $tree_B &&
>> check_result"
>
> I suspect that it would make sense to replace
>
> git read-tree $args && check_result
>
> with
>
> read_tree_must_succeed $args
>
> and
>
> test_must_fail git read-tree $args
>
> with
>
> read_tree_must_fail $args
>
> and implement two shell wrappers, perhaps like this.
>
> read_tree_must_succeed () {
> git ls-files -s >pre-dry-run &&
> git read-tree -n "$@" &&
> git ls-files -s >post-dry-run &&
> test_cmp pre-dry-run post-dry-run &&
> git read-tree "$@"
> }
>
> read_tree_must_fail () {
> git ls-files -s >pre-dry-run &&
> test_must_fail git read-tree -n "$@" &&
> git ls-files -s >post-dry-run &&
> test_must_fail git read-tree "$@"
> }
Thanks, will send an updated patch with better test cases soon ...
next prev parent reply other threads:[~2011-05-08 21:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-06 22:12 [PATCH] Teach checkout the -n|--dry-run option Jens Lehmann
2011-05-06 22:49 ` Junio C Hamano
2011-05-07 19:24 ` Junio C Hamano
2011-05-08 11:22 ` Jens Lehmann
2011-05-08 20:50 ` Jens Lehmann
2011-05-08 21:30 ` Junio C Hamano
2011-05-08 21:41 ` Jens Lehmann [this message]
2011-05-11 21:50 ` [PATCH] Teach read-tree " Jens Lehmann
2011-05-11 22:47 ` 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=4DC70E1A.6060702@web.de \
--to=jens.lehmann@web.de \
--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).