git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Charvi Mendiratta <charvi077@gmail.com>,
	Git List <git@vger.kernel.org>,
	Christian Couder <christian.couder@gmail.com>,
	Taylor Blau <me@ttaylorr.com>,
	Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator
Date: Wed, 21 Oct 2020 22:55:58 -0700	[thread overview]
Message-ID: <xmqqh7qmolch.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: xmqq36264xx5.fsf@gitster.c.googlers.com

Junio C Hamano <gitster@pobox.com> writes:

> Also, this is outside any test_expect_*, which is unusual in
> modernized test scripts.  There are many other instances of
> preparing expected output outside test_expect_* in this file,
> so we may need another patch to clean them up.
>
> For now, within the context of this patch, let's just fix the space
> after the << here-doc redirection operator, as you spotted.  The
> attached I'll squash into this patch.

And the other clean-up patch would look like this.

--- >8 ---
Subject: t7102: prepare expected output inside test_expect_* block

That way we can notice if there is a breakage/bug in the parts of
the test that prepare the expected outcome, which is how modern
tests are arranged.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t7102-reset.sh | 244 +++++++++++++++++++++++++++----------------------------
 1 file changed, 121 insertions(+), 123 deletions(-)

diff --git c/t/t7102-reset.sh w/t/t7102-reset.sh
index 07acaa2beb..821e8bb94d 100755
--- c/t/t7102-reset.sh
+++ w/t/t7102-reset.sh
@@ -82,15 +82,15 @@ test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' '
 	test_i18ncmp .expected .actual
 '
 
->.diff_expect
->.cached_expect
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-EOF
-
 test_expect_success 'giving a non existing revision should fail' '
+	>.diff_expect &&
+	>.cached_expect &&
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	EOF
+
 	test_must_fail git reset aaaaaa &&
 	test_must_fail git reset --mixed aaaaaa &&
 	test_must_fail git reset --soft aaaaaa &&
@@ -191,38 +191,38 @@ test_expect_success 'resetting to HEAD with no changes should succeed and do not
 		check_changes $head5
 '
 
->.diff_expect
-cat >.cached_expect <<EOF
-diff --git a/secondfile b/secondfile
-index $head5p1s..$head5s 100644
---- a/secondfile
-+++ b/secondfile
-@@ -1 +1,2 @@
--2nd file
-+1st line 2nd file
-+2nd line 2nd file
-EOF
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-EOF
 test_expect_success '--soft reset only should show changes in diff --cached' '
+	>.diff_expect &&
+	cat >.cached_expect <<-EOF &&
+	diff --git a/secondfile b/secondfile
+	index $head5p1s..$head5s 100644
+	--- a/secondfile
+	+++ b/secondfile
+	@@ -1 +1,2 @@
+	-2nd file
+	+1st line 2nd file
+	+2nd line 2nd file
+	EOF
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	EOF
 	git reset --soft HEAD^ &&
 	check_changes $head5p1 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
 			$head5
 '
 
->.diff_expect
->.cached_expect
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-3rd line 2nd file
-EOF
 test_expect_success 'changing files and redo the last commit should succeed' '
+	>.diff_expect &&
+	>.cached_expect &&
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	3rd line 2nd file
+	EOF
 	echo "3rd line 2nd file" >>secondfile &&
 	git commit -a -C ORIG_HEAD &&
 	head4=$(git rev-parse --verify HEAD) &&
@@ -231,54 +231,54 @@ test_expect_success 'changing files and redo the last commit should succeed' '
 			$head5
 '
 
->.diff_expect
->.cached_expect
-cat >.cat_expect <<EOF
-first:
-1st file
-2nd line 1st file
-second:
-2nd file
-EOF
 test_expect_success '--hard reset should change the files and undo commits permanently' '
+	>.diff_expect &&
+	>.cached_expect &&
+	cat >.cat_expect <<-\EOF &&
+	first:
+	1st file
+	2nd line 1st file
+	second:
+	2nd file
+	EOF
 	git reset --hard HEAD~2 &&
 	check_changes $head5p2 &&
 	test "$(git rev-parse ORIG_HEAD)" = \
 			$head4
 '
 
->.diff_expect
-cat >.cached_expect <<EOF
-diff --git a/first b/first
-deleted file mode 100644
-index $head5p2f..0000000
---- a/first
-+++ /dev/null
-@@ -1,2 +0,0 @@
--1st file
--2nd line 1st file
-diff --git a/second b/second
-deleted file mode 100644
-index $head5p1s..0000000
---- a/second
-+++ /dev/null
-@@ -1 +0,0 @@
--2nd file
-diff --git a/secondfile b/secondfile
-new file mode 100644
-index 0000000..$head5s
---- /dev/null
-+++ b/secondfile
-@@ -0,0 +1,2 @@
-+1st line 2nd file
-+2nd line 2nd file
-EOF
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-EOF
 test_expect_success 'redoing changes adding them without commit them should succeed' '
+	>.diff_expect &&
+	cat >.cached_expect <<-EOF &&
+	diff --git a/first b/first
+	deleted file mode 100644
+	index $head5p2f..0000000
+	--- a/first
+	+++ /dev/null
+	@@ -1,2 +0,0 @@
+	-1st file
+	-2nd line 1st file
+	diff --git a/second b/second
+	deleted file mode 100644
+	index $head5p1s..0000000
+	--- a/second
+	+++ /dev/null
+	@@ -1 +0,0 @@
+	-2nd file
+	diff --git a/secondfile b/secondfile
+	new file mode 100644
+	index 0000000..$head5s
+	--- /dev/null
+	+++ b/secondfile
+	@@ -0,0 +1,2 @@
+	+1st line 2nd file
+	+2nd line 2nd file
+	EOF
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	EOF
 	git rm first &&
 	git mv second secondfile &&
 
@@ -288,46 +288,45 @@ test_expect_success 'redoing changes adding them without commit them should succ
 	check_changes $head5p2
 '
 
-cat >.diff_expect <<EOF
-diff --git a/first b/first
-deleted file mode 100644
-index $head5p2f..0000000
---- a/first
-+++ /dev/null
-@@ -1,2 +0,0 @@
--1st file
--2nd line 1st file
-diff --git a/second b/second
-deleted file mode 100644
-index $head5p1s..0000000
---- a/second
-+++ /dev/null
-@@ -1 +0,0 @@
--2nd file
-EOF
->.cached_expect
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-EOF
 test_expect_success '--mixed reset to HEAD should unadd the files' '
+	cat >.diff_expect <<-EOF &&
+	diff --git a/first b/first
+	deleted file mode 100644
+	index $head5p2f..0000000
+	--- a/first
+	+++ /dev/null
+	@@ -1,2 +0,0 @@
+	-1st file
+	-2nd line 1st file
+	diff --git a/second b/second
+	deleted file mode 100644
+	index $head5p1s..0000000
+	--- a/second
+	+++ /dev/null
+	@@ -1 +0,0 @@
+	-2nd file
+	EOF
+	>.cached_expect &&
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	EOF
 	git reset &&
 	check_changes $head5p2 &&
 	test "$(git rev-parse ORIG_HEAD)" = $head5p2
 '
 
->.diff_expect
->.cached_expect
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-EOF
 test_expect_success 'redoing the last two commits should succeed' '
+	>.diff_expect &&
+	>.cached_expect &&
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	EOF
 	git add secondfile &&
 	git reset --hard $head5p2 &&
-
 	git rm first &&
 	git mv second secondfile &&
 	git commit -a -m "remove 1st and rename 2nd" &&
@@ -340,15 +339,15 @@ test_expect_success 'redoing the last two commits should succeed' '
 	check_changes $head5
 '
 
->.diff_expect
->.cached_expect
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-3rd line in branch2
-EOF
 test_expect_success '--hard reset to HEAD should clear a failed merge' '
+	>.diff_expect &&
+	>.cached_expect &&
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	3rd line in branch2
+	EOF
 	git branch branch1 &&
 	git branch branch2 &&
 
@@ -366,14 +365,14 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' '
 	check_changes $head3
 '
 
->.diff_expect
->.cached_expect
-cat >.cat_expect <<EOF
-secondfile:
-1st line 2nd file
-2nd line 2nd file
-EOF
 test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' '
+	>.diff_expect &&
+	>.cached_expect &&
+	cat >.cat_expect <<-\EOF &&
+	secondfile:
+	1st line 2nd file
+	2nd line 2nd file
+	EOF
 	git reset --hard HEAD^ &&
 	check_changes $head5 &&
 
@@ -460,12 +459,11 @@ test_expect_success 'resetting an unmodified path is a no-op' '
 	git diff-index --cached --exit-code HEAD
 '
 
-cat >expect <<EOF
-Unstaged changes after reset:
-M	file2
-EOF
-
 test_expect_success '--mixed refreshes the index' '
+	cat >expect <<-\EOF &&
+	Unstaged changes after reset:
+	M	file2
+	EOF
 	echo 123 >> file2 &&
 	git reset --mixed HEAD >output &&
 	test_i18ncmp expect output

  parent reply	other threads:[~2020-10-22  5:56 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 17:57 [PATCH 0/5][Outreachy] modernizing the test scripts charvi-077
2020-10-15 17:57 ` [PATCH 1/5][Outreachy] t7101,t7102,t7201: modernize test formatting charvi-077
2020-10-16 13:07   ` Christian Couder
2020-10-15 17:57 ` [PATCH 2/5][Outreachy] t7102,t7201: remove unnecessary blank spaces in test body charvi-077
2020-10-15 17:57 ` [PATCH 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator charvi-077
2020-10-15 17:57 ` [PATCH 4/5][Outreachy] t7201: avoid using cd outside of subshells charvi-077
2020-10-15 17:57 ` [PATCH 5/5][Outreachy] t7201: place each command in its own line charvi-077
2020-10-16 12:54 ` [PATCH 0/5][Outreachy] modernizing the test scripts Christian Couder
2020-10-17  8:27   ` Charvi Mendiratta
2020-10-17  7:54 ` [PATCH v2 " Charvi Mendiratta
2020-10-17  7:54   ` [PATCH v2 1/5][Outreachy] t7101,t7102,t7201: modernize test formatting Charvi Mendiratta
2020-10-17  7:54   ` [PATCH v2 2/5][Outreachy] t7102,t7201: remove unnecessary blank spaces in test body Charvi Mendiratta
2020-10-17 15:13     ` Đoàn Trần Công Danh
2020-10-18  5:40       ` Charvi Mendiratta
2020-10-17  7:54   ` [PATCH v2 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator Charvi Mendiratta
2020-10-17  7:54   ` [PATCH v2 4/5][Outreachy] t7201: avoid using cd outside of subshells Charvi Mendiratta
2020-10-18 15:39     ` Phillip Wood
2020-10-19 12:55       ` Charvi Mendiratta
2020-10-19 13:46         ` Phillip Wood
2020-10-19 17:24           ` Charvi Mendiratta
2020-10-19 20:25             ` Taylor Blau
2020-10-20  5:38               ` Charvi Mendiratta
2020-10-20 20:09                 ` Taylor Blau
2020-10-20  9:13               ` Phillip Wood
2020-10-20 11:48                 ` Charvi Mendiratta
2020-10-17  7:54   ` [PATCH v2 5/5][Outreachy] t7201: place each command in its own line Charvi Mendiratta
2020-10-20 11:43   ` [PATCH v3 0/5][Outreachy] modernize the test scripts Charvi Mendiratta
2020-10-20 11:43     ` [PATCH v3 1/5][Outreachy] t7101,t7102,t7201: modernize test formatting Charvi Mendiratta
2020-10-20 11:43     ` [PATCH v3 2/5][Outreachy] t7102,t7201: remove unnecessary blank spaces in test body Charvi Mendiratta
2020-10-20 11:43     ` [PATCH v3 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator Charvi Mendiratta
2020-10-20 11:43     ` [PATCH v3 4/5][Outreachy] t7201: use 'git -C' to avoid subshell Charvi Mendiratta
2020-10-20 11:43     ` [PATCH v3 5/5][Outreachy] t7201: put each command on a seperate line Charvi Mendiratta
2020-10-20 12:11   ` [PATCH v4] t7201: put each command on a separate line Charvi Mendiratta
2020-10-20 20:13     ` Junio C Hamano
2020-10-20 20:15       ` Taylor Blau
2020-10-20 20:25         ` Junio C Hamano
2020-10-20 20:30           ` Taylor Blau
2020-10-20 21:00             ` Junio C Hamano
2020-10-21  7:14             ` Charvi Mendiratta
2020-10-20 20:19       ` Junio C Hamano
2020-10-21 13:16         ` Charvi Mendiratta
2020-10-21 12:48     ` [PATCH v5 0/5][Outreachy] modernize the test scripts Charvi Mendiratta
2020-10-21 12:48       ` [PATCH v5 1/5][Outreachy] t7101,t7102,t7201: modernize test formatting Charvi Mendiratta
2020-10-21 12:48       ` [PATCH v5 2/5][Outreachy] t7102,t7201: remove unnecessary blank spaces in test body Charvi Mendiratta
2020-10-21 12:48       ` [PATCH v5 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator Charvi Mendiratta
2020-10-21 17:20         ` Eric Sunshine
2020-10-22  5:44           ` Junio C Hamano
2020-10-22  5:53             ` Eric Sunshine
2020-10-22  5:55             ` Junio C Hamano [this message]
2020-10-22  6:04               ` Eric Sunshine
2020-10-22 17:35                 ` Junio C Hamano
2020-10-22  6:29             ` Charvi Mendiratta
2020-10-21 12:48       ` [PATCH v5 4/5][Outreachy] t7201: use 'git -C' to avoid subshell Charvi Mendiratta
2020-10-21 12:48       ` [PATCH v5 5/5][Outreachy] t7201: put each command on a separate line Charvi Mendiratta
2020-10-22  7:16       ` [PATCH v6 0/5][Outreachy] modernize test scripts Charvi Mendiratta
2020-10-22  7:16       ` [PATCH v6 1/5][Outreachy] t7101,t7102,t7201: modernize test formatting Charvi Mendiratta
2020-10-22  7:16       ` [PATCH v6 2/5][Outreachy] t7102,t7201: remove unnecessary blank spaces in test body Charvi Mendiratta
2020-10-22  7:16       ` [PATCH v6 3/5][Outreachy] t7102,t7201: remove whitespace after redirect operator Charvi Mendiratta
2020-10-22  7:16       ` [PATCH v6 4/5][Outreachy] t7201: use 'git -C' to avoid subshell Charvi Mendiratta
2020-10-22  7:16       ` [PATCH v6 5/5][Outreachy] t7201: put each command on a separate line Charvi Mendiratta

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

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

  git send-email \
    --in-reply-to=xmqqh7qmolch.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=charvi077@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    --cc=phillip.wood123@gmail.com \
    --cc=sunshine@sunshineco.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.
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 NNTP newsgroup(s).