git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] t/t7106-reset-unborn-branch.sh: Add PERL prerequisite

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2013, 06:50 UTC
Message-ID
<xmqq8uzql0vr.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20130824203414.GD2960@elie.Belkin>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 16 quoted lines
> Kacper Kornet wrote:
>
>> Signed-off-by: Kacper Kornet <draenog@pld-linux.org>
>
> Thanks.
>
> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
>
> Here's a style cleanup on top.
>
> -- >8 --
> Subject: reset test: modernize style
>
> Avoid command substitution and pipes to ensure that the exit status
> from each git command is tested (and in particular that any segfaults
> are caught).
Makes sense.

The change to the one that feeds 'y' to "reset -p" may be a bit too pedantic, as we are not in the business of testing "echo y", though.

Show 73 quoted lines
> Maintain the test setup (no commits, one file named "a", another named
> "b") even after the last test, to make it easier to rearrange tests or
> add new tests after the last in the future.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
>  t/t7106-reset-unborn-branch.sh | 31 ++++++++++++++++++++++++-------
>  1 file changed, 24 insertions(+), 7 deletions(-)
>
> diff --git a/t/t7106-reset-unborn-branch.sh b/t/t7106-reset-unborn-branch.sh
> index 499cd88c..af00ab4d 100755
> --- a/t/t7106-reset-unborn-branch.sh
> +++ b/t/t7106-reset-unborn-branch.sh
> @@ -11,7 +11,10 @@ test_expect_success 'setup' '
>  test_expect_success 'reset' '
>  	git add a b &&
>  	git reset &&
> -	test "$(git ls-files)" = ""
> +
> +	>expect &&
> +	git ls-files >actual &&
> +	test_cmp expect actual
>  '
>  
>  test_expect_success 'reset HEAD' '
> @@ -24,28 +27,42 @@ test_expect_success 'reset $file' '
>  	rm .git/index &&
>  	git add a b &&
>  	git reset a &&
> -	test "$(git ls-files)" = "b"
> +
> +	echo b >expect &&
> +	git ls-files >actual &&
> +	test_cmp expect actual
>  '
>  
>  test_expect_success PERL 'reset -p' '
>  	rm .git/index &&
>  	git add a &&
> -	echo y | git reset -p &&
> -	test "$(git ls-files)" = ""
> +	echo y >yes &&
> +	git reset -p <yes &&
> +
> +	>expect &&
> +	git ls-files >actual &&
> +	test_cmp expect actual
>  '
>  
>  test_expect_success 'reset --soft is a no-op' '
>  	rm .git/index &&
>  	git add a &&
> -	git reset --soft
> -	test "$(git ls-files)" = "a"
> +	git reset --soft &&
> +
> +	echo a >expect &&
> +	git ls-files >actual &&
> +	test_cmp expect actual
>  '
>  
>  test_expect_success 'reset --hard' '
>  	rm .git/index &&
>  	git add a &&
> +	test_when_finished "echo a >a" &&
>  	git reset --hard &&
> -	test "$(git ls-files)" = "" &&
> +
> +	>expect &&
> +	git ls-files >actual &&
> +	test_cmp expect actual &&
>  	test_path_is_missing a
>  '
Previous: Jonathan NiederNext: Jonathan Nieder
Message 10 of 12 in “Fixes for tests run without perl”
  1. 0/3 Fixes for tests run without perlKacper Kornet, Aug 24, 2013
  2. 1/3 Make test "using invalid commit with -C" more strictKacper Kornet, Aug 24, 2013
  3. Jonathan NiederAug 24, 2013
  4. Junio C HamanoAug 25, 2013
  5. Jonathan NiederAug 25, 2013
  6. 2/3 t/t3701-add-interactive.sh: Add PERL prerequisiteKacper Kornet, Aug 24, 2013
  7. Jonathan NiederAug 24, 2013
  8. 3/3 t/t7106-reset-unborn-branch.sh: Add PERL prerequisiteKacper Kornet, Aug 24, 2013
  9. Jonathan NiederAug 24, 2013
  10. Junio C HamanoAug 25, 2013
  11. Jonathan NiederAug 25, 2013
  12. Jonathan NiederAug 24, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.