John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

I generated this Makefile.PL
use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Exporter::VA', 'VERSION_FROM' => 'Exporter-VA.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'Exporter-VA.pm', # retrieve abstract from mod +ule AUTHOR => 'John M. Dlugosz <john@dlugosz.com>') : ()), );
When I run it on my Windows 2000 box, I get a pop-up dialog box entitled "WinIEPG - ()" with a little flag icon. It asks if I want to make a Recording or a Viewing Reminder, and what Record Quality, and on what channel. This appears to be part of WinDVR, a digital video recorder that came with the TV I/O thingie.

Apparently, it grabbed the .PL extension for itself when WinDVR was installed. I hadn't noticed because I use ".perl" for files that are meant to be top-level runnable programs. Easy enough to fix.

Now I get this:

Your perl and your Config.pm seem to have different ideas about the ar +chitecture they are running on. Perl thinks: [lib] Config says: [MSWin32-x86-multi-thread]
When I run ActiveState's Perl with -v, it tells me the latter. What's this mean?

A few misc. questions:
How do I get make install to not copy all the *.pm files? Some of them are for the tester, not the module itself.

How do I get make test to recognise and use my tester?

More Seriously, it got the name wrong! It copied Exporter-VA.pm to site\lib\Exporter\Exporter-VA.pm, which means it noticed the correct path as part of the module name but not the naming convention of the file. How do I get that to work right? —John

Replies are listed 'Best First'.
Re: Makefile.PL even weirder on Windows
by theorbtwo (Prior) on Jan 11, 2003 at 22:47 UTC

    The quick answer is "use the POD, Luke", to both. However, the POD for MakeMaker is terribly written. You should either have a VA.pm in the root of your source tarball, or have a Exporter/VA.pm, or a lib/Exporter/VA.pm, IIRC.

    As far as the tests, have a t/yadda.pl that uses the Test::Harness output conventions, or a ./test.pl, IIRC. (OTOH, if you use ./test.pl, the output is ignored -- the tests will be run, but MM, and thus CPAN.pm, won't notice if the tests failed.)


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      You both are saying that the source project has various subdirectories, rather than the few files I have in one directory?

      I read about the testing tutorial and the module, but it didn't give the format of the expected output. But really the issue is that the auto-testing looks in a particular subdirectory. Or, you're saying that the file named "test.pl", rather than "test$_.perl" foreach (1..$n); will be seen but the output not automatically processed? Doesn't it (MM or CPAN) care about the exit code?!

      —John

        The answer to all your questions is "yes". Seriously.

        If you have a file named ./test.pl, it will be run, and the results ignored by the Makefile (IIRC, of course -- read the disclaimer) (MM doesn't actualy run anything, it only writes a makefile. CPAN only runs the makefile). If there is a ./t/ subdirectory, it will be run via Test::Harness. See it's POD for details of the output format, or just use it's runtime functions (ok, ok_if, etc).


        Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: Makefile.PL even weirder on Windows
by chromatic (Archbishop) on Jan 12, 2003 at 01:50 UTC

    Did you use h2xs? That makes life much easier.

    If you have modules that exist only for testing purposes, stick them in t/lib and adjust the library path property in the test. You'll also have better luck if you stick with t/*.t files as Test::Harness expects.

    To get your name right, you could either dig through the MakeMaker docs (which have improved in recent versions; feel free to upgrade), or stick with the normal convention of putting your module in the appropriate directory with the appropriate name under lib/. I recommend the latter.

      Yes I did. The Makefile.PL I posted was generated by h2xs.
Re: Makefile.PL even weirder on Windows
by PodMaster (Abbot) on Jan 12, 2003 at 09:49 UTC
    Huh? So you're double clicking on Makefile.PL? Don't do that.

    I gotta say by the looks of Exporter-VA-1.2.2, I'd never consider testing it, much less installing it.

    First, your program is pure perl, and it should follow the standard way for installing perl modules, which is not double click, which is not ./Makefile.PL, it is perl Makefile.PL, make, make test, make install.

    Here's how you should think about changing it (dir structure first).

    E:\NEW\EXPORTER-VA-1.2.2
    |   Exporter-VA-Convert.perl
    |   Makefile.PL
    |   MANIFEST.txt
    |   README.txt
    |   VA.pm
    |
    \---t
            00-basic.t
            M1.pm
            M2.pm
            M3.pm
    
    I moved all the M*.pm files to the 't' directory, and I renamed test1.perl to 00-basic.t (which i also moved to 't'), and prepended use lib 't'; to it.

    I also renamed Exporter-VA.pm to VA.pm. Everything went fine, except your test file, well, ins't a perl test file (you don't have a 1..numberOfTests line). You should read this perl.com article on testing.

    The simple way of testing, is to have a single test.pl in the same directory as the Makefile.PL, like so

    E:\NEW\EXPORTER-VA-1.2.2
    |   Exporter-VA-Convert.perl
    |   Makefile.PL
    |   MANIFEST.txt
    |   README.txt
    |   test.pl
    |   VA.pm
    |
    \---t
            M1.pm
            M2.pm
            M3.pm
    
    

    Here's the Makefile.PL

    use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Exporter::VA', 'VERSION_FROM' => 'VA.pm', # finds $VERSION 'EXE_FILES' => [qw[ Exporter-VA-Convert.perl ]], 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'VA.pm', # retrieve abstract from module AUTHOR => 'A. U. Thor <a.u.thor@a.galaxy.far.far.away>') : +()), );
    This is what `h2xs -AX -n Exporter::VA' basically gives you.
    Writing Exporter/VA/VA.pm
    Writing Exporter/VA/Makefile.PL
    Writing Exporter/VA/README
    Writing Exporter/VA/test.pl
    Writing Exporter/VA/Changes
    Writing Exporter/VA/MANIFEST
    
    Notice where VA.pm is? If it was Exporter-VA.pm, MakeMaker would not magically rename it to Exporter\VA.pm


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.

      Another quick question:

      Moving the stuff to a t subdirectory, "nmake test" tells me that M1 etc. are not found. Apparently it does not chdir to the t directory before running the tests. How do I say in the Makefile.PL that the modules needed for the test scripts are also in that directory?

      Also, what is the significance of the name 00-basic ?

      —John

        Moving the stuff to a t subdirectory, "nmake test" tells me that M1 etc. are not found. Apparently it does not chdir to the t directory before running the tests. How do I say in the Makefile.PL that the modules needed for the test scripts are also in that directory?

        There isn't a way of doing this in the Makefile.PL that I am aware of. (Or, to be more accurate, no standard way. You can always write some custom code.)

        People normally add the directory to @INC in the appropriate *.t files.

        Also, what is the significance of the name 00-basic

        Adding a number prefix is one way to define the order test scripts are run in.

        Test are run in filename order. Some people like to have their test scripts run in a certain order. For example, you might test some basic stuff in the first script run and then bail out of the test suite if it fails - saving time when something goes wrong.

        I don't know about the number part, but MakeMaker (or whatever in the backend) globs t/*.t for test files, and runs them. Generally you wanna name these, and putting numbers don't hurt (it's like a convention).

        Remember when I say above I added use lib 't'; like to the test file (i do)? You don't do it in the makefile, you do it in your test file.


        MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
        ** The Third rule of perl club is a statement of fact: pod is sexy.