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

2013-08-25 Thread Jonathan Nieder
Junio C Hamano wrote:

> 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.

Yeah, that's true.  Here's a patch for squashing in.

diff --git i/t/t7106-reset-unborn-branch.sh w/t/t7106-reset-unborn-branch.sh
index af00ab4d..bd28feba 100755
--- i/t/t7106-reset-unborn-branch.sh
+++ w/t/t7106-reset-unborn-branch.sh
@@ -12,9 +12,8 @@ test_expect_success 'reset' '
git add a b &&
git reset &&
 
-   >expect &&
git ls-files >actual &&
-   test_cmp expect actual
+   test_must_be_empty actual
 '
 
 test_expect_success 'reset HEAD' '
@@ -36,12 +35,10 @@ test_expect_success 'reset $file' '
 test_expect_success PERL 'reset -p' '
rm .git/index &&
git add a &&
-   echo y >yes &&
-   git reset -p expect &&
git ls-files >actual &&
-   test_cmp expect actual
+   test_must_be_empty actual
 '
 
 test_expect_success 'reset --soft is a no-op' '
@@ -60,9 +57,8 @@ test_expect_success 'reset --hard' '
test_when_finished "echo a >a" &&
git reset --hard &&
 
-   >expect &&
git ls-files >actual &&
-   test_cmp expect actual &&
+   test_must_be_empty actual &&
test_path_is_missing a
 '
 
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-08-24 Thread Junio C Hamano
Jonathan Nieder  writes:

> Kacper Kornet wrote:
>
>> Signed-off-by: Kacper Kornet 
>
> Thanks.
>
> Reviewed-by: Jonathan Nieder 
>
> 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.

> 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 
> ---
>  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  +
> + >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
>  '
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2013-08-24 Thread Jonathan Nieder
Kacper Kornet wrote:

> Signed-off-by: Kacper Kornet 

Thanks.

Reviewed-by: Jonathan Nieder 

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).

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 
---
 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 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
 '
 
-- 
1.8.4.rc4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html