in reply to Re^5: STDERR in Test Results
in thread STDERR in Test Results

However, in this particular case we are talking about Test::Warn which at the time of writing this post has 365 direct dependents and 5381 total dependents

It seems, quite a few testers don't have Test::Warn installed...

Perhaps they only have core modules on their setup for testing.

Replies are listed 'Best First'.
Re^7: STDERR in Test Results
by hippo (Archbishop) on Jun 26, 2023 at 10:05 UTC
    Perhaps they only have core modules on their setup for testing.

    Well, yes. How else could they test that all the dependencies have been correctly listed? The system is working as intended :-)


    🦛

Re^7: STDERR in Test Results
by afoken (Chancellor) on Jun 25, 2023 at 21:40 UTC
    It seems, quite a few testers don't have Test::Warn installed...

    You should be able to detect that and skip the test(s).

    Very crudely, something like this should work (completely untested):

    #... use Test::More tests => 42; eval 'use Test::Warn;'; # just ignore if we can't load Test::Warn #... SKIP: { unless ($INC{'Test/Warn.pm'}) { # test if Test::Warn was loaded skip 'Test::Warn is not available', 1; } warning_like { warn "foo" } qr/foo/; # you may need to put this li +ne in a string eval because warning_like is exported by Test::Warn } # ...

    Or maybe put all warnings tests in a separate script and skip the entire script if Test::Warn is not available (again untested):

    # ... use Test::More; BEGIN { if (eval 'use Test::Warn; 1') { Test::More->import(tests => 42); } else { Test::More->import(skip_all => 'Test::Warn is not available'); # this line won't be reached, see Test::More } } warning_like { warn "foo" } qr/foo/; # ...

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)