git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
To: git@vger.kernel.org
Cc: t.gummerer@gmail.com
Subject: [PATCH v11 04/22] stash: improve option parsing test coverage
Date: Fri, 23 Nov 2018 01:05:24 +0200	[thread overview]
Message-ID: <b150a3abbfff1bcfebc272d2bea2f9ab947f68ed.1542925164.git.ungureanupaulsebastian@gmail.com> (raw)
In-Reply-To: <cover.1542925164.git.ungureanupaulsebastian@gmail.com>

From: Joel Teichroeb <joel@teichroeb.net>

In preparation for converting the stash command incrementally to
a builtin command, this patch improves test coverage of the option
parsing. Both for having too many parameters, or too few.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
---
 t/t3903-stash.sh | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index cd216655b9..4f8aa56021 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -444,6 +444,36 @@ test_expect_failure 'stash file to directory' '
 	test foo = "$(cat file/file)"
 '
 
+test_expect_success 'giving too many ref arguments does not modify files' '
+	git stash clear &&
+	test_when_finished "git reset --hard HEAD" &&
+	echo foo >file2 &&
+	git stash &&
+	echo bar >file2 &&
+	git stash &&
+	test-tool chmtime =123456789 file2 &&
+	for type in apply pop "branch stash-branch"
+	do
+		test_must_fail git stash $type stash@{0} stash@{1} 2>err &&
+		test_i18ngrep "Too many revisions" err &&
+		test 123456789 = $(test-tool chmtime -g file2) || return 1
+	done
+'
+
+test_expect_success 'drop: too many arguments errors out (does nothing)' '
+	git stash list >expect &&
+	test_must_fail git stash drop stash@{0} stash@{1} 2>err &&
+	test_i18ngrep "Too many revisions" err &&
+	git stash list >actual &&
+	test_cmp expect actual
+'
+
+test_expect_success 'show: too many arguments errors out (does nothing)' '
+	test_must_fail git stash show stash@{0} stash@{1} 2>err 1>out &&
+	test_i18ngrep "Too many revisions" err &&
+	test_must_be_empty out
+'
+
 test_expect_success 'stash create - no changes' '
 	git stash clear &&
 	test_when_finished "git reset --hard HEAD" &&
@@ -479,6 +509,11 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
 	test $(git ls-files --modified | wc -l) -eq 1
 '
 
+test_expect_success 'stash branch complains with no arguments' '
+	test_must_fail git stash branch 2>err &&
+	test_i18ngrep "No branch name specified" err
+'
+
 test_expect_success 'stash show format defaults to --stat' '
 	git stash clear &&
 	test_when_finished "git reset --hard HEAD" &&
-- 
2.19.1.878.g0482332a22


  parent reply	other threads:[~2018-11-22 23:06 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <https://public-inbox.org/git/cover.1539553398.git.ungureanupaulsebastian@gmail.com/>
2018-11-22 23:05 ` [PATCH v11 00/22] Convert "git stash" to C builtin Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 01/22] sha1-name.c: add `get_oidf()` which acts like `get_oid()` Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 02/22] strbuf.c: add `strbuf_join_argv()` Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 03/22] strbuf.c: add `strbuf_insertf()` and `strbuf_vinsertf()` Paul-Sebastian Ungureanu
2018-11-25 21:43     ` Thomas Gummerer
2018-11-27 13:35       ` Johannes Schindelin
2018-11-27 22:32         ` Thomas Gummerer
2018-11-22 23:05   ` Paul-Sebastian Ungureanu [this message]
2018-11-22 23:05   ` [PATCH v11 05/22] t3903: modernize style Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 06/22] stash: rename test cases to be more descriptive Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 07/22] stash: add tests for `git stash show` config Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 08/22] stash: mention options in `show` synopsis Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 09/22] stash: convert apply to builtin Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 10/22] stash: convert drop and clear " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 11/22] stash: convert branch " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 12/22] stash: convert pop " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 13/22] stash: convert list " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 14/22] stash: convert show " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 15/22] stash: convert store " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 16/22] stash: convert create " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 17/22] stash: convert push " Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 18/22] stash: make push -q quiet Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 19/22] stash: convert save to builtin Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 20/22] stash: convert `stash--helper.c` into `stash.c` Paul-Sebastian Ungureanu
2018-11-26  5:30     ` Junio C Hamano
2018-11-27 13:46       ` Johannes Schindelin
2018-11-27 23:40         ` Ævar Arnfjörð Bjarmason
2018-11-29 10:58           ` Johannes Schindelin
2018-11-22 23:05   ` [PATCH v11 21/22] stash: optimize `get_untracked_files()` and `check_changes()` Paul-Sebastian Ungureanu
2018-11-22 23:05   ` [PATCH v11 22/22] stash: replace all `write-tree` child processes with API calls Paul-Sebastian Ungureanu
2018-11-25 21:55   ` [PATCH v11 00/22] Convert "git stash" to C builtin Thomas Gummerer
2018-11-26  5:47     ` Junio C Hamano
2018-11-26  7:38       ` Junio C Hamano
2018-11-29 12:54         ` Johannes Schindelin
2018-11-29 14:06           ` Johannes Schindelin

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=b150a3abbfff1bcfebc272d2bea2f9ab947f68ed.1542925164.git.ungureanupaulsebastian@gmail.com \
    --to=ungureanupaulsebastian@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=t.gummerer@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).