X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=author%2Fimport-moose-test.pl;h=e89735914ed3c3ebe94d3da3160f41424f6f8920;hb=590e40d8d76ceb0ee30bbd2ea9e679701bb1280a;hp=a0ad424add1532b0e8c09bf0945657185474cb9b;hpb=0bdc9d38dfd3de07aad929f6629f8fa65d434c27;p=gitmo%2FMouse.git diff --git a/author/import-moose-test.pl b/author/import-moose-test.pl index a0ad424..e897359 100644 --- a/author/import-moose-test.pl +++ b/author/import-moose-test.pl @@ -4,28 +4,30 @@ use strict; use warnings FATAL => 'all'; use File::Path qw(mkpath); use File::Find; +use File::Basename qw(basename dirname); use autodie; my($moose_dir, $result) = @ARGV; unless(defined $moose_dir and -d "$moose_dir/t") { - die "Usage: $0 Moose-dir result-dir\n"; -} -$result //= 'Moose-test'; -if(-e $result) { - die "'$result' exists, stopped"; + die "Usage: $0 Moose-dir [result-dir]\n"; } +$result //= 'Moose-t'; my @tests; sub wanted { - (my $mouse_test = $_) =~ s{\A $moose_dir/t }{$result}xmso; - (my $mouse_failing_test = $_) =~ s{\A $moose_dir/t }{$result-failing}xmso; + return if /native_traits/; + my $file = $_; + (my $basename = basename($file)) =~ s/Moose/Mouse/g; + $file = dirname($file) . '/' . $basename; + (my $test = $file) =~ s{\A $moose_dir/t }{$result}xmso; + (my $failing_test = $file) =~ s{\A $moose_dir/t }{$result-failing}xmso; if( -d $_ ) { - mkpath [$mouse_test, $mouse_failing_test]; + mkpath [$test, $failing_test]; return; } - copy_as_mouse($_ => $mouse_test); - push @tests, [$mouse_test, $mouse_failing_test] - if $mouse_test =~/\.t\z/xms; + copy_as_mouse($_ => $test); + push @tests, [$test, $failing_test] + if $file =~/\.t\z/xms; return; } @@ -75,11 +77,13 @@ sub copy_as_mouse { while(<$in>) { if($. == 2) { + say $out "# This is automatically generated by $0."; + say $out "# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!"; say $out 'use t::lib::MooseCompat;'; } - s/\b Class::MOP::([a-z_]+) \b/Mouse::Util::$1/xmsg; - s/\b Class::MOP \b /Mouse::Meta/xmsg; - s/\b Moose \b/Mouse/xmsg; + s/ Class::MOP::([a-z_]+) /Mouse::Util::$1/xmsg; + s/ Class::MOP /Mouse::Meta/xmsg; + s/ Moose /Mouse/xmsg; # make classes simple s{\b(Mouse::Meta::TypeConstraint)::\w+ }{$1}xmsg;