develooper Front page | perl.perl6.users | Postings from July 2021

Re: use lib and locations in a variable

Thread Previous | Thread Next
Joseph Brenner
July 13, 2021 05:31
Re: use lib and locations in a variable
Message ID:
Just to clarify my use case a bit:

Joseph Brenner <> wrote:
> I want my test files to be able to find the modules they're testing
> just using their relative locations, given the usual layout of "lib"
> and "t" locations in parallel inside the project directory.

That's like so:

     |    |
    lib   t

There are *.t files (raku scripts) in the "t" location, and they're
intended to exercise the *.rakumod files located under the "lib"
location.   Unless you've got every "lib" in every project on your
system included in your PERL6LIB directory, you're going to need to Do
Something if you want the *.t files to be able to find the modules
under development.

That's what something like this does:

>     use lib $*PROGRAM.parent.add('../lib');

"use lib" adds that path to the locations raku will search for modules.
Here the path is determined starting with the path to the currently
running script:


From there we go up one more level, then look down into the lib location.

I gather that many people would change directories into the "t"
directory before running the tests there, but myself I like to just
use full paths to the tests, so my current directory might be set to
any where.   So starting at the "." doesn't really work for me.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About