Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
"My question is what is the directory where the test scripts are run?" Well, look at it this way... when your module is popped open by the CPAN Testers, they base their operations (executions) of your tests from the top-level root directory of your module, so when tests are run, they typically see lib, t etc. underneath. Your unit tests should always be under the t/ directory, and inside of a test file, you should always specify special locations from the location the test is being run *from*... that is, if you have Module/t/01-my_test.t, wanting to grab a baseline file from Module/t/data/baseline.conf, you'd reference it as t/data/baseline.conf. It's really that simple. Write your tests from the perspective that they'll be run out of the parent directory of t/, and you'll be fine. this is an example test file where I open a baseline comparison file from within t/orig. I do perform unlink in that test file... I could create tempfiles in t/data, lib/MyModule or wherever... just reference them as you're sitting in your module root dir (really, really avoid absolute paths... that's not portable at all). To create, then unlink within a unit test, ensure you have any directory eg: t/data dir, then, after you've done your work (eg: open my $wfh, '>', 't/data/scrap.crap' or die $!;) at the end of your unit test (or at the end of the test file) do something like:
Again... tests are run from your module root directory. When specifying a directory from within your test, act like you're in the directory above it. When running your unit tests, be in your module root dir, and do: perl t/01-mytest.t or make test. If your directories are off, you'll find out quickly. In reply to Re: CPAN test scripts, "run" directory, and test data files
by stevieb
|
|