Craig A. Berry wrote: > On Thu, Feb 26, 2009 at 8:32 PM, Michael G Schwern <schw...@pobox.com> wrote: >> Craig A. Berry wrote: >>>> The important thing is the core change from running the ext/ tests >>>> manually to >>>> using each module's own "make test". This will make integrating and >>>> developing dual life modules far easier by eliminating a key difference in >>>> how >>>> ext/ and CPAN modules are developed. >>> Hmm. This only makes any difference for modules that distribute their >>> own libraries that are only used for testing, right? It looks like >>> ext/Test-Harness/t/lib is the only one like that currently. Add >>> Module::Build and ExtUtils::MakeMaker when they get moved to ext/, >>> maybe a couple others. >> It's a general purpose problem that effects all the ext/ modules. > > You mean affects, not effects.
Thank you, you have saved the Internet. >> Most tests >> have some special code to accommodate the duality of core vs CPAN testing. >> Usually its just this: >> >> BEGIN { >> if ($ENV{'PERL_CORE'}){ >> chdir 't'; >> unshift @INC, '../lib'; >> } >> } >> >> But it will effect any test that needs to know its position relative its >> source tree, usually to read another file or load a module in the source >> tree. > > Is that really considered a best practice? I know a lot of smart > people do that, but in my experience, this sort of cleverness often > leads to things going wrong. Reading a file in a subdir is clever? >> CPANPLUS and CPAN are good examples off the top of my head. But it's not >> limited to just finding stuff in their own t/lib. > > CPANPLUS tests use FindBin to locate themselves and find their > friends. It's not immediately clear the tests would need any changes > to move over to ext/ (though it is big and complicated and can't be > known for sure without trying it). Right, they do that because it's not clear from where the test will be run so it needs extra code to figure that out. Using FindBin is a clever technique that lets the test be moved around, but earlier versions did something more static: BEGIN { if( $ENV{PERL_CORE} ) { chdir '../lib/CPANPLUS' if -d '../lib/CPANPLUS'; unshift @INC, '../../../lib'; ### fix perl location too $^X = '../../../t/' . $^X; } } And most of the tests are written with kludges like that. Here's one from lib/CPAN/t/03pkgs.t so it can test that its own modules will load. my @m; if ($ENV{PERL_CORE}){ @m = ("CPAN", map { "CPAN::$_" } qw(Debug DeferredCode Distroprefs FirstTime Kwalify Nox Queue Tarzip Version )); } else { opendir DH, "lib/CPAN" or die; @m = ("CPAN", map { "CPAN::$_" } grep { s/\.pm$// } readdir DH); } MakeMaker's t/00compile.t isn't working in ext/ at the moment because it can't find its own modules, it's going to need some sort of kludge like that if things are left as is. ext/Cwd/t/cwd.t has some typical examples of groping around looking for test directories: $want = $ENV{PERL_CORE} ? $Test_Dir : File::Spec->catdir('t', $Test_Dir); if ($ENV{PERL_CORE}) { chdir '../ext/Cwd/t'; unshift @INC, '../../../lib'; } And MakeMaker did some pretty deep back bends to work out the differences. >> The more we do this, the more we're going to find "exceptions", the more >> hacks >> we have to put into place and what's going to wind up happening is we're not >> going to want to move things into ext. Making ext/ as much like the normal >> module process as possible smooths out the transition. > > I'll try to keep an open mind and assist where I can, but from where I > sit this is just shifting time and attention away from important > things like fixing known bugs and getting releases out the door toward > putting out all the fires that will inevitably arise from breaking > something that is known to be stable and working. That's the general purpose excuse for any change. It doesn't fly, volunteers aren't interchangeable parts. You can't say "don't scratch that itch, scratch this one". I will freely admit I'm doing this because it's been a royal pain in my ass for years. I'm going to reverse the advice and instead of continuing to justify this change I'll just implement it and see whether the sky remains up. -- But there's no sense crying over every mistake. You just keep on trying till you run out of cake. -- Jonathan Coulton, "Still Alive"