git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git Test Coverage Report (Mon. Dec 9)

From
Derrick Stolee <stolee@gmail.com>
Date
Dec 9, 2019, 20:17 UTC
Message-ID
<944d66f0-7745-b70f-bec8-1d3610e7b8d0@gmail.com>
In-Reply-To
<676dc5c1-5823-ac83-878b-995f3793bfb8@gmail.com>
On 12/9/2019 1:23 PM, Derrick Stolee wrote:
Show 51 quoted lines
> On 12/9/2019 1:10 PM, René Scharfe wrote:
>> Am 09.12.19 um 18:44 schrieb Derrick Stolee:
>>> On 12/9/2019 12:19 PM, Eric Sunshine wrote:
>>>> On Mon, Dec 9, 2019 at 12:11 PM René Scharfe <l.s.r@web.de> wrote:
>>>>> Am 09.12.19 um 16:36 schrieb Derrick Stolee:
>>>>>> René Scharfe  0bb313a5 xdiff: unignore changes in function context
>>>>>> xdiff/xemit.c
>>>>>> 0bb313a5 223)        xchp->i1 + xchp->chg1 <= s1 &&
>>>>>> 0bb313a5 224)        xchp->i2 + xchp->chg2 <= s2)
>>>>>> 0bb313a5 225) xchp = xchp->next;
>>>>>
>>>>> Hmm, line 223 *is* exercised by t4015.85.
>>>>
>>>> This, along with Dscho's[1] review of an earlier coverage report,
>>>> makes one wonder if there is some off-by-one error in the reporting
>>>> logic, such that it is reporting the wrong lines as not covered.
>>>
>>> This is definitely possible. I'll see if I can locate the bug in
>>> my report-generation code.
>>>
>>> However, line 222 is here [1]
>>>
>>> 	while (xchp != xch &&
>>>
>>> So if this is always false, then the rest of the while condition
>>> will not be tested, nor will the body (line 225: xchp = xchp->next;).
>>
>> 0bb313a5 also added lines 228 and 229, which are not in the report, so
>> xchp != xch must be true at least once (it is, in t4015.85).
>>
>> 222)				while (xchp != xch &&
>> 223)				       xchp->i1 + xchp->chg1 <= s1 &&
>> 224)				       xchp->i2 + xchp->chg2 <= s2)
>> 225)					xchp = xchp->next;
>> 226)
>> 227)				/* If so, show it after all. */
>> 228)				if (xchp != xch) {
>> 229)					xch = xchp;
> 
> Thanks for pointing out that context.
> 
> My guess is that gcov is marking the line as uncovered because the &&
> operator is on that line. I'm testing [1] by breaking style conventions
> and using the following:
> 
> 				while (xchp != xch
> 				       && xchp->i1 + xchp->chg1 <= s1
> 				       && xchp->i2 + xchp->chg2 <= s2)
> 					xchp = xchp->next;
> 
> [1] https://dev.azure.com/git/git/_build/results?buildId=1453
Confirmed:

target fork/test-gcov base e0522318ac56aeb88f14e72ba2db25912e9972de

Uncovered code in 'target' not in 'base' --------------------------------------------------------

xdiff/xemit.c ddd5ad00 224) && xchp->i2 + xchp->chg2 <= s2)

Commits introducing uncovered code: Derrick Stolee ddd5ad00 TEST: switch position of &&

For future reference: having the "&&" at the end of the line will mark the line as uncovered if the right-hand side of the && is uncovered. The same holds for other short-circuit operators.

Thanks, -Stolee

Previous: Derrick Stolee
Message 7 of 7 in “Git Test Coverage Report (Mon. Dec 9)”
  1. Derrick StoleeDec 9, 2019
  2. René ScharfeDec 9, 2019
  3. Eric SunshineDec 9, 2019
  4. Derrick StoleeDec 9, 2019
  5. René ScharfeDec 9, 2019
  6. Derrick StoleeDec 9, 2019
  7. Derrick StoleeDec 9, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.