Make Mouse::Util::load_class return the argument class name, which can remove several...
[gitmo/Mouse.git] / tool / create-moose-compatibility-tests.pl
CommitLineData
32cf1353 1#!perl
2use strict;
3use warnings;
4
5use File::Path ();
6use File::Spec ();
7use File::Basename ();
8
9print "Creating compatibility tests in xt/compatibility/* ...\n";
10
11File::Path::rmtree(File::Spec->catfile('xt', 'compatibility'));
12
13# some test does not pass... currently skip it.
14my %SKIP_TEST = (
15 '016-trigger.t' => "trigger's argument is incompatble :(",
98e392b9 16 '810-isa-or.t' => "Mouse has a bug",
32cf1353 17
18 '052-undefined-type-in-union.t' => "Mouse accepts undefined type as a member of union types",
19 '054-anon-leak.t' => 'Moose has memory leaks',
20
98e392b9 21 '059-weak-with-default.t' => 'Moose has a bug',
22
32cf1353 23 '600-tiny-tiny.t' => "Moose doesn't support ::Tiny",
24 '601-tiny-mouse.t' => "Moose doesn't support ::Tiny",
25 '602-mouse-tiny.t' => "Moose doesn't support ::Tiny",
ed2f9d78 26 '603-mouse-pureperl.t'=> "Moose doesn't have ::PurePerl",
32cf1353 27
4f21a0b3 28 '031_roles_applied_in_create.t' => 't/lib/*.pm are not for Moose',
29 '013_metaclass_traits.t' => 't/lib/*.pm are not for Moose',
32cf1353 30);
31
32my @compat_tests;
33
34File::Find::find(
35 {
36 wanted => sub {
37 return unless -f $_;
38
39 return if /failing/; # skip tests in failing/ directories which are Moose specific
40
41 return if /with_moose/; # tests with Moose
42 return if /100_bugs/; # some tests require Mouse specific files
43 return if /deprecated/;
44
45 my $basename = File::Basename::basename($_);
46 return if $basename =~ /^\./;
47
48 if(exists $SKIP_TEST{$basename}){
49 print "# skip $basename because: $SKIP_TEST{$basename}\n";
50 return;
51 }
52
53 my $dirname = File::Basename::dirname($_);
54
55 my $tmpdir = File::Spec->catfile('xt', 'compatibility', $dirname);
56 File::Path::mkpath($tmpdir);
57
58 my $tmpfile = File::Spec->catfile($tmpdir, $basename);
59 open my $wfh, '>', $tmpfile or die $!;
60 print $wfh do {
61 my $src = do {
62 open my $rfh, '<', $_ or die $!;
63 my $s = do { local $/; <$rfh> };
64 close $rfh;
65 $s;
66 };
67 $src =~ s/Mouse::(?:Util::)?is_class_loaded/Class::MOP::is_class_loaded/g;
68 $src =~ s/Mouse::(?:Util::)?load_class/Class::MOP::load_class/g;
b3d7fe46 69 $src =~ s/Mouse::Util::class_of/Class::MOP::class_of/g;
32cf1353 70 $src =~ s/Mouse/Moose/g;
71 $src;
72 };
73 close $wfh;
74 push @compat_tests, $tmpfile;
75 },
76 no_chdir => 1
77 },
78 't',
79);
80print "Compatibility tests created.\n";
81
82clean_files("@compat_tests"); # defined in main
83
84