mvhub-dev team mailing list archive
-
mvhub-dev team
-
Mailing list archive
-
Message #00295
[Branch ~mvhub-commit/mvhub/trunk] Rev 410: merged lp:~omacneil/mvhub/improve_perltidy_t
Merge authors:
Dan MacNeil (omacneil)
Related merge proposals:
https://code.launchpad.net/~omacneil/mvhub/improve_perltidy_t/+merge/27456
proposed by: Dan MacNeil (omacneil)
review: Approve - Priya Ravindran (priya)
------------------------------------------------------------
revno: 410 [merge]
committer: Dan MacNeil <dan@xxxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-06-15 14:39:09 -0400
message:
merged lp:~omacneil/mvhub/improve_perltidy_t
removed:
app-mvhub/t/perltidy.t@
renamed:
lib-mvhub/t/perltidy.t => app-mvhub/t/perltidy.t
modified:
app-mvhub/t/perltidy.t
--
lp:mvhub
https://code.launchpad.net/~mvhub-commit/mvhub/trunk
Your team MVHub Developers is subscribed to branch lp:mvhub.
To unsubscribe from this branch go to https://code.launchpad.net/~mvhub-commit/mvhub/trunk/+edit-subscription
=== renamed file 'lib-mvhub/t/perltidy.t' => 'app-mvhub/t/perltidy.t'
--- lib-mvhub/t/perltidy.t 2010-03-12 15:21:20 +0000
+++ app-mvhub/t/perltidy.t 2010-06-13 20:19:57 +0000
@@ -3,19 +3,21 @@
use strict;
use warnings;
+use Carp;
use Test::More;
use File::Temp;
+use Test::NoWarnings;
BEGIN {
use FindBin qw($Bin);
- chdir $Bin;
+ chdir "$Bin/../..";
}
use TestHelper;
SKIP:
{
- my $perltidyrc = "$FindBin::Bin" . "/conf/perltidyrc";
+ my $perltidyrc = "lib-mvhub/t/conf/perltidyrc";
eval {
require Perl::Tidy;
$Perl::Tidy::VERSION eq '20090616'
@@ -28,13 +30,20 @@
}
else {
- my @perl_files = get_files(qw/*.pl *.pm *.t /);
- @perl_files = grep { $_ !~ /blib/ } @perl_files;
- plan tests => ( scalar @perl_files );
-
- my $fix_msg;
+ my @perl_files;
+ if ( defined $ENV{MV_CHECK_ONLY_UNCOMMITTED} ) {
+ @perl_files = _get_uncommitted_perl_files();
+ }
+ else {
+ @perl_files = _get_all_perl_files();
+ }
+
+ plan tests => ( scalar @perl_files ) + 1; # +1 for NoWarnings
+
+ my @files_to_fix;
foreach my $file (@perl_files) {
+
my $destination = ( File::Temp::tempfile() )[1];
Perl::Tidy::perltidy(
source => $file,
@@ -44,18 +53,51 @@
);
if (!ok(TestHelper::no_difference( $file, $destination ),
- "$file is all perltidy "
+ "perltidy: $file"
)
)
{
- $fix_msg .= " $file";
+ push @files_to_fix, $file;
}
unlink $destination
or diag "failed to unlink $destination";
} # foreach
- diag(
- "\n\nto fix:\n\n \t perltidy -b $fix_msg --profile=$perltidyrc\n\n"
- ) if $fix_msg;
+ diag( _build_fix_msg( $perltidyrc, @files_to_fix ) )
+ if scalar @files_to_fix;
} # else
} # SKIP
+
+sub _get_uncommitted_perl_files {
+
+ my @perl_files = `bzr status`;
+ chomp @perl_files;
+ @perl_files = map { s# +##; $_; } @perl_files;
+ @perl_files = grep { m/(pl|pm|t)$/; } @perl_files;
+
+ return @perl_files;
+}
+
+sub _get_all_perl_files {
+
+ my @perl_files = get_files_from( '.', qw/*.pl *.pm *.t / );
+ @perl_files = map { s#^.*lib-mvhub/t/\.\.#lib-mvhub#; $_; } @perl_files;
+ @perl_files = map { s#^.*app-mvhub/t/\.\.#app-mvhub/#; $_; } @perl_files;
+ @perl_files = map { s#^\./##; $_; } @perl_files;
+
+ return @perl_files;
+}
+
+sub _build_fix_msg {
+ my $perltidyrc = shift or croak 'missing pararm: $perltidyrc';
+ my @files = @_ or die 'missing parameter: @files';
+ my $files = join ' ', @files;
+
+ my $cmd = <<"END";
+TO FIX:
+
+ cdw && perltidy -b --profile=$perltidyrc $files
+
+END
+ return $cmd;
+}
=== removed symlink 'app-mvhub/t/perltidy.t'
=== target was '../../lib-mvhub/t/perltidy.t'