johanvdb has asked for the wisdom of the Perl Monks concerning the following question:
I'm stuck with the next problem...
I want to make a test in the ./t directory that accesses a config file. Using an absolute path from out of the test script is impossible as the config files live in the ./t directory and I don't know which directory will be used to
build the package from.
It also seems impossible to use a relative path, as the script is executed in Test::Harness, or at least I don't see it on how to track down this ...
So, I was thinking on building the path to the config file dynamically, using something like 'FindBin'....
Does any of the enlightened monks has an idea on how to approach this?
use Test::More qw( no_plan ); use MyPackage; # try relative ( good idea, but does not work ) my $p1 = MyPackage->new( -config => './test.conf' ); # try absolute ( bad idea, does not *always* work ) my $p2 = MyPackage->new( -config => '/tmp/MyPackage/t/test.conf' ); # help !
J.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accessing config files under 'make test'
by IlyaM (Parson) on Feb 26, 2002 at 20:53 UTC | |
by johanvdb (Beadle) on Feb 26, 2002 at 21:11 UTC |