Re: [PATCH 2/3] submodule tests: reset "trace.out" between "grep" invocations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 31, 2022 at 01:50:07PM +0100, Ævar Arnfjörð Bjarmason wrote:
> >>  	(
> >>  		cd downstream &&
> >>  		GIT_TRACE=$(pwd)/trace.out git fetch &&
> >>  		grep "1 tasks" trace.out &&
> >> +		>trace.out &&
> >> +
> >
> > I fail to see why these hunks are necessary. If we specify GIT_TRACE,
> > and don't have a test_must_fail around the execution, then why should we
> > feel obligated to clean up the trace.out after every execution?
>
> Because the trace file isn't clobbered by each git command that
> specifies GIT_TRACE, so these tests are basically doing:
>
> 	(echo foo; echo bar) >>trace &&
> 	grep foo trace &&
>
>         (echo bar) >>trace &&
> 	grep bar trace
>
> Now, it just so happens that the earlier command isn't echoing "bar" to
> the file, so this is currently working out.

Ah, nicely explained. This is new to me, since I thought the behavior of
both GIT_TRACE and GIT_TRACE2 was to clobber the file.

> But it's a bad pattern to be pretending as though you care about the
> last output (which was the intent of the test), when really what you're
> testing is the combined output of all preceding commands.
>
> This would also be a potenital landmine with "test_must_fail", just
> because the command failed we're not guaranteed to have written nothing
> to the log (and usually we'd get as far as to write something).

Yeah, both make sense, thanks.

Thanks,
Taylor



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux