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

[PATCH v3 1/5] stash: improve option parsing test coverage

From
Joel Teichroeb <joel@teichroeb.net>
Date
Mar 27, 2018, 05:44 UTC
Message-ID
<20180327054432.26419-2-joel@teichroeb.net>
In-Reply-To
<20180327054432.26419-1-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 paramerters, or too few.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
---
 t/t3903-stash.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index aefde7b17..8a666c60c 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -84,6 +84,17 @@ test_expect_success 'apply stashed changes (including index)' '
 	test 1 = $(git show HEAD:file)
 '
 
+test_expect_success 'giving too many ref agruments does nothing' '
+
+	for type in apply drop pop show "branch stash-branch"
+	do
+		test-chmtime =123456789 file &&
+		test_must_fail git stash $type stash@{0} stash@{1} 2>err &&
+		test_i18ngrep "Too many" err &&
+		test 123456789 = $(test-chmtime -v +0 file | sed 's/[^0-9].*$//') || return 1
+	done
+'
+
 test_expect_success 'unstashing in a subdirectory' '
 	git reset --hard HEAD &&
 	mkdir subdir &&
@@ -479,6 +490,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.16.2
Previous: Joel TeichroebNext: Joel Teichroeb
Message 2 of 10 in “Convert some stash functionality to a builtin”
  1. 0/5 Convert some stash functionality to a builtinJoel Teichroeb, Mar 27, 2018
  2. 1/5 stash: improve option parsing test coverageJoel Teichroeb, Mar 27, 2018
  3. 2/5 stash: convert apply to builtinJoel Teichroeb, Mar 27, 2018
  4. Johannes SchindelinMar 27, 2018
  5. Johannes SchindelinMar 27, 2018
  6. Joel TeichroebMar 27, 2018
  7. 3/5 stash: convert drop and clear to builtinJoel Teichroeb, Mar 27, 2018
  8. 4/5 stash: convert branch to builtinJoel Teichroeb, Mar 27, 2018
  9. 5/5 stash: convert pop to builtinJoel Teichroeb, Mar 27, 2018
  10. Johannes SchindelinMar 27, 2018

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.