Re: [v2 PATCH 2/2] reset: add tests for git reset -

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

 



On Tue, Mar 10, 2015 at 11:38 AM, Sundararajan R <dyoucme@xxxxxxxxx> wrote:
> reset: add tests for git reset -

Since this patch is changing the tests rather than 'reset' itself,
you'd likely want to say:

    t7102: add 'reset -' tests

> The failure case which occurs on teaching git is taught the '-' shorthand
> is when there exists no branch pointed to by '@{-1}'.

ECANNOTPARSE

> The ambiguous cases occur when there exist files named '-' or '@{-1}' in
> the work tree. These are also treated as failure cases but here the user
> is given advice as to how he can proceed.
>
> Add tests to check the handling of these cases.
> Also add a test to verify that reset - behaves like reset @{-1} when none
> of the above cases are true.
>
> Helped-by: Junio C Hamano <gitster@xxxxxxxxx>
> Helped-by: Torsten Bögershausen <tboegi@xxxxxx>

Torsten already pointed out this botch.

> Helped-by: Eric Sunshine <sunshine@xxxxxxxxxxxxxx>
> Helped-by: Matthieu Moy <Matthieu.Moy@xxxxxxxxxxxxxxx>
> Signed-off-by: Sundararajan R <dyoucme@xxxxxxxxx>
> ---
> diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
> index 98bcfe2..c05dab0 100755
> --- a/t/t7102-reset.sh
> +++ b/t/t7102-reset.sh
> @@ -568,4 +568,94 @@ test_expect_success 'reset --mixed sets up work tree' '
>         test_cmp expect actual
>  '
>
> +test_expect_success 'reset - with no @{-1} should fail' '
> +       git init new &&
> +       (
> +               cd new &&
> +               test_must_fail git reset - 2>actual
> +       ) &&
> +       test_i18ngrep "unknown revision" new/actual

Broken &&-chain here and throughout the patch.

> +       test_when_finished rm -rf new

If one of the statements in the test before this point fails, then
test_when_finished() will never be invoked, which means that the "rm
-rf new" cleanup action will never be run. Here, and throughout the
patch, you need to invoke test_when_finished() at the earliest point
possible so that the cleanup is effective even if some other part of
the test fails. In this case, register the cleanup either just before
or just after git-init.

> +'
> +
> +test_expect_success 'reset - with @{-1} and no file named - or @{-1} should succeed' '
> +       git init new &&
> +       (
> +               cd new &&
> +               echo "Hey" >new_file &&
> +               git add new_file &&
> +               git commit -m "first_commit" &&
> +               git checkout -b new_branch &&
> +               >new_file &&
> +               git add new_file &&
> +               git reset - &&
> +               git status -uno >file1 &&
> +               git add new_file &&
> +               git reset @{-1} &&
> +               git status -uno >file2
> +       ) &&
> +       test_cmp new/file1 new/file2

Broken &&-chain.

> +       test_when_finished rm -rf new
> +'
> +
>  test_done
> --
> 2.1.0
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]