Garfield Nate

Big Fat Hairy Programmer

Testing Perl Distributions With Test Subdirectories

| Comments

Normally I run my test suites with the prove utility:

prove -vl --merge

The v option turns on verbose processing, and the l option adds lib/ to the include path. provethen runs all of the tests in the t/ folder.

Today, I had a new problem. I merged multiple distributions into one (without losing any Git history!), and each had a test suite that I wanted to keep separate. Naturally, I moved the tests from each distribution into its own subdirectory under t/. However, this time when I ran prove -vl, I got this message:

Files=0, Tests=0,  0 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)

Dubious… Well, I needed to know how to test with subdirectories in the t/ folder, so I looked at the prove documentation and found the -r option. The r stands for “recurse”, meaning that the test files would be found by recursing into the directories of the distribution (starting at the top in the root of the distribution). That turned out to be exactly what I needed!

prove -vlr
All tests successful.
Files=28, Tests=1815, 211 wallclock secs ( 0.92 usr + 0.28 sys = 1.20 CPU)
Result: PASS


Also, both MakeMakerand Module::Build recurse in the same way during module testing. If you use Dist::Zilla, then you’ll probably have the plugins [MakeMaker] and [ModuleBuild]. Using these, dzil test will recurse in the same way.