lib-filter-0.03 fails test on Windows 8 with VS2013 built perl 5.20.2 #1

Closed
nanis opened this Issue May 24, 2015 · 5 comments

Projects

None yet

2 participants

@nanis
Contributor
nanis commented May 24, 2015

This is all I have for now:

C:\...\lib-filter-0.03> prove -vb t\01-basics.t
t\01-basics.t ..                                                                   
# Subtest: disallow                                                                
    ok 1                                                                           
                                                                                   
    not ok 2    #   Failed test at t\01-basics.t line 15.                          
                                                                                   
    ok 3                                                                           
    1..3                                                                           
    # Looks like you failed 1 test of 3.                                           
                                                                                   
not ok 1 - disallow#   Failed test 'disallow'                                      
                                                                                   
#   at t\01-basics.t line 18.                                                      
1..1                                                                               
# Looks like you failed 1 test of 1.                                               
Dubious, test returned 1 (wstat 256, 0x100)                                        
Failed 1/1 subtests 
@nanis
Contributor
nanis commented May 24, 2015

This is all rather mysterious: I have verified that code reaches where it should die, i.e.

        if ($disallow{$mod}) {
            die "Module '$mod' is disallowed ($disallow{$mod})";
        }

in filter.pm. The only thing I can think of is the fact that List::Util is loaded by Test::More. In fact:

C:\...\lib-filter-0.03> perl -Ilib -Mlib::filter=disallow,List::Util -MList::Util -E "say for @INC"
Module 'List::Util' is disallowed (disallow) at lib/lib/filter.pm line 107.
BEGIN failed--compilation aborted.

There is one other Windows test failure due to the same reason.

@perlancar
Owner

Do you think it would help if the test script loads List::Util first?

On Sun, May 24, 2015 at 6:39 PM, A. Sinan Unur notifications@github.com
wrote:

This is all rather mysterious: I have verified that code reaches where it
should die, i.e.

    if ($disallow{$mod}) {
        die "Module '$mod' is disallowed ($disallow{$mod})";
    }

in filter.pm. The only thing I can think of is the fact that List::Util
is loaded by Test::More.


Reply to this email directly or view it on GitHub
#1 (comment)
.

@nanis
Contributor
nanis commented May 26, 2015

It doesn't seem to have any effect. It seems to me the test is failing because the hook is not being invoked for List::Util. Now, clearly, on other platforms, it is being invoked, so I am confused right now. If I can think of something, I'll let you know.

To be honest, I am more surprised that the hook is invoked for List::Util on other platforms. After all, perldoc -f require does say

Note that the file will not be included twice under the same specified name.

@nanis
Contributor
nanis commented May 26, 2015

BTW, the following makes the test pass:

dies_ok  { local %INC = %INC; delete $INC{'List/Util.pm'}; require List::Util };

Presumably, this should be done for each module you are using in the test.

I have finally figured out the reason for all the passing tests on CPANTesters. On my Windows machine, I had Test::More version 1.301001_099, a development version I had installed to test the changes. See also 'Test::More has lots of crazy new development that's breaking my modules'.

I believe the non-failing reports on CPANTesters are from platforms running earlier versions that do not load List::Util.

I'll submit a pull request.

@nanis
Contributor
nanis commented May 27, 2015

See also this discussion on /r/perl:

Another alternative is to instead ship a little lib directory with the distribution with some trivial module files, and use those to test this functionality, instead of referring to modules that are in widespread use, and, therefore, might end up being already loaded by the time the test is being run.

I think this is the better route. Put the lib dir under the t/ tree so people know it's specifically for testing purposes, then load or block modules accordingly. Use the Local:: Namespace to prevent potential conflicts (or put everything under lib::filter::test or something)

To me the corrected code isn't self-documenting and it wouldn't be possible to guess why it was needed without a comment or the blog post.

I think at this very early stage of the module, this quick fix is OK. As the author figures out the remaining tests, it would be better for him to incorporate a separate t/lib/Local/ with Local::Allowed and Local::Disallowed trivial modules etc.

HTH and makes sense. Thank you.

@nanis nanis closed this May 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment