Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How to organize and install test files

by roman (Monk)
on Oct 12, 2007 at 11:03 UTC ( [id://644436]=perlquestion: print w/replies, xml ) Need Help??

roman has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

has anybody ever solved a problem how to make test files coming with a (your own) Perl module permanent, i.e. able to be run without the reinstallation of the module?

I'd like to have the tests installed along with the module installation. I don't want to use Build test again, because after installation I don't keep the module source at a production server.

Since our inhouse modules are build using a subclass of Module::Build I plan to extend the installation phase so it copies the t directory into some APP_ROOT/test/Module-Name dir.

Do you think it is a reasonable approach? Do you use a different one? Do you keep your test files separated from your modules?

As I am thinking of it It would be nice to locally hack ExtUtils::MakeMaker and Module::Build so that also CPAN modules would have their tests permanently installed (for retests and for inspiration how to write the test). Do you think it is worth the effort?

Any idea appreciated. Upgrade of SOAP::Lite while neglecting the tests put me into troubles I want to avoid for the next time.

Replies are listed 'Best First'.
Re: How to organize and install test files
by lima1 (Curate) on Oct 12, 2007 at 11:18 UTC
    Haven't tried it, but you can easily add script files in both ExtUtils::MakeMaker and Module::Build.
    WriteMakefile( ... EXE_FILES => \@test_files_to_be_installed, );
    or:
    my $builder = $class->new( ... script_files => \@test_files_to_be_installed, );
Re: How to organize and install test files
by moritz (Cardinal) on Oct 12, 2007 at 11:14 UTC
    Why would you want to do this? (This is no implicit "don't do it!" question, but a serious question).

    As long as you don't change the modules the test results shouldn't change.

    And if you change the modules you do an installation - and you can execute the tests along the way.

      Because the unchanged module may depend on other modules which were just changed.

      For example after refactoring and reinstallation of base class for call statements (I work in the telecommunications) it would be nice to check whether the derived classes (incoming call statements, outgoing call statements, ...) are still working.

      Another real (my) world example is the upgrade of SOAP::Lite and XML::LibXML which we use extensively. I wish I checked our modules before this upgrade.

Re: How to organize and install test files
by chromatic (Archbishop) on Oct 13, 2007 at 05:02 UTC

    Write your tests with Test::Class, keep them in your lib/ directory as if they were normal modules, and let them get installed as normal.

    If you want to be extra clever, check caller and have them run themselves if they're invoked directly. (Pod::ToDemo uses a similar trick.)

      Thank you very much, Test::Class seems to be the solution.

      We already place our code into modules (with scripts being mere use MyModule; MyModule->run(@ARGV);), now we can use similar approach with test files also.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://644436]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2024-04-26 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found