From: Junio C Hamano <gitster@pobox.com>
To: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [GSoC][PATCH v6] parse-options: do not show usage upon invalid option value
Date: Wed, 21 Mar 2018 11:22:25 -0700 [thread overview]
Message-ID: <xmqqk1u5p9um.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20180320175005.18759-1-ungureanupaulsebastian@gmail.com> (Paul-Sebastian Ungureanu's message of "Tue, 20 Mar 2018 19:50:05 +0200")
Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com> writes:
> diff --git a/t/t0041-usage.sh b/t/t0041-usage.sh
> new file mode 100755
> index 000000000..ac96bc3b9
> --- /dev/null
> +++ b/t/t0041-usage.sh
> @@ -0,0 +1,107 @@
> +#!/bin/sh
> +
> +test_description='Test commands behavior when given invalid argument value'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'setup ' '
> + test_commit "v1.0"
> +'
> +
> +test_expect_success 'tag --contains <existent_tag>' '
> + git tag --contains "v1.0" 1>actual 2>actual.err &&
It is not wrong per-se, but >redirection without a number redirects
fd#1, so "1>actual" is an unusual way to spell ">actual".
> + grep "v1.0" actual &&
> + test_line_count = 0 actual.err
> +'
> +
> +test_expect_success 'tag --contains <inexistent_tag>' '
> + test_must_fail git tag --contains "notag" 1>actual 2>actual.err &&
> + test_line_count = 0 actual &&
> + test_i18ngrep "error" actual.err &&
> + test_must_fail test_i18ngrep "usage" actual.err
test_must_fail mustn't be used like that for two reasons
- It is to be used for "git" stuff, because it knows failing with
segfault and other failure modes are _wrong_ and should not be
happy even if the command "fail"ed. We however do not expect
commands that are not git (e.g. test_i18ngrep) to require special
casing of the failure modes.
- test_i18ngrep pretends to always "have found match" when running
under GETTEXT_POISON build, so it will pretend that usage exists
in actual.error. test_must_fail will then say "oops, the string
'usage' shouldn't appear in the output but it did", which is not
what you want.
Perhaps
test_i18ngrep ! "usage" actual.err
is what you want to say here instead.
In any case, the tests got a lot cleaner compared to the previous
round, and I feel that this patch is "getting there" ;-)
Thanks for working on it.
prev parent reply other threads:[~2018-03-21 18:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-20 17:50 [GSoC][PATCH v6] parse-options: do not show usage upon invalid option value Paul-Sebastian Ungureanu
2018-03-20 18:36 ` Eric Sunshine
2018-03-22 18:34 ` Paul-Sebastian Ungureanu
2018-03-21 18:22 ` Junio C Hamano [this message]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk1u5p9um.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ungureanupaulsebastian@gmail.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).