From: Jonathan Nieder Date: Mon, 13 Oct 2014 16:10:22 GMT Subject: Re: [PATCH 2/3] t5304: use helper to report failure of "test foo = bar" Message-ID: <20141013161022.GA20520@google.com> In-Reply-To: <20141010061114.GB15277@peff.net> Jeff King wrote: > For small outputs, we sometimes use: > > test "$(some_cmd)" = "something we expect" > > instead of a full test_cmp. The downside of this is that > when it fails, there is no output at all from the script. There's another downside to that construct: it loses the exit status from some_cmd. [...] > --- a/t/t5304-prune.sh > +++ b/t/t5304-prune.sh > @@ -13,7 +13,7 @@ add_blob() { > before=$(git count-objects | sed "s/ .*//") && > BLOB=$(echo aleph_0 | git hash-object -w --stdin) && > BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") && > - test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && > + verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && So ideally this would be something like: git count-objects >output && verbose test "$((1 + $before))" = "$(sed "s/ .*//" output)" && [...] > @@ -45,11 +45,11 @@ test_expect_success 'prune --expire' ' > > add_blob && > git prune --expire=1.hour.ago && > - test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && > + verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") && and likewise elsewhere in the file. Alternatively, maybe there could be a helper in the same spirit as test_cmp_rev? test_object_count () { git count-objects >output && sed "s/ .*//" output >count && printf "%s\n" "$1" >expect && test_cmp expect count } My two cents, Jonathan