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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <joel@xxxxxxxxxxxxx>
> ---
>  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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux