From 7d74a013e25930c366d9a9f1ee391344c13f3461 Mon Sep 17 00:00:00 2001
From: Jared Camins-Esakov <jcamins@cpbibliography.com>
Date: Wed, 27 Jun 2012 11:02:31 -0400
Subject: [PATCH] Bug 8244 follow-up: improvements to find-undefined-subroutines
Content-Type: text/plain; charset="UTF-8"

* Adds a repeatable --ignore option so that the user can choose to
  ignore certain files.
* Exit with the same success or failure code that the prove command
  returns
---
 xt/find-undefined-subroutines.pl |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/xt/find-undefined-subroutines.pl b/xt/find-undefined-subroutines.pl
index 2fdd62f..4a567c4 100755
--- a/xt/find-undefined-subroutines.pl
+++ b/xt/find-undefined-subroutines.pl
@@ -61,6 +61,11 @@ Usage:
     --dest-path|-d PATH     Where you want to build the hierarchy of tests
                             scripts and modules. Leave empty to use a temporary
                             directory (will be removed automatically)
+    --ignore PATTERN        Ignore files with a name matching the specified
+                            pattern (note that this will only match on a
+                            single component of a filename so you cannot
+                            choose to ignore only one of two files with
+                            identical names)
     --verbose|-v            Print some progress informations
     --help|-h               Print this help message
 
@@ -76,11 +81,14 @@ my $src_path;
 my $dest_path;
 my $verbose = 0;
 my $help = 0;
+my @ignore;
+my $ignore_regex;
 
 my $options_ok = GetOptions(
     'src-path=s' => \$src_path,
     'dest-path=s' => \$dest_path,
     'verbose' => \$verbose,
+    'ignore=s' => \@ignore,
     'help' => \$help
 );
 
@@ -89,6 +97,13 @@ if ($help) {
     exit 0;
 }
 
+$ignore_regex = '(';
+for my $skip (@ignore) {
+    $ignore_regex .= "$skip|";
+}
+chop $ignore_regex;
+$ignore_regex .= ')';
+
 if (!$src_path) {
     $src_path = $src_path_default;
 }
@@ -133,6 +148,7 @@ find( sub {
     return $File::Find::prune = 1 if ($_ =~ /^$dest_path$/);
     return $File::Find::prune = 1 if ($_ =~ /^t$/);
     return $File::Find::prune = 1 if ($_ =~ /^blib$/);
+    return $File::Find::prune = 1 if ($_ =~ /$ignore_regex/);
     return unless $_ =~ m/\.pm$/;
     my $file = $File::Find::name;
     $file =~ s#^$src_path##;
@@ -258,6 +274,7 @@ my @scripts;
 find( sub {
     return $File::Find::prune = 1 if ($_ =~ /^t$/);
     return $File::Find::prune = 1 if ($_ =~ /^$dest_path$/);
+    return $File::Find::prune = 1 if ($_ =~ /$ignore_regex/);
     return unless $_ =~ m/\.pl$/;
     my $file = $File::Find::name;
     $file =~ s#^$src_path##;
@@ -389,3 +406,4 @@ my $includes_param = join(' ', map { "-I$_" } @includedirs);
 my $scripts_param = join(' ', map { "$dest_path/$_" } @scripts_to_run);
 
 system("prove $includes_param $scripts_param");
+exit $? >> 8;
-- 
1.7.2.5