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: 55112
Status: resolved
Priority: 0/
Queue: Test-Strict

People
Owner: MANWAR [...] cpan.org
Requestors: tamias (no email address)
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.14
Fixed in: 0.36



Subject: .svn directories incorrectly filtered out
Test::Strict filters out any directory containing 'svn' in its name, rather than just directories named .svn, due to an error in this regex: return if ($File::Find::dir =~ m![\\/]?CVS[\\/]|[\\/]?.svn[\\/]!); # Filter out cvs or subversion dirs/ The period in .svn should be escaped, and [\\/]? should be replaced by (?:^|[\\/]) to avoid matching just part of a directory name: return if ($File::Find::dir =~ m!(?:^|[\\/])CVS[\\/]|(?:^|[\\/])\.svn[\\/]!); # Filter out cvs or subversion dirs/ The other two regexes should have [\\/]? replaced by (?:^|[\\/]) as well. Patch attached.
Subject: test-strict-regex.patch
diff -uw -r Test-Strict-0.14.orig/lib/Test/Strict.pm Test-Strict-0.14/lib/Test/Strict.pm --- Test-Strict-0.14.orig/lib/Test/Strict.pm 2010-02-13 19:49:40.000000000 -0500 +++ Test-Strict-0.14/lib/Test/Strict.pm 2010-03-01 14:08:42.000000000 -0500 @@ -123,9 +123,9 @@ : File::Spec->catdir($Bin, $updir); my @found; my $want_sub = sub { - return if ($File::Find::dir =~ m![\\/]?CVS[\\/]|[\\/]?.svn[\\/]!); # Filter out cvs or subversion dirs/ - return if ($File::Find::dir =~ m![\\/]?blib[\\/]libdoc$!); # Filter out pod doc in dist - return if ($File::Find::dir =~ m![\\/]?blib[\\/]man\d$!); # Filter out pod doc in dist + return if ($File::Find::dir =~ m!(?:^|[\\/])CVS[\\/]|(?:^|[\\/])\.svn[\\/]!); # Filter out cvs or subversion dirs/ + return if ($File::Find::dir =~ m!(?:^|[\\/])blib[\\/]libdoc$!); # Filter out pod doc in dist + return if ($File::Find::dir =~ m!(?:^|[\\/])blib[\\/]man\d$!); # Filter out pod doc in dist return unless (-f $File::Find::name && -r _); push @found, File::Spec->canonpath( File::Spec->no_upwards( $File::Find::name ) ); };
From: rjk [...] tamias.net
New patch attached, to fix another regex issue. The CVS & .svn regex matches [\\/] at the end, but should match $ instead.
Subject: test-strict-regex.patch
diff -uw -r Test-Strict-0.14.orig/lib/Test/Strict.pm Test-Strict-0.14/lib/Test/Strict.pm --- Test-Strict-0.14.orig/lib/Test/Strict.pm 2010-02-13 19:49:40.000000000 -0500 +++ Test-Strict-0.14/lib/Test/Strict.pm 2010-03-01 15:23:46.000000000 -0500 @@ -123,9 +123,9 @@ : File::Spec->catdir($Bin, $updir); my @found; my $want_sub = sub { - return if ($File::Find::dir =~ m![\\/]?CVS[\\/]|[\\/]?.svn[\\/]!); # Filter out cvs or subversion dirs/ - return if ($File::Find::dir =~ m![\\/]?blib[\\/]libdoc$!); # Filter out pod doc in dist - return if ($File::Find::dir =~ m![\\/]?blib[\\/]man\d$!); # Filter out pod doc in dist + return if ($File::Find::dir =~ m!(?:^|[\\/])CVS$|(?:^|[\\/])\.svn$!); # Filter out cvs or subversion dirs/ + return if ($File::Find::dir =~ m!(?:^|[\\/])blib[\\/]libdoc$!); # Filter out pod doc in dist + return if ($File::Find::dir =~ m!(?:^|[\\/])blib[\\/]man\d$!); # Filter out pod doc in dist return unless (-f $File::Find::name && -r _); push @found, File::Spec->canonpath( File::Spec->no_upwards( $File::Find::name ) ); };
From: rjk [...] tamias.net
On Mon Mar 01 15:26:29 2010, tamias wrote: Show quoted text
> New patch attached, to fix another regex issue. The CVS & .svn regex > matches [\\/] at the end, but should match $ instead.
Okay, one more try... I overlooked that the check isn't pruning the search, it's just skipping the current file. Instead of just returning, it should set $File::Find::prune to skip the entire directory. Patch is attached. Clearly there should be tests for the filtering. I would add some myself, but I'm leery of a module that depends on itself to run its own tests... :)
Subject: test-strict-regex.patch
Only in Test-Strict-0.14: cover_db diff -uw -r Test-Strict-0.14.orig/lib/Test/Strict.pm Test-Strict-0.14/lib/Test/Strict.pm --- Test-Strict-0.14.orig/lib/Test/Strict.pm 2010-02-13 19:49:40.000000000 -0500 +++ Test-Strict-0.14/lib/Test/Strict.pm 2010-03-01 17:03:33.000000000 -0500 @@ -123,9 +123,15 @@ : File::Spec->catdir($Bin, $updir); my @found; my $want_sub = sub { - return if ($File::Find::dir =~ m![\\/]?CVS[\\/]|[\\/]?.svn[\\/]!); # Filter out cvs or subversion dirs/ - return if ($File::Find::dir =~ m![\\/]?blib[\\/]libdoc$!); # Filter out pod doc in dist - return if ($File::Find::dir =~ m![\\/]?blib[\\/]man\d$!); # Filter out pod doc in dist + if (-d $File::Find::name && + ($_ eq 'CVS' || $_ eq '.svn' || # Filter out cvs or subversion dirs + $File::Find::name =~ m!(?:^|[\\/])blib[\\/]libdoc$! || # Filter out pod doc in dist + $File::Find::name =~ m!(?:^|[\\/])blib[\\/]man\d$!) # Filter out pod doc in dist + ) { + $File::Find::prune = 1; + return; + } + return unless (-f $File::Find::name && -r _); push @found, File::Spec->canonpath( File::Spec->no_upwards( $File::Find::name ) ); };
Hi, Thanks for raising the issue and providing the patch as well. Much appreciated. I will soon apply the patch. Best Regards, Mohammad S Anwar
Resolved.