Re: [PATCH v3 3/5] stash: add test for the create command line arguments

2017-02-11 Thread Thomas Gummerer
On 02/06, Jeff King wrote:
> On Sun, Feb 05, 2017 at 08:26:40PM +, Thomas Gummerer wrote:
> 
> > +test_expect_success 'create stores correct message' '
> > +   >foo &&
> > +   git add foo &&
> > +   STASH_ID=$(git stash create "create test message") &&
> > +   echo "On master: create test message" >expect &&
> > +   git show --pretty=%s ${STASH_ID} | head -n1 >actual &&
> > +   test_cmp expect actual
> > +'
> 
> This misses failure exit codes from "git show" because it's on the left
> side of a pipe. Perhaps "git show -s" or "git log -1" would get you the
> same output without needing "head" (and saving a process and the time
> spent generating the diff, as a bonus).
> 
> Ditto in the other tests from this patch and later ones.

Good catch, will fix.

> -Peff


Re: [PATCH v3 3/5] stash: add test for the create command line arguments

2017-02-06 Thread Jeff King
On Sun, Feb 05, 2017 at 08:26:40PM +, Thomas Gummerer wrote:

> +test_expect_success 'create stores correct message' '
> + >foo &&
> + git add foo &&
> + STASH_ID=$(git stash create "create test message") &&
> + echo "On master: create test message" >expect &&
> + git show --pretty=%s ${STASH_ID} | head -n1 >actual &&
> + test_cmp expect actual
> +'

This misses failure exit codes from "git show" because it's on the left
side of a pipe. Perhaps "git show -s" or "git log -1" would get you the
same output without needing "head" (and saving a process and the time
spent generating the diff, as a bonus).

Ditto in the other tests from this patch and later ones.

-Peff


[PATCH v3 3/5] stash: add test for the create command line arguments

2017-02-05 Thread Thomas Gummerer
Currently there is no test showing the expected behaviour of git stash
create's command line arguments.  Add a test for that to show the
current expected behaviour and to make sure future refactorings don't
break those expectations.

Signed-off-by: Thomas Gummerer 
---
 t/t3903-stash.sh | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 0171b824c9..21cb70dc74 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -784,4 +784,22 @@ test_expect_success 'push -m shows right message' '
test_cmp expect actual
 '
 
+test_expect_success 'create stores correct message' '
+   >foo &&
+   git add foo &&
+   STASH_ID=$(git stash create "create test message") &&
+   echo "On master: create test message" >expect &&
+   git show --pretty=%s ${STASH_ID} | head -n1 >actual &&
+   test_cmp expect actual
+'
+
+test_expect_success 'create with multiple arguments for the message' '
+   >foo &&
+   git add foo &&
+   STASH_ID=$(git stash create test untracked) &&
+   echo "On master: test untracked" >expect &&
+   git show --pretty=%s ${STASH_ID} | head -n1 >actual &&
+   test_cmp expect actual
+'
+
 test_done
-- 
2.12.0.rc0.208.g81c5d00b20.dirty