From: Ævar Arnfjörð Bjarmason Date: Mon, 30 Aug 2021 10:47:13 GMT Subject: [RFC PATCH v2 1/2] t3303/t9301: make `notes` tests less brittle Message-ID: In-Reply-To: From: Eric Sunshine 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 Signed-off-by: Ævar Arnfjörð Bjarmason --- 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 < actual && + GIT_NOTES_REF=refs/notes/test git log --format="tformat:%B%N" >actual && test_cmp expect actual ' -- 2.33.0.737.g0eefde7d76