Re: [PATCH v5 1/5] stash: improve option parsing test coverage
Hi Paul, On Sat, 7 Apr 2018, Paul-Sebastian Ungureanu wrote: > On 06.04.2018 16:06, Johannes Schindelin wrote: > > > + git stash clear && > > > + test_when_finished "git reset --hard HEAD" && > > > + echo foo >file2 && > > > + git stash && > > > + echo bar >file2 && > > > + git stash && > > > + test-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" err && > > > + test 123456789 = $(test-chmtime -v +0 file2 | sed > > > 's/[^0-9].*$//') || return 1 > > > > Not your problem, but if there is future work on this (read: if I get to > > mentor a GSoC student, and if I get them to work on it: this idiom > > `test-chmtime -v +0 ... | sed ...` is too common, there really *should* be > > a `test-chmtime --get ...`). > > Hi, > > I submitted a patch for this [1]. > > [1] > https://public-inbox.org/git/20180406221947.28402-1-ungureanupaulsebast...@gmail.com/ Excellent, thank you so much! Johannes
Re: [PATCH v5 1/5] stash: improve option parsing test coverage
On 06.04.2018 16:06, Johannes Schindelin wrote: + git stash clear && + test_when_finished "git reset --hard HEAD" && + echo foo >file2 && + git stash && + echo bar >file2 && + git stash && + test-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" err && + test 123456789 = $(test-chmtime -v +0 file2 | sed 's/[^0-9].*$//') || return 1 Not your problem, but if there is future work on this (read: if I get to mentor a GSoC student, and if I get them to work on it: this idiom `test-chmtime -v +0 ... | sed ...` is too common, there really *should* be a `test-chmtime --get ...`). Hi, I submitted a patch for this [1]. [1] https://public-inbox.org/git/20180406221947.28402-1-ungureanupaulsebast...@gmail.com/ Best regards, Paul Ungureanu
Re: [PATCH v5 1/5] stash: improve option parsing test coverage
Hi Joel, On Wed, 4 Apr 2018, Joel Teichroeb wrote: > 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. Very good. > Signed-off-by: Joel Teichroeb > --- > t/t3903-stash.sh | 35 +++ > 1 file changed, 35 insertions(+) > > diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh > index aefde7b172..4eaa4cae9a 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 agruments does not modify files' ' Quick, before Eric beats me to it! A typo! s/agruments/arguments/ > + git stash clear && > + test_when_finished "git reset --hard HEAD" && > + echo foo >file2 && > + git stash && > + echo bar >file2 && > + git stash && > + test-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" err && > + test 123456789 = $(test-chmtime -v +0 file2 | sed > 's/[^0-9].*$//') || return 1 Not your problem, but if there is future work on this (read: if I get to mentor a GSoC student, and if I get them to work on it: this idiom `test-chmtime -v +0 ... | sed ...` is too common, there really *should* be a `test-chmtime --get ...`). Any prospective GSoC student: you know what I have in stock for you ;-) > + done > +' > + > +test_expect_success 'giving too many ref agruments to drop does not drop > anything' ' s/agruments/arguments/ Also, we try to keep the lines to <= 80 columns. So maybe +test_expect_success 'drop: too many arguments errors out (does nothing)' ' > + git stash list > stashlist1 && Again, before Eric can beat me to it: we prefer the syntax `>file` (i.e. without a space between the `>` and the file name). BTW is there a public branch with your patches? I am not so much of a fan of reviewing and having all the work being punted back to the contributor, especially when we failed you for so long in reviewing these patches. I would love, for example, to open a PR on GitHub (even if that would only apply to code changes, not so much to commit message changes, not until we have rebase support reword! and drop! keywords). > + test_must_fail git stash drop stash@{0} stash@{1} 2>err && > + test_i18ngrep "Too many" err && > + git stash list > stashlist2 && > + test_cmp stashlist1 stashlist2 > +' It might make sense to rename stashlist1 to `expect` an `stashlist2` to `actual`, to clarify the roles. > + > +test_expect_success 'giving too many ref agruments to show does not show > anything' ' Maybe test_expect_success 'show: error on too may arguments (show nothing)' to keep within the 80 columns/line limit? The rest looks obviously correct to me. Thanks! Dscho
[PATCH v5 1/5] 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 --- t/t3903-stash.sh | 35 +++ 1 file changed, 35 insertions(+) diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index aefde7b172..4eaa4cae9a 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 agruments 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-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" err && + test 123456789 = $(test-chmtime -v +0 file2 | sed 's/[^0-9].*$//') || return 1 + done +' + +test_expect_success 'giving too many ref agruments to drop does not drop anything' ' + git stash list > stashlist1 && + test_must_fail git stash drop stash@{0} stash@{1} 2>err && + test_i18ngrep "Too many" err && + git stash list > stashlist2 && + test_cmp stashlist1 stashlist2 +' + +test_expect_success 'giving too many ref agruments to show does not show anything' ' + test_must_fail git stash show stash@{0} stash@{1} 2>err 1>out && # show must not show anything + test_i18ngrep "Too many" 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.16.3