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

Re: [PATCH 2/5] t6036, t6042: use test_line_count instead of wc -l

From
Elijah Newren <newren@gmail.com>
Date
May 26, 2018, 00:44 UTC
Message-ID
<CABPp-BEcTKaPPUOVqTRUAW+LBBySCK0dgx1J66hYB30yMasK_Q@mail.gmail.com>
In-Reply-To
<xmqqy3g8pm8g.fsf@gitster-ct.c.googlers.com>
On Thu, May 24, 2018 at 6:17 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
> SZEDER Gábor <szeder.dev@gmail.com> writes:
>
>>> -            test 2 = $(git ls-files -s | wc -l) &&
>>> -            test 2 = $(git ls-files -u | wc -l) &&
>>> -            test 2 = $(git ls-files -o | wc -l) &&
>>
>> Here 'git ls-files -o' should have listed two untracked files ...
>>
>>> +            git ls-files -s >out &&
>>> +            test_line_count = 2 out &&
>>> +            git ls-files -u >out &&
>>> +            test_line_count = 2 out &&
>>> +            git ls-files -o >out &&
>>> +            test_line_count = 3 out &&
>>
>> ... but now you expect it to list three.  I was about to point out the
>> typo, but then noticed that you expect it to list one more untracked
>> file than before in all subsequent tests...  now that can't be just a
>> typo, can it?
>>
>> Please mention in the commit message that when using an intermediate
>> file to store the output, 'git ls-files -o' will list that file, too,
>> that's why the number of expected untracked files had to be adjusted;
>> so future readers won't have to figure this out themselves.
>
> I'd expect that a reader of the commit who cares enough to bother to
> wonder by looking at the patch and seeing that 2 became 3 would know
> why already.  And a reader of the resulting file would not know that
> the 3 used to be 2, and won't be helped by "we used to count to 2,
> now we have 'out' also counted" that much, especially in the commit
> log message.  What would help the latter would be to name which
> three paths we expect to see in the comment (or test against the
> exact list of paths, instead of using test_line_count).
>
>> An alternative to consider would be to add a .gitignore file in the
>> initial commit to ignore 'out', then the number of untracked files
>> don't have to be adjusted.
>
> I think that is a preferred solution that we've used in ls-files and
> status tests successfully.

...except that if we add a .gitignore to each initial commit (we use test_create_repo for nearly every test to keep them separable meaning we'd have to do this many times), then four lines above we have to adjust the number of expected tracked files. And, for it to work, we'd have to add an --exclude-standard flag to ls-files -o.

I can make that change if you both want it, but it seems like it's actually making it harder to follow the changes rather than easier.

Previous: Junio C HamanoNext: Elijah Newren
Message 8 of 11 in “Modernize some testcases for merge-recursive corner cases”
  1. 0/5 Modernize some testcases for merge-recursive corner casesElijah Newren, May 24, 2018
  2. 1/5 t6036, t6042: use test_create_repo to keep tests independentElijah Newren, May 24, 2018
  3. 2/5 t6036, t6042: use test_line_count instead of wc -lElijah Newren, May 24, 2018
  4. SZEDER GáborMay 24, 2018
  5. SZEDER GáborMay 24, 2018
  6. Elijah NewrenMay 24, 2018
  7. Junio C HamanoMay 25, 2018
  8. Elijah NewrenMay 26, 2018
  9. 4/5 t6036, t6042: prefer test_cmp to sequences of testElijah Newren, May 24, 2018
  10. 3/5 t6036, t6042: prefer test_path_is_file, test_path_is_missingElijah Newren, May 24, 2018
  11. 5/5 t6036: prefer test_when_finished to manual cleanup in following testElijah Newren, May 24, 2018

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.