Commits

Shlomi Fish  committed 5fa0f56

Fix regex

  • Participants
  • Parent commits 665582d

Comments (0)

Files changed (3)

File Test-TrailingSpace/Changes

+0.0201      Mon 27 May 14:47:33 IDT 2013
+    - Fix the regex for the matching of a .hg or .bzr directory.
+
 0.0200      Mon 27 May 13:09:33 IDT 2013
     - Add the 'abs_path_prune_re' parameter to the constructor.
 

File Test-TrailingSpace/lib/Test/TrailingSpace.pm

     my $abs_path_prune_re = $self->_abs_path_prune_re();
 
     my $rule = $subrule->or(
-        $subrule->new->directory->name(qr/(?:\A|\/)(?:blib|_build|CVS|\.svn|\.bzr\.hg|\.git)\z/)->prune->discard,
+        $subrule->new->directory->name(qr/(?:\A|\/)(?:blib|_build|CVS|\.svn|\.bzr|\.hg|\.git)(?:\/|\z)/)->prune->discard,
         (defined ( $abs_path_prune_re )
             ? (
                 $subrule->exec(

File Test-TrailingSpace/t/object-test.t

 
 use lib './t/lib';
 
-use Test::Builder::Tester tests => 3;
+use Test::Builder::Tester tests => 4;
 
 use File::Path qw( rmtree );
 
         {
             root => "./$test_dir",
             filename_regex => qr/\.(?:pm|txt)\z/,
-            abs_path_prune_re => qr#(?:\A|/)lib/#ms,
+            abs_path_prune_re => qr#(?:\A|/)lib(?:/|\z)#ms,
         }
     );
 
     test_test("no trailing space was reported");
     rmtree($t->get_path("./$test_dir"))
 }
+
+{
+    my $test_id = "no-trailing-space-in-hg";
+    my $test_dir = "t/sample-data/$test_id";
+    my $tree =
+    {
+        'name' => "$test_id/",
+        'subs' =>
+        [
+            {
+                'name' => "a/",
+                subs =>
+                [
+                    {
+                        'name' => "b.pm",
+                        'contents' => "This file was spotted in the wild.",
+                    },
+                ],
+            },
+            {
+                'name' => "foo/",
+                'subs' =>
+                [
+                    {
+                        'name' => "t.door.txt",
+                        'contents' => "A T Door",
+                    },
+                    {
+                        'name' => "yet/",
+                    },
+                ],
+            },
+            {
+                'name' => ".hg/",
+                subs =>
+                [
+                    {
+                        'name' => "foo.pm",
+                        'contents' => "File with trailing space     \nhello\n",
+                    }
+                ],
+            },
+        ],
+    };
+
+    my $t = File::Find::Object::TreeCreate->new();
+    $t->create_tree("./t/sample-data/", $tree);
+
+    my $finder = Test::TrailingSpace->new(
+        {
+            root => "./$test_dir",
+            filename_regex => qr/\.(?:pm|txt)\z/,
+        }
+    );
+
+    test_out("ok 1 - trailing space in .hg is ignored.");
+    $finder->no_trailing_space("trailing space in .hg is ignored.");
+    test_test("no trailing space was reported");
+    rmtree($t->get_path("./$test_dir"))
+}