Re: [RFC PATCH v2 05/11] notes: clean up t3301
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 16, 2010, 23:52 UTC
- Message-ID
- <7vd40420yb.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <2c7b0e51f7d299a481b62cbe4f728ff20e4651ab.1266361759.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 23 quoted lines
> 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 <trast@student.ethz.ch>
> ---
> 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:
Show 6 quoted lines
> cat > expect << EOF > -c18dc024e14f08d18d14eea0d747ff692d66d6a3 1584215f1d29c65e99c6c6848626553fdd07fd75 > -c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 268048bfb8a1fb38e703baceb8ab235421bf80c5 > +c9c6af7f78bc47490dbf3e822cf2f3c24d4b9061 7a4ca6ee52a974a66cbaa78e33214535dff1d691 > +c18dc024e14f08d18d14eea0d747ff692d66d6a3 d07d62e5208f22eb5695e7eb47667dc8b9860290 > EOF
it might be easier to do without such a niceness.