Subject: Re: [PATCH v3 2/4] Revert and amend "test-lib-functions: assert correct parameter count"

From: Junio C Hamano <[email-masked]>
Date: Thu, 29 Apr 2021 12:59:10 +0900

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> The goal here is to get rid of the verbosity of having e.g. a "test 2
> -ne 2" line for every "test_cmp". We use "$@" as an argument to "test"
> to intentionally feed the "test" operator too many arguments if the
> functions are called with too many arguments, thus piggy-backing on it
> to check the number of arguments we get.
>
> Before this for each test_cmp invocation we'd emit:
>
>     + test_cmp expect actual
>     + test 2 -ne 2
>     + eval diff -u "$@"
>     + diff -u expect actual

Quite honestly, I do not see what's bad about that and am not all
that sympathetic to the cause behind this series.

The developer is asking to debug the test script by passing '-x',
and see where the test script is broken.  Especially since ...

> Now we'll get just:
>     + test_cmp expect actual
>     + eval diff -u "$@"
>     + diff -u expect actual

... we are not removing the 'eval diff -u "$@"' line, I do not think
how a few extra trace output lines coming from sanity check hurts
all that much.  It is worth paying for to have such basic sanity
checks expressed in a more natural way (than "oh, this hack would
not work when 'one -a two' is used as a path"), I would think.

Thanks.