Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 83388
Status: resolved
Priority: 0/
Queue: Test-Strict

People
Owner: Nobody in particular
Requestors: peter [...] vereshagin.org
Cc:
AdminCc:

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



Subject: 'use Moose::Autobox' has no difference from 'use Moose' for strict_ok
Hello. It is known that 'use Moose' turns on strictures. 'Test::Strict' is known to check for it. On the other side, the 'use Moose::Autobox' may happen to be included into the checked source(s) by a mistake. It happens that 'Test::Strict' doesn't distinct such a situation with the perfect absence of the 'use Moose' or any other kind of strictures. The patch supplied solves the problem for me. Below is the shell session example showing the issue. Thank you. === $ perl -e 'use Moose::Autobox; $abcd = "efgh";' $ perl -Mstrict -e 'use Moose::Autobox; $abcd;' Global symbol "$abcd" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors. $ echo 'use Moose::Autobox; $abcd;' > test00.pl $ perl -Mstrict -we 'use Test::Strict qw{tests 1}; strict_ok( "test00.pl" );' 1..1 ok 1 - use strict test00.pl
Subject: Test-Strict-2013-02-17-02.patch
diff -ru Test-Strict-0.17.orig/lib/Test/Strict.pm Test-Strict-0.17/lib/Test/Strict.pm --- Test-Strict-0.17.orig/lib/Test/Strict.pm 2012-12-30 10:14:07.000000000 +0400 +++ Test-Strict-0.17/lib/Test/Strict.pm 2013-02-17 12:54:19.000000000 +0400 @@ -215,7 +215,7 @@ next if (/^\s*=.+/ .. /^\s*=(cut|back|end)/); # Skip pod last if (/^\s*(__END__|__DATA__)/); # End of code if ( /\buse\s+strict\s*;/ - or /\buse\s+Moose\b/ + or /\buse\s+Moose(?:[^\w:]|$)/ or /\buse\s+Mouse\b/ or /\buse\s+Modern::Perl\b/ ) { diff -ru Test-Strict-0.17.orig/t/02fail.t Test-Strict-0.17/t/02fail.t --- Test-Strict-0.17.orig/t/02fail.t 2010-02-14 03:50:01.000000000 +0300 +++ Test-Strict-0.17/t/02fail.t 2013-02-17 12:52:33.000000000 +0400 @@ -17,7 +17,7 @@ } } -use Test::More tests => 10; +use Test::More tests => 13; use File::Temp qw( tempdir tempfile ); my $perl = $^X || 'perl'; @@ -28,6 +28,7 @@ test2(); test3(); test4(); +test5(); exit; @@ -70,6 +71,16 @@ like( $content, qr/not ok \d+ \- use warnings/, "Does not have use warnings" ); } +sub test5 { + my $dir = make_moose_bad_file(); + my ($fh, $outfile) = tempfile( UNLINK => 1 ); + ok( `$perl $inc -MTest::Strict -e "all_perl_files_ok( '$dir' )" 2>&1 > $outfile` ); + local $/ = undef; + my $content = <$fh>; + like( $content, qr/^ok 1 - Syntax check /m, "Syntax ok" ); + like( $content, qr/not ok 2 - use strict /, "Does not have use strict" ); +} + sub make_bad_file { my $tmpdir = tempdir( CLEANUP => 1 ); @@ -106,6 +117,17 @@ return $tmpdir; } +sub make_moose_bad_file { + my $tmpdir = tempdir( CLEANUP => 1 ); + my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pm' ); + print $fh <<'DUMMY'; +# Makes methods for plain Perl types with autobox +# No 'use Moose' here and no strictures turned on +use Moose::Autobox; +DUMMY + return $tmpdir; +} + sub make_bad_warning { my $tmpdir = tempdir( CLEANUP => 1 ); Only in Test-Strict-0.17/t: 02fail.t.orig
applied and will be in next release (0.18). Next time, could you please fork the github repository and send a pull request there?
On Sun Feb 17 06:51:48 2013, SZABGAB wrote: Show quoted text
> applied and will be in next release (0.18). > Next time, could you please fork the github repository and send a pull > request there?
err, and thanks for the patch :)
Subject: Re: [rt.cpan.org #83388] 'use Moose::Autobox' has no difference from 'use Moose' for strict_ok
Date: Sun, 17 Feb 2013 16:33:43 +0400
To: bug-Test-Strict [...] rt.cpan.org
From: peter [...] vereshagin.org
On 2013-02-17 15:52, Gabor Szabo via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=83388 > > > On Sun Feb 17 06:51:48 2013, SZABGAB wrote:
>> applied and will be in next release (0.18). >> Next time, could you please fork the github repository and send a >> pull >> request there?
> > err, and thanks for the patch :)
Welcome. I should prefer pull-request(s) too, but don't see Test::Strict's GitHub location in the POD... I use to check for them there.
Subject: Re: [rt.cpan.org #83388] 'use Moose::Autobox' has no difference from 'use Moose' for strict_ok
Date: Sun, 17 Feb 2013 15:17:09 +0200
To: bug-Test-Strict [...] rt.cpan.org
From: Gabor Szabo <SZABGAB [...] cpan.org>
On Sun, Feb 17, 2013 at 2:34 PM, Peter Vereshagin via RT <bug-Test-Strict@rt.cpan.org> wrote: Show quoted text
> Queue: Test-Strict > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=83388 > > > On 2013-02-17 15:52, Gabor Szabo via RT wrote:
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=83388 > >> >> On Sun Feb 17 06:51:48 2013, SZABGAB wrote:
>>> applied and will be in next release (0.18). >>> Next time, could you please fork the github repository and send a >>> pull >>> request there?
>> >> err, and thanks for the patch :)
> > Welcome. > > I should prefer pull-request(s) too, but don't see Test::Strict's > GitHub location in the POD... I use to check for them there.
Oh, interesting point. It is in the meta files and it is also displayed on https://metacpan.org/module/Test::Strict (see the 'Clone repository' link)