Re: [PATCH 4/6] merge hook tests: fix and update tests
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Mar 6, 2014, 22:11 UTC
- Message-ID
- <CAPig+cRXLQVcZFbawc=TzBAMqb3XwBFGZH1viMnTwtoqz6p-zA@mail.gmail.com>
- In-Reply-To
- <1394117424-29780-5-git-send-email-benoit.pierre@gmail.com>
On Thu, Mar 6, 2014 at 9:50 AM, Benoit Pierre <benoit.pierre@gmail.com> wrote:
Show 26 quoted lines
> - update 'no editor' hook test and add 'editor' hook test
> - reset tree at the beginning of failing hook tests to avoid failures
> due to an unclean tree after running a previous test
>
> Signed-off-by: Benoit Pierre <benoit.pierre@gmail.com>
> ---
> t/t7505-prepare-commit-msg-hook.sh | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh
> index 3573751..ae7b2db 100755
> --- a/t/t7505-prepare-commit-msg-hook.sh
> +++ b/t/t7505-prepare-commit-msg-hook.sh
> @@ -141,7 +141,19 @@ test_expect_success 'with hook (merge)' '
> git commit -m other &&
> git checkout - &&
> git merge other &&
> - test "`git log -1 --pretty=format:%s`" = merge
> + test "`git log -1 --pretty=format:%s`" = "merge (no editor)"
> +'
> +
> +test_expect_success 'with hook and editor (merge)' '
> +
> + head=`git rev-parse HEAD` &&
> + git checkout -B other HEAD@{1} &&
> + echo "more" >> file &&Drop space after >>.
> + git add file && > + git commit -m other && > + git checkout - &&
If one of the commands above this point fails, then "git checkout -" will never be invoked, and the working tree may be left in a state inconsistent with what following tests expect. Instead, perhaps use test_when_finished to perform the restorative "git checkout ...".
Show 36 quoted lines
> + env GIT_EDITOR="\"\$FAKE_EDITOR\"" git merge -e other &&
> + test "`git log -1 --pretty=format:%s`" = "merge"
> '
>
> cat > "$HOOK" <<'EOF'
> @@ -151,6 +163,7 @@ EOF
>
> test_expect_success 'with failing hook' '
>
> + git reset --hard &&
> head=`git rev-parse HEAD` &&
> echo "more" >> file &&
> git add file &&
> @@ -160,6 +173,7 @@ test_expect_success 'with failing hook' '
>
> test_expect_success 'with failing hook (--no-verify)' '
>
> + git reset --hard &&
> head=`git rev-parse HEAD` &&
> echo "more" >> file &&
> git add file &&
> @@ -169,6 +183,7 @@ test_expect_success 'with failing hook (--no-verify)' '
>
> test_expect_success 'with failing hook (merge)' '
>
> + git reset --hard &&
> git checkout -B other HEAD@{1} &&
> echo "more" >> file &&
> git add file &&
> --
> 1.9.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html