Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: How to define a package using a tweaked version of LWP::UserAgent?

by moritz (Cardinal)
on Jul 31, 2008 at 16:08 UTC ( [id://701459]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to define a package using a tweaked version of LWP::UserAgent?
in thread How to define a package using a tweaked version of LWP::UserAgent?

But when I try to run "make test" from the lib/My/Client directory

Why would you want to run 'make test' in that directory? Usually the directory structure for a module looks like this:

Makefile.PL Makefile lib/My/Client.pm lib/OtherModules.pm t/test-one.t t/test-two.t # other stuff META.yml important-script.pl README examples/example1.pl

If you adhere to that standard, your Makefile lives in the root directory, and the tests in a directory sub directory of the root dir.

So running make test on the lib/Foo/ level would actually complain about a Makefile not being found. So tests are always run from the root level directory, in which case make tests will invoke your test scripts as perl t/test-file.t.

In this case a use lib 'lib'; in all scripts that are invoked with the root dir as the current working directory.

Replies are listed 'Best First'.
Re^4: How to define a package using a tweaked version of LWP::UserAgent?
by pwolfenden (Novice) on Jul 31, 2008 at 16:40 UTC

    I'm simply running "make" in the directory where h2xs created the Makefile.

    My development sequence so far has been this:

    1. Use h2xs to create the My::Client package skeleton.
    2. Hack away at the skeleton until My::Client does almost everything I want it to.
    3. Discover that I need to override the proxy credentials handling logic in the LWP::UserAgent package.
    4. Look for the leanest/cleanest change which achieves the desired objective (hence this thread).

    It sounds like you're saying that it is time for me to reorganize the directory structure of my package distribution.

      I'm just trying to describe how most modules organize their directories, and so far it worked out very well for me.

      If you put all your modules in the distribution under lib/, and run your script from directly above lib (aka root for the distribution dir), all you need is a simple use lib 'lib'.

      For installed modules this usually doesn't matter, because make install puts them in a directory below @INC where perl can find it.

        Thanks for the suggestion.

        But it seems that MakeMaker is smarter than I thought, and the simplest solution in my case is to add RequestAgent.pm to lib/My/Client/. Running "perl Makefile.PL" in this directory then creates a Makefile which automatically includes both Client.pm and RequestAgent.pm (and which works with "make test"), and in order to include RequestAgent.pm from inside Client.pm I can simply add this line:

        use My::RequestAgent;
        No hardcoded or relative paths, and no "use lib". Sweet.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://701459]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-19 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found