git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Stefan Beller <sbeller@google.com>,
	git@vger.kernel.org, jan.palus@gmail.com
Subject: Re: [PATCH] t7406: correct test case for submodule-update initial population
Date: Wed, 22 Mar 2017 15:12:07 -0700	[thread overview]
Message-ID: <xmqq37e5hsg8.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170322215951.f4xbxehzvsd64c4y@sigill.intra.peff.net> (Jeff King's message of "Wed, 22 Mar 2017 17:59:51 -0400")

Jeff King <peff@peff.net> writes:

> Neither of those is true, but I think:
>
>   cat >expect <<-EOF &&
>   Execution of '\''false $submodulesha1'\'' failed in ...
>   EOF
>
> is safer and less surprising. The single-quote handling is unfortunate and
> ugly, but necessary to get them into the shell snippet in the first
> place. I notice the others tests in this script set up the expect file
> outside of a block. You could also do something like:
>
>   sq=\'
>   test_expect_success '...' '
> 	cat >expect <<-EOF
> 	Execution of ${sq}false $submodulesha1${sq} ...
>   '
>
> but I'm not sure if that is any more readable.

Yup, my eyes have long learned to coast over '\'' as an idiomatic
symbol, but I agree that it is harder to see until you get used to
it (and I do not think it is particularly useful skill to be able to
spot '\'' as a logical unit, either).  ${sq} thing may make it easier
to read but I think the one you did in the first quoted part in this
reply is good enough.

-- >8 --
Subject: t7406: correct test case for submodule-update initial population

There are three issues with the test:

* The syntax of the here-doc was wrong, such that the entire test was
  sucked into the here-doc, which is why the test succeeded successfully.

* The variable $submodulesha1 was not expanded as it was inside a quoted
  here text.  We do not want to quote EOF marker for this.

* The redirection from the git command to the output file for comparison
  was wrong as the -C operator from git doesn't apply to the redirect path.
  Also we're interested in stderr of that command.

Noticed-by: Jan Palus <jan.palus@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 t/t7406-submodule-update.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 8c086a429b..a70fe96ad6 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -425,11 +425,11 @@ test_expect_success 'submodule update - command in .git/config catches failure -
 '
 
 test_expect_success 'submodule update - command run for initial population of submodule' '
-	cat <<-\ EOF >expect
+	cat >expect <<-EOF &&
 	Execution of '\''false $submodulesha1'\'' failed in submodule path '\''submodule'\''
-	EOF &&
+	EOF
 	rm -rf super/submodule &&
-	test_must_fail git -C super submodule update >../actual &&
+	test_must_fail git -C super submodule update 2>actual &&
 	test_cmp expect actual &&
 	git -C super submodule update --checkout
 '


  parent reply	other threads:[~2017-03-22 22:13 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 17:35 EOF test fixes (t5615/t7004) Jan Palus
2017-03-22 18:28 ` EOF test fixes (t7030/t7406) Jan Palus
2017-03-22 18:47 ` EOF test fixes (t5615/t7004) Stefan Beller
2017-03-22 19:43 ` Junio C Hamano
2017-03-22 20:08 ` [PATCH 0/3] fix "here-doc" syntax errors Junio C Hamano
2017-03-22 20:08   ` [PATCH 1/3] t5615: fix a here-doc syntax error Junio C Hamano
2017-03-22 21:02     ` Jeff King
2017-03-22 20:08   ` [PATCH 2/3] t7406: fix here-doc syntax errors Junio C Hamano
2017-03-22 21:07     ` Jeff King
2017-03-22 21:32       ` Stefan Beller
2017-03-22 21:39         ` Jeff King
2017-03-22 21:49           ` [PATCH] t7406: correct test case for submodule-update initial population Stefan Beller
2017-03-22 21:59             ` Jeff King
2017-03-22 22:07               ` Stefan Beller
2017-03-22 22:09                 ` Jeff King
2017-03-22 22:14                 ` Jonathan Nieder
2017-03-22 22:12               ` Junio C Hamano [this message]
2017-03-22 22:24                 ` Jeff King
2017-03-22 22:28                   ` Stefan Beller
2017-03-22 21:34       ` [PATCH 2/3] t7406: fix here-doc syntax errors Junio C Hamano
2017-03-22 20:08   ` [PATCH 3/3] t7004, t7030: " Junio C Hamano
2017-03-22 21:10     ` Jeff King
2017-03-22 21:43       ` Santiago Torres
2017-03-22 22:04         ` Jeff King
2017-03-22 22:04       ` Junio C Hamano
2017-03-22 22:15         ` Santiago Torres
2017-03-22 22:22           ` Jeff King
2017-03-22 22:34             ` Santiago Torres
2017-03-22 22:41               ` Jeff King
2017-03-22 22:47                 ` Junio C Hamano
2017-03-22 22:51                 ` Santiago Torres
2017-03-23 22:00                   ` Junio C Hamano
2017-03-23 22:28                     ` Santiago Torres
2017-03-23 23:49                     ` Jeff King
2017-03-24 16:45                       ` Junio C Hamano
2017-03-24 16:49                         ` Jeff King
2017-03-24 18:00                           ` Jeff King
2017-03-24 18:04                           ` Junio C Hamano
2017-03-24 18:16                             ` Jeff King
2017-03-22 22:38             ` Junio C Hamano
2017-03-22 22:40   ` [PATCH 0/3] fix "here-doc" " Jan Palus
2017-03-23  2:12   ` [PATCH] tests: lint for run-away here-doc Junio C Hamano
2017-03-23  5:43     ` [PATCH v2] " Junio C Hamano
2017-03-24  1:29       ` Jonathan Nieder
2017-03-24  2:45         ` Junio C Hamano
2017-03-24  3:59       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq37e5hsg8.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jan.palus@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).