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