[RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle
flat view
STALE1864d
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-08-30 10:47:26
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Eric Sunshine <redacted> 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 <redacted> Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> --- 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