git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Eric Sunshine" <sunshine@sunshineco.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle
Date: Mon, 30 Aug 2021 12:47:13 +0200	[thread overview]
Message-ID: <RFC-patch-v2-1.2-5a1ddd30859-20210830T103913Z-avarab@gmail.com> (raw)
In-Reply-To: <RFC-cover-v2-0.2-00000000000-20210830T103913Z-avarab@gmail.com>

From: Eric Sunshine <sunshine@sunshineco.com>

These tests care about whether intended notes-related functionality
occurred, but they check for the expected result in a brittle way by
consulting the default output of `git log` which is intended for human,
not machine, consumption. Make the tests more robust by requesting the
desired information in a stable machine-consumable format.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t3303-notes-subtrees.sh    | 13 ++++++++-----
 t/t9301-fast-import-notes.sh | 36 +++++++++++++++++++-----------------
 2 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/t/t3303-notes-subtrees.sh b/t/t3303-notes-subtrees.sh
index d47ce00f694..abffa105645 100755
--- a/t/t3303-notes-subtrees.sh
+++ b/t/t3303-notes-subtrees.sh
@@ -171,13 +171,16 @@ INPUT_END
 }
 
 verify_concatenated_notes () {
-	git log | grep "^    " > output &&
+	git log --format="tformat:%B%N" >output &&
 	i=$number_of_commits &&
 	while [ $i -gt 0 ]; do
-		echo "    commit #$i" &&
-		echo "    first note for commit #$i" &&
-		echo "    " &&
-		echo "    second note for commit #$i" &&
+		cat <<-EOF &&
+		commit #$i
+		first note for commit #$i
+
+		second note for commit #$i
+
+		EOF
 		i=$(($i-1));
 	done > expect &&
 	test_cmp expect output
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index 1ae4d7c0d37..123323b2bbb 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -259,29 +259,31 @@ EOF
 
 INPUT_END
 
-whitespace="    "
-
 cat >expect <<EXPECT_END
-    fourth commit
-    pre-prefix of note for fourth commit
-$whitespace
-    prefix of note for fourth commit
-$whitespace
-    third note for fourth commit
-    third commit
-    prefix of note for third commit
-$whitespace
-    third note for third commit
-    second commit
-    third note for second commit
-    first commit
-    third note for first commit
+fourth commit
+pre-prefix of note for fourth commit
+
+prefix of note for fourth commit
+
+third note for fourth commit
+
+third commit
+prefix of note for third commit
+
+third note for third commit
+
+second commit
+third note for second commit
+
+first commit
+third note for first commit
+
 EXPECT_END
 
 test_expect_success 'add concatenation notes with M command' '
 
 	git fast-import <input &&
-	GIT_NOTES_REF=refs/notes/test git log | grep "^    " > actual &&
+	GIT_NOTES_REF=refs/notes/test git log --format="tformat:%B%N" >actual &&
 	test_cmp expect actual
 
 '
-- 
2.33.0.737.g0eefde7d76


  reply	other threads:[~2021-08-30 10:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30  7:21 [PATCH 0/3] suppress trailing whitespace on empty "notes" lines Eric Sunshine
2021-08-30  7:21 ` [PATCH 1/3] t3301: tolerate minor notes-related presentation changes Eric Sunshine
2021-08-30 17:09   ` Junio C Hamano
2021-08-30 18:16     ` Eric Sunshine
2021-08-30  7:21 ` [PATCH 2/3] t3303/t9301: make `notes` tests less brittle Eric Sunshine
2021-08-30  7:21 ` [PATCH 3/3] notes: don't indent empty lines Eric Sunshine
2021-08-30 17:10   ` Junio C Hamano
2021-08-30 17:41     ` Eric Sunshine
2021-08-30 17:56       ` Junio C Hamano
2021-08-30 18:04         ` Eric Sunshine
2021-09-10  5:18           ` Eric Sunshine
2021-09-10  5:21             ` Eric Sunshine
2021-09-10 18:33             ` Junio C Hamano
2021-09-10 20:31               ` Eric Sunshine
2021-09-11  1:53                 ` Ævar Arnfjörð Bjarmason
2021-09-11  9:15                   ` Eric Sunshine
2021-09-11 10:39                     ` Ævar Arnfjörð Bjarmason
2021-09-12  5:53                       ` Eric Sunshine
2021-09-12  8:22                         ` Junio C Hamano
2021-08-30 10:47 ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Ævar Arnfjörð Bjarmason
2021-08-30 10:47   ` Ævar Arnfjörð Bjarmason [this message]
2021-08-30 10:47   ` [RFC PATCH v2 2/2] notes: don't indent empty lines Ævar Arnfjörð Bjarmason
2021-08-30 16:45   ` [RFC PATCH v2 0/2] suppress trailing whitespace on empty "notes" lines Eric Sunshine
2021-08-30 16:50     ` Eric Sunshine
2021-08-30 17:04   ` Junio C Hamano

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=RFC-patch-v2-1.2-5a1ddd30859-20210830T103913Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --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).