Subject: Re: [PATCH/RFC v4 07/10] send-email: reduce dependancies impact on parse_address_line

From: Matthieu Moy <[email-masked]>
Date: Fri, 19 Jun 2015 09:16:45 +0200

Remi Lespinet <[email-masked]> writes:

> Matthieu Moy <[email-masked]> writes:
>
>> Cool. Then almost all the work is done to get an automated test. Next
>> step would be to add the tests itself in the code. I would do that by
>> adding a hidden --selfcheck option to git send-email that would compare
>> Mail::Address->parse($string); and split_addrs($string); for all your
>> testcases, and die if they do not match. Then calling it from the
>> testsuite would be trivial.
>
> Ok, are there such "--selfcheck" options elsewhere?

Not as far as I know.

> If I understand it right, you want to put the tests inside the
> git-send-email script. I don't feel really good about that but I guess
> it's hard to test it otherwise...

Hmm, actually there is, I didn't look at the right places yesterday.
git-send-email.perl already does 'use Git;', and there's already a set
of unit-tests for Git.pm: t9700-perl-git.sh, which calls perl
"$TEST_DIRECTORY"/t9700/test.pl.

So, you can just add your code as a function in Git.pm and unit-tests in
t/t9700/test.pl.

> Also what will we do with the failing tests? Just discard them? I
> think there's two sort of failing test:
>
>  - When output provided by parse_address_ without Mail::Address
>    is better or has no impact at all on the code. Such as:

I'm not sure we can be "better" as long as we do use Mail::Address when
available. Any difference is potentially harmfull for the user because
it means that Git will have different behavior on different machines.

Perhaps this is an argument to use your version unconditionally and drop
Mail::Address actually.

But you can still test that with

  is(parse_address_(...), "Doe, Jane", "<description>");

(possibly not calling Mail::Address)

http://search.cpan.org/~exodist/Test-Simple-1.001014/lib/Test/More.pm

The cases where Mail::Address and your version give the same result can
be tested with a foreach loop calling

  is(parse_address_(...), Mail::Address(...), ...);

>  - When we don't really care about the output, because the user entry
>    is wrong, and we just expect the script to be aborted somehow... We
>    don't need to test that.

... but if you already have the tests, you can keep them as known
failure.

See the "TODO: BLOCK" section of the doc of Test::More.

>> I can do that on top of your series if you don't have time.
>
> Time will become a problem soon, but I think I can handle it unless
> you really want to do it !

If you have time, just do it.

Thanks,

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/