Skip to content

Commit 4fefec0

Browse files
klusarkdscho
authored andcommitted
stash: improve option parsing test coverage
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>
1 parent 7fb0dbe commit 4fefec0

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

t/t3903-stash.sh

+35
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,36 @@ test_expect_failure 'stash file to directory' '
444444
test foo = "$(cat file/file)"
445445
'
446446

447+
test_expect_success 'giving too many ref arguments does not modify files' '
448+
git stash clear &&
449+
test_when_finished "git reset --hard HEAD" &&
450+
echo foo >file2 &&
451+
git stash &&
452+
echo bar >file2 &&
453+
git stash &&
454+
test-tool chmtime =123456789 file2 &&
455+
for type in apply pop "branch stash-branch"
456+
do
457+
test_must_fail git stash $type stash@{0} stash@{1} 2>err &&
458+
test_i18ngrep "Too many revisions" err &&
459+
test 123456789 = $(test-tool chmtime -g file2) || return 1
460+
done
461+
'
462+
463+
test_expect_success 'drop: too many arguments errors out (does nothing)' '
464+
git stash list >expect &&
465+
test_must_fail git stash drop stash@{0} stash@{1} 2>err &&
466+
test_i18ngrep "Too many revisions" err &&
467+
git stash list >actual &&
468+
test_cmp expect actual
469+
'
470+
471+
test_expect_success 'show: too many arguments errors out (does nothing)' '
472+
test_must_fail git stash show stash@{0} stash@{1} 2>err 1>out &&
473+
test_i18ngrep "Too many revisions" err &&
474+
test_must_be_empty out
475+
'
476+
447477
test_expect_success 'stash create - no changes' '
448478
git stash clear &&
449479
test_when_finished "git reset --hard HEAD" &&
@@ -479,6 +509,11 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
479509
test $(git ls-files --modified | wc -l) -eq 1
480510
'
481511

512+
test_expect_success 'stash branch complains with no arguments' '
513+
test_must_fail git stash branch 2>err &&
514+
test_i18ngrep "No branch name specified" err
515+
'
516+
482517
test_expect_success 'stash show format defaults to --stat' '
483518
git stash clear &&
484519
test_when_finished "git reset --hard HEAD" &&

0 commit comments

Comments
 (0)