Re: [RFC PATCH v2 05/11] notes: clean up t3301
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:48:17
Thomas Rast [off-list ref] writes:
quoted hunk
The existing tests handrolled test_commit, so use that instead. Unfortunately this changes all sha1's. Since we're not supposed to unneccessarily rely on them anyway, introduce a small helper that filters out the commit headers before comparing, and remove them from the expected outputs. Signed-off-by: Thomas Rast <redacted> --- t/t3301-notes.sh | 141 ++++++++++++++++++------------------------------------ 1 files changed, 46 insertions(+), 95 deletions(-)diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh index 90178f9..3fec7ae 100755 --- a/t/t3301-notes.sh +++ b/t/t3301-notes.sh@@ -7,6 +7,15 @@ test_description='Test commit notes' . ./test-lib.sh +strip_header () { + sed -i '/^\(commit\|tree\|parent\) /d' "$@" +}
I do not think -i is portable. Neither the use of ERE elements by quoting
them with backslash (which is a non-POSIX GNU extension IIRC).
You use this only for one side of test_cmp, so you should be able to do
something like:
strip_then_cmp () {
sed -e "/^[ctp][a-z]* $x40$/d" "$2" |
test_cmp "$1" -
}
But because you are using test_commit to freeze the time and get stable
output, and because you still have something like this anyway:
cat > expect << EOF -c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75 -c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5 +c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691 +c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290 EOF
it might be easier to do without such a niceness.