Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Perl-Critic CPAN distribution.

Report information
The Basics
Id: 78035
Status: new
Priority: 0/
Queue: Test-Perl-Critic

People
Owner: Nobody in particular
Requestors: dschrag [...] oneupweb.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: $^W is set globally by using this module (->Perl::Critic->Perl::Tidy)
Download (untitled) / with headers
text/plain 1.1k
Because Perl::Tidy (now a required dependency of Perl::Critic) does a: BEGIN { $^W = 1; } when it is loaded, all code run during testing has this flag set, unless explicitly overridden. Being used to using lexical warnings in the modern style and moving away from the -w flag, I was surprised when an XS module I was using (Unicode::String) began emitting warnings which could NOT be turned off with 'no warnings'. I am reporting this here, rather than Perl::Critic or Perl::Tidy because that kind of makes sense (though I don't really know why?) in the usual context those modules are used -- though it doesn't seem to be documented. For Test::Perl::Critic, however, this is a lovely case of action-at-a-distance. The attached test shows how it fails. Substituting the following block makes it work: # Do this instead of 'use Test::Perl::Critic' to pass the test: BEGIN { local $^W; require Test::Perl::Critic; Test::Perl::Critic->import(); } Perhaps you can do something similar when you load Perl::Tidy? I've tested this on perl 5.8.7 and 5.12.3. I guess you could consider this a work-around for the 'perl -w' bug ;-)
Subject: test_warn_flag.t
Download test_warn_flag.t
text/x-perl 396b
#!/usr/bin/perl BEGIN { $^W = 0; } use Test::Perl::Critic; # Who knew this would set $^W ?? # Do this instead to pass the test: # BEGIN { # local $^W; # require Test::Perl::Critic; # Test::Perl::Critic->import(); # } use warnings; warn join "\n ", "\nThese Perl::* modules are loaded", grep( {/Perl.*Tidy/} keys %INC ), ""; use Test::More tests => 1; is $^W, 0, 'Surprise';


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.