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

Re: [PATCH 1/3] remote: add a test for extra arguments, according to docs

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 25, 2013, 15:31 UTC
Message-ID
<7vwqrq62zv.fsf@alter.siamese.dyndns.org>
In-Reply-To
<87obd3cbux.fsf@linux-k42r.v.cablecom.net>
Thomas Rast <trast@inf.ethz.ch> writes:
Show 29 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Thomas Rast <trast@inf.ethz.ch> writes:
>>
>>> +test_extra_arg () {
>>> +	expect="success"
>>> +	if test "z$1" = "z-f"; then
>>> +		expect=failure
>>> +		shift
>>> +	fi
>>> +	test_expect_$expect "extra args: $*" "
>>> +		test_must_fail git remote $* bogus_extra_arg 2>actual &&
>>> +		grep '^usage:' actual
>>> +	"
>>> +}
>>> +
>>> +test_extra_arg -f add nick url
>>> +test_extra_arg rename origin newname
>>
>> Perhaps just a taste in readability thing, but I would prefer to see
>> them more like
>>
>> 	test_extra_arg_expect failure add nick url
>> 	test_extra_arg_expect success rename origin newname
>>
>> than misunderstanding-inviting "-f" that often stands for "--force".
>
> Hmm.  I had that at first, but then the final cleanup would have had to
> touch all tests to remove the optional argument, making it noisy.

You do not need a final cleanup, as I _never_ meant failure/success in the above illustration to be _optional_. Being explicit reduces mental burden when you later have to read such a custom scaffolding each test invents in an ad-hoc manner to suit its needs.

Previous: Thomas RastNext: Thomas Rast
Message 5 of 7 in “git remote with superfluous arguments”
  1. 0/3 git remote with superfluous argumentsThomas Rast, Apr 24, 2013
  2. 1/3 remote: add a test for extra arguments, according to docsThomas Rast, Apr 24, 2013
  3. Junio C HamanoApr 24, 2013
  4. Thomas RastApr 25, 2013
  5. Junio C HamanoApr 25, 2013
  6. 2/3 remote: check for superfluous arguments in 'git remote add'Thomas Rast, Apr 24, 2013
  7. 3/3 remote: 'show' and 'prune' take more than one remoteThomas Rast, Apr 24, 2013

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.