in reply to A unit-test script that causes remorse

"Suggestions, improvements are welcome!"

Instead of shelling out to get the file names:

use File::Find::Rule; my $path = 'lib'; my @files = File::Find::Rule->file() ->name('*.pm') ->in($path);

Replies are listed 'Best First'.
Re^2: A unit-test script that causes remorse
by Dallaylaen (Chaplain) on Sep 05, 2016 at 16:42 UTC

    Thanks, added it. I try to require File::Find::Rule and fall back to shell in case it's not there.

      Good idea. Take a look at Module::Load. I've used it in some of my distributions where I've needed to dynamically load modules by module or file name based on conditions and whether they are available. May be of use to you here.

      Regarding the sub redefined issue, you're not copying a module to a new name without changing the package name within for testing are you? I can't trigger this unless I copy one module, as-is, to another module name. eg: copy lib/Module.pm to lib/ModuleWithoutTests.pm without changing the package name within the copied file.

      Granted though, I only spent a couple of minutes playing so I very well could be overlooking something...

        copy lib/Module.pm to lib/ModuleWithoutTests.pm without changing the package name within the copied file.

        You nailed it. Cover includes modules from blib and not lib, and it seems to keep them ALL in one process to get coverage.

        Perhaps I should just skip modules already loaded. I'll do when I get some round tuits for this. (Gonna find some time to work, too...).

      This might break WIN. Better to require it or to use a more simple version of file finding that is core.

        Agreed. Updated to File::Find, and it actually ran on a Windows box, "testing" an empty module.
Re^2: A unit-test script that causes remorse
by Dallaylaen (Chaplain) on Sep 08, 2016 at 11:50 UTC
    Runs on stock File::Find now, Windows included, and no more warnings. Thanks again.