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

Re: [PATCH 1/2] completion: refactor __gitcomp related tests

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Oct 30, 2012, 23:02 UTC
Message-ID
<CAMP44s0aN_FU+51huzdtEKOMaw2yhVy4d=jV6YHMeoCKDeqU8Q@mail.gmail.com>
In-Reply-To
<20121030224558.GN12052@goldbirke>
On Tue, Oct 30, 2012 at 11:45 PM, SZEDER Gábor <szeder@ira.uka.de> wrote:
Show 12 quoted lines
> On Mon, Oct 22, 2012 at 03:39:00AM +0200, Felipe Contreras wrote:
>> Lots of duplicated code!
>>
>> No functional changes.
>
> I'm not sure.
> I'm all for removing duplicated application code, but I'm usually more
> conservative when it comes to test code.  The more logic, the more
> possibility for bugs in tests.  So tests should be dead simple, even
> if that means some duplicated test code or the lack of convenience
> functions.
> While this might be considered just a matter of personal preference, ...

Fair enough, but my preference is different: test code should be the same as normal code; easy to maintain.

Show 14 quoted lines
>> +test_gitcomp ()
>> +{
>> +     sed -e 's/Z$//' > expected &&
>>       (
>>               local -a COMPREPLY &&
>> -             cur="--re" &&
>> -             __gitcomp "--dry-run --reuse-message= --reedit-message=
>> -                             --reset-author" &&
>> +             cur="$1" &&
>> +             shift &&
>> +             __gitcomp "$@" &&
>
> ... I was really puzzled by how __gitcomp() gets its arguments here,
> and had to think for a while to figure out why it's not broken.

You mean because "$@" is treated in a special way? Without that behavior I'm not sure many things would be possible :)

Anyway, I don't think we should make our life more difficult while maintaining test code... that's my opinion.

Cheers.
-- 
Felipe Contreras
Previous: SZEDER GáborNext: Felipe Contreras
Message 4 of 7 in “completion: test simplifications”
  1. 0/2 completion: test simplificationsFelipe Contreras, Oct 22, 2012
  2. 1/2 completion: refactor __gitcomp related testsFelipe Contreras, Oct 22, 2012
  3. SZEDER GáborOct 30, 2012
  4. Felipe ContrerasOct 30, 2012
  5. 2/2 completion: simplify __gitcomp test helperFelipe Contreras, Oct 22, 2012
  6. SZEDER GáborOct 30, 2012
  7. Felipe ContrerasOct 30, 2012

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.