Re: [PATCH v2] t9116: avoid using pipes
- From
Shanthanu <shanthanu.s.rai9@gmail.com>
- Date
- Mar 25, 2020, 14:00 UTC
- Message-ID
- <4b40a756-c32f-64ad-1e1d-4e31804d8295@gmail.com>
- In-Reply-To
- <CAP8UFD2Uu-dPJcZB--T7k0tMuXc0iVeqnMUn3Y_x+3iaFf9xFQ@mail.gmail.com>
On 25/03/20 12:04 am, Christian Couder wrote:
Show 14 quoted lines
> On Tue, Mar 24, 2020 at 10:36 AM Shanthanu <shanthanu.s.rai9@gmail.com> wrote: >> Commit c6f44e1da5 (t9813: avoid using pipes, 2017-01-04) recommends to >> avoid using pipes, since the exit code of upstream in the pipe is >> ignored. Hence, redirect the output to a file and parse that file. >> >> Commit de26f02db1 (t9001, t9116: avoid pipes, 2020-02-14) noted that >> this also allows easy debugging in case the test fails, since the file >> will be left on disk and can be manually inspected. >> >> Signed-off-by: Shanthanu <shanthanu.s.rai9@gmail.com> > We usually ask for a legal name in a format similar to "<Firstname> > <MaybeMiddleNameInitial> <Lastname>" where <MaybeMiddleNameInitial> > can be omitted. The name should also match what is in the "From:" > field of the emails you send.
Okay, I will keep that in mind.
Show 20 quoted lines
>> --- >> t/t9116-git-svn-log.sh | 53 +++++++++++++++++++++++++++++++----------- >> 1 file changed, 39 insertions(+), 14 deletions(-) >> >> diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh >> index 0a9f1ef366..56d68e4aed 100755 >> --- a/t/t9116-git-svn-log.sh >> +++ b/t/t9116-git-svn-log.sh >> @@ -61,12 +61,16 @@ printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4 >> >> test_expect_success 'test ascending revision range' " >> git reset --hard origin/trunk && >> - git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 - >> + git svn log -r 1:4 >out && >> + grep '^r[0-9]' out | cut -d'|' -f1 >actual && >> + test_cmp expected-range-r1-r2-r4 actual >> " > It seems that the code that your patch changes is repeated a lot in > this test script. I wonder if it would be better to write a shell > function to avoid those repetitions.
Oh yeah, that would be better. I will add a function. Just clarifying, the function should run the git, grep, cut and test_cmp commands?
Also, could you suggest an appropriate name for this function?