From 51ab375dce249e4ac0632ead13ac991da0ae4eee Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Wed, 27 Jun 2012 11:02:31 -0400 Subject: [PATCH] Bug 8244 follow-up: improvements to find-undefined-subroutines * 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 Signed-off-by: Kyle M Hall --- xt/find-undefined-subroutines.pl | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/xt/find-undefined-subroutines.pl b/xt/find-undefined-subroutines.pl index 2fdd62f..2faefd5 100755 --- a/xt/find-undefined-subroutines.pl +++ b/xt/find-undefined-subroutines.pl @@ -61,6 +61,12 @@ 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). + Must be a valid regular expression --verbose|-v Print some progress informations --help|-h Print this help message @@ -76,11 +82,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 +98,10 @@ if ($help) { exit 0; } +if (@ignore) { + $ignore_regex = '(' . join ('|', @ignore) . ')'; +} + if (!$src_path) { $src_path = $src_path_default; } @@ -133,6 +146,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 and $_ =~ /$ignore_regex/); return unless $_ =~ m/\.pm$/; my $file = $File::Find::name; $file =~ s#^$src_path##; @@ -258,6 +272,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 and $_ =~ /$ignore_regex/); return unless $_ =~ m/\.pl$/; my $file = $File::Find::name; $file =~ s#^$src_path##; @@ -389,3 +404,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