git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] t3303/t9301: make `notes` tests less brittle

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Aug 30, 2021, 07:21 UTC
Message-ID
<20210830072118.91921-3-sunshine@sunshineco.com>
In-Reply-To
<20210830072118.91921-1-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>
---
 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 d47ce00f69..abffa10564 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 1ae4d7c0d3..123323b2bb 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.153.gba50c8fa24
Previous: Eric SunshineNext: Eric Sunshine
Message 5 of 25 in “suppress trailing whitespace on empty "notes" lines”
  1. 0/3 suppress trailing whitespace on empty "notes" linesEric Sunshine, Aug 30, 2021
  2. 1/3 t3301: tolerate minor notes-related presentation changesEric Sunshine, Aug 30, 2021
  3. Junio C HamanoAug 30, 2021
  4. Eric SunshineAug 30, 2021
  5. 2/3 t3303/t9301: make `notes` tests less brittleEric Sunshine, Aug 30, 2021
  6. 3/3 notes: don't indent empty linesEric Sunshine, Aug 30, 2021
  7. Junio C HamanoAug 30, 2021
  8. Eric SunshineAug 30, 2021
  9. Junio C HamanoAug 30, 2021
  10. Eric SunshineAug 30, 2021
  11. Eric SunshineSep 10, 2021
  12. Eric SunshineSep 10, 2021
  13. Junio C HamanoSep 10, 2021
  14. Eric SunshineSep 10, 2021
  15. Ævar Arnfjörð BjarmasonSep 11, 2021
  16. Eric SunshineSep 11, 2021
  17. Ævar Arnfjörð BjarmasonSep 11, 2021
  18. Eric SunshineSep 12, 2021
  19. Junio C HamanoSep 12, 2021
  20. 0/2 suppress trailing whitespace on empty "notes" linesÆvar Arnfjörð Bjarmason, Aug 30, 2021
  21. 1/2 t3303/t9301: make `notes` tests less brittleÆvar Arnfjörð Bjarmason, Aug 30, 2021
  22. 2/2 notes: don't indent empty linesÆvar Arnfjörð Bjarmason, Aug 30, 2021
  23. Eric SunshineAug 30, 2021
  24. Eric SunshineAug 30, 2021
  25. Junio C HamanoAug 30, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.