Re: [PATCH v2 01/10] cat-file tests: test for bogus type name handling

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

 



Ævar Arnfjörð Bjarmason  <avarab@xxxxxxxxx> writes:

> Add a test of how "cat-file" behaves when given a bogus type in its
> "git cat-file <TYPE> <OBJECT>" mode. There were existing tests (just
> below this one) for "-t bogus" or "--allow-unknown-type" modes, but
> none for the switch-less mode.
>
> This test is similar to the one that exists for "git hash-object"
> already, see b7994af0f92 (type_from_string_gently: make sure length
> matches, 2015-04-17).
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
> ---
>  t/t1006-cat-file.sh | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> index 5d2dc99b74..908797dcae 100755
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -315,6 +315,22 @@ test_expect_success '%(deltabase) reports packed delta bases' '
>  	}
>  '
>  
> +test_expect_success 'cat-file complains about bogus type name' '
> +	test_must_fail git cat-file co HEAD >out 2>err &&
> +	test_must_be_empty out &&
> +	cat >expected <<-\EOF &&
> +	fatal: invalid object type "co"
> +	EOF
> +	test_cmp expected err &&
> +
> +	test_must_fail git cat-file bogus HEAD >out 2>err &&
> +	test_must_be_empty out &&
> +	cat >expected <<-\EOF &&
> +	fatal: invalid object type "bogus"
> +	EOF
> +	test_cmp expected err
> +'

I am not 100% sure if it is worth testing both "co" and "bogus", but
if it were, then I'd prefer to have these two as independent test
pieces, because a convincing "we need to have both of these tested
for this reason" would very much likely say that these two kinds of
bugs can come from different/independent bug sources.

FWIW, the commit b7994af0 (type_from_string_gently: make sure length
matches, 2015-04-17) used as a model for this patch uses two
separate tests (one for truncated, the other for bogus).

>  bogus_type="bogus"
>  bogus_content="bogus"
>  bogus_size=$(strlen "$bogus_content")




[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