Re: [PATCH 08/10] t: forbid piping into 'test_i18ngrep'
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Jan 26, 2018, 18:51 UTC
- Message-ID
- <CAM0VKjn401p4fbF-mJrpaQrgOHGHZ1HtRNx9n+CV+jn4n2a1Uw@mail.gmail.com>
- In-Reply-To
- <xmqq1sic8omp.fsf@gitster.mtv.corp.google.com>
On Fri, Jan 26, 2018 at 7:24 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 23 quoted lines
> SZEDER Gábor <szeder.dev@gmail.com> writes:
>
>> See two of the previous patches for the only such cases we had in our
>> test suite. However, reliably preventing this antipattern is arguably
>> more important than supporting these cases, which can be worked around
>> by only minor inconveniences.
>
> I am not sure if that inconveniences will be minor. Is this too
> contrived an example, for example?
>
> check () {
> pattern=$1 file=$2 script=./runme
>
> test_i18ngrep "$pattern" "$file" &&
> write_script "$script" &&
> test_expect_success "check $pattern" '
> "$script"
> '
> }
>
> check foo file <<-EOF
> ... test script comes here ...
> EOFWith 'test_i18ngrep' outside the 'test_expect_success' block!? Definitely too contrived. :)
OTOH, what about flipping the order of 'test_i18ngrep' and 'write_script'? If we can't do that, then I wonder what the reason might be that is not too contrived.
Show 21 quoted lines
>>
>> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
>> ---
>> t/test-lib-functions.sh | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
>> index 92ed02937..e381d50d0 100644
>> --- a/t/test-lib-functions.sh
>> +++ b/t/test-lib-functions.sh
>> @@ -719,6 +719,10 @@ test_i18ncmp () {
>> # under GETTEXT_POISON this pretends that the command produced expected
>> # results.
>> test_i18ngrep () {
>> + ( read line ) &&
>> + error "bug in the test script: data on test_i18ngrep's stdin;" \
>> + "perhaps a git command's output is piped into it?"
>> +
>> if test -n "$GETTEXT_POISON"
>> then
>> : # pretend success