Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_ok() can report a false-positive #149

Closed
rjray opened this issue Aug 16, 2011 · 1 comment
Closed

use_ok() can report a false-positive #149

rjray opened this issue Aug 16, 2011 · 1 comment

Comments

@rjray
Copy link

rjray commented Aug 16, 2011

Recently, I got a false-positive from use_ok() on a module that had been deleted from my distro, but was still being tested for in a test-suite. The reason I got this, is that because I had a previous version of the distro installed, the deprecated module lived under a site_perl somewhere. However, clean tests of my release by people such as CPAN Testers and the Debian team got test failures.

It might be worthwhile to consider having use_ok look at %INC after a successful "use" of the module, and see if it picked it up from lib/blib, or from a system location. Whether this case would warrant a failing test is questionable, but it should at least garner a warning.

@schwern
Copy link
Contributor

schwern commented Aug 24, 2011

Sorry, but use_ok() is intended as a way to test use statements, not specifically to check the modules in the distribution being tested. Putting a special case check in for where the module loaded from would be against that purpose, reduce its utility and break many existing tests.

The use case you propose has merit, and you're free to write a version of use_ok() that adds the additional check. It's pretty straight forward...

sub use_local_ok {
    local $Test::Builder::Level = $Test::Builder::Level + 1;

    my($module, @args) = @_;

    use_ok($module, @args) or return;

    ...whatever else you want to add...
}

I'm going to close it up, but feel free to keep discussing.

@schwern schwern closed this as completed Aug 24, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants