git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Rast <trast@inf.ethz.ch>
To: <git@vger.kernel.org>
Subject: [PATCH 1/3] remote: add a test for extra arguments, according to docs
Date: Wed, 24 Apr 2013 15:54:35 +0200	[thread overview]
Message-ID: <372aa93e4a7a3583730c02543583ce93e095ec64.1366811347.git.trast@inf.ethz.ch> (raw)
In-Reply-To: <cover.1366811347.git.trast@inf.ethz.ch>

This adds one test or comment for each subcommand of git-remote
according to its current documentation.  All but 'set-branches' and
'update' are listed as taking only a fixed number of arguments; for
those we can write a test with one more (bogus) argument, and see if
the command notices that.

They fail on several counts: 'add' does not check for extra arguments,
and 'show' and 'prune' actually iterate over remotes (i.e., take any
number of args).  We'll fix them in the next two patches.

The -f machinery is only there to make the tests readable while still
ensuring they pass as a whole, and will be removed in the final patch.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
---
 t/t5505-remote.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 6579a86..764ee97 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1003,4 +1003,31 @@ test_expect_success 'remote set-url --delete baz' '
 	cmp expect actual
 '
 
+test_expect_success 'extra args: setup' '
+	# add a dummy origin so that this does not trigger failure
+	git remote add origin .
+'
+
+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
+test_extra_arg remove origin
+test_extra_arg set-head origin master
+# set-branches takes any number of args
+test_extra_arg set-url origin newurl oldurl
+test_extra_arg -f show origin
+test_extra_arg -f prune origin
+# update takes any number of args
+
 test_done
-- 
1.8.2.1.931.g0116868

  reply	other threads:[~2013-04-24 13:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24 13:54 [PATCH 0/3] git remote with superfluous arguments Thomas Rast
2013-04-24 13:54 ` Thomas Rast [this message]
2013-04-24 21:37   ` [PATCH 1/3] remote: add a test for extra arguments, according to docs Junio C Hamano
2013-04-25  7:23     ` Thomas Rast
2013-04-25 15:31       ` Junio C Hamano
2013-04-24 13:54 ` [PATCH 2/3] remote: check for superfluous arguments in 'git remote add' Thomas Rast
2013-04-24 13:54 ` [PATCH 3/3] remote: 'show' and 'prune' take more than one remote Thomas Rast

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=372aa93e4a7a3583730c02543583ce93e095ec64.1366811347.git.trast@inf.ethz.ch \
    --to=trast@inf.ethz.ch \
    --cc=git@vger.kernel.org \
    /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).