Re: [PATCH 4/5] test-tool: test refspec input/output
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Apr 6, 2021, 11:13 UTC
- Message-ID
- <0c3989de-8fe9-b812-edb3-cab1e7227505@gmail.com>
- In-Reply-To
- <CAPig+cTCeED-Q_64+S5MDVFjCJdnCqYXWNS2ZDWKm4Ehjn=VXw@mail.gmail.com>
On 4/5/2021 1:52 PM, Eric Sunshine wrote:
Show 47 quoted lines
> On Mon, Apr 5, 2021 at 9:04 AM Derrick Stolee via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
>> Add a new test-helper, 'test-tool refspec', that currently reads stdin
>> line-by-line and translates the refspecs using the parsing logic of
>> refspec_item_init() and writes them to output.
>> [...]
>> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
>> ---
>> diff --git a/t/helper/test-refspec.c b/t/helper/test-refspec.c
>> @@ -0,0 +1,39 @@
>> +int cmd__refspec(int argc, const char **argv)
>> +{
>> + struct strbuf line = STRBUF_INIT;
>> + [...]
>> + return 0;
>> +}
>
> Leaking `strbuf line` here. Yes, I realize that the function is
> returning and test-tool exiting immediately after this, so not a big
> deal, but it's easy to do this correctly by releasing the strbuf, thus
> setting good precedence for people who might use this as a template
> for new test-tool functions they add in the future.
>
>> diff --git a/t/t5511-refspec.sh b/t/t5511-refspec.sh
>> @@ -93,4 +93,45 @@ test_refspec fetch "refs/heads/${good}"
>> +test_expect_success 'test input/output round trip' '
>> + cat >input <<-\EOF &&
>> + +refs/heads/*:refs/remotes/origin/*
>> + refs/heads/*:refs/remotes/origin/*
>> + refs/heads/main:refs/remotes/frotz/xyzzy
>> + :refs/remotes/frotz/deleteme
>> + ^refs/heads/secrets
>> + refs/heads/secret:refs/heads/translated
>> + refs/heads/secret:heads/translated
>> + refs/heads/secret:remotes/translated
>> + secret:translated
>> + refs/heads/*:remotes/xxy/*
>> + refs/heads*/for-linus:refs/remotes/mine/*
>> + 2e36527f23b7f6ae15e6f21ac3b08bf3fed6ee48:refs/heads/fixed
>> + HEAD
>> + @
>> + :
>> + EOF
>
> Over-indented heredoc body. It is customary[1] in this codebase for
> the body and EOF to have the same indentation as the command which
> starts the heredoc.Good catches. Thanks! -Stolee