Retrieve @EXPORT, which is no longer used, but defined for backward compatibility
[gitmo/Mouse.git] / Makefile.PL
1 use strict;
2 use warnings;
3 use inc::Module::Install;
4
5 name     'Mouse';
6 all_from 'lib/Mouse.pm';
7
8 tests 't/*.t t/*/*.t';
9
10 # Scalar::Util < 1.14 has a bug.
11 # > Fixed looks_like_number(undef) to return false for perl >= 5.009002
12 requires 'Scalar::Util' => 1.14;
13
14 test_requires 'Test::More'      => 0.88;
15 test_requires 'Test::Exception' => 0.27;
16 # test_requires 'Test::Output'    => 0.16; # too many dependencies!
17
18 include 'Test::Exception'; # work around 0.27_0x (its use of diehook might be wrong)
19
20 recommends 'MRO::Compat' if $] < 5.010;
21
22 if ($Module::Install::AUTHOR) {
23     local @INC = ('lib', @INC);
24     require 'lib/Mouse/Spec.pm';
25     my $require_version = Mouse::Spec->MooseVersion;
26
27     if (eval{ require Moose; Moose->VERSION($require_version) }) {
28         if (eval 'use Module::Install::AuthorTests; 1') {
29             create_moose_compatibility_test();
30             recursive_author_tests('xt');
31         } else {
32             print "you don't have a M::I::AuthorTests.\n";
33         }
34     } else {
35         print "you don't have Moose $require_version. skipping moose compatibility test\n";
36     }
37     system("author/generate-mouse-tiny.pl");
38 }
39
40 WriteAll check_nmake => 0;
41
42 sub create_moose_compatibility_test {
43     require File::Path;
44     require File::Spec;
45     require File::Basename;
46
47     print "Creating compatibility tests in xt/compatibility/* ...\n";
48
49     File::Path::rmtree(File::Spec->catfile('xt', 'compatibility'));
50
51     # some test does not pass... currently skip it.
52     my %SKIP_TEST = (
53         '016-trigger.t'    => "trigger's argument is incompatble :(",
54         '010-isa-or.t'     => "Mouse has a [BUG]",
55
56         '052-undefined-type-in-union.t' => "Mouse accepts undefined type as a member of union types",
57         '054-anon-leak.t'     => 'Moose has memory leaks',
58
59         '600-tiny-tiny.t'     => "Moose doesn't support ::Tiny",
60         '601-tiny-mouse.t'    => "Moose doesn't support ::Tiny",
61         '602-mouse-tiny.t'    => "Moose doesn't support ::Tiny",
62
63         '031_roles_applied_in_create.t' => 't/lib/* classes are not Moose classes/roles',
64     );
65
66     my @compat_tests;
67
68     File::Find::find(
69         {
70             wanted => sub {
71                 return unless -f $_;
72
73                 return if /failing/; # skip tests in failing/ directories which  are Moose specific
74
75                 return if /100_with_moose/; # tests with Moose
76                 return if /deprecated/;
77
78                 my $basename = File::Basename::basename($_);
79                 return if $basename =~ /^\./;
80
81                 if(exists $SKIP_TEST{$basename}){
82                     print "# skip $basename because: $SKIP_TEST{$basename}\n";
83                     return;
84                 }
85
86                 my $dirname = File::Basename::dirname($_);
87
88                 my $tmpdir = File::Spec->catfile('xt', 'compatibility', $dirname);
89                 File::Path::mkpath($tmpdir);
90
91                 my $tmpfile = File::Spec->catfile($tmpdir, $basename);
92                 open my $wfh, '>', $tmpfile or die $!;
93                 print $wfh do {
94                     my $src = do {
95                         open my $rfh, '<', $_ or die $!;
96                         my $s = do { local $/; <$rfh> };
97                         close $rfh;
98                         $s;
99                     };
100                     $src =~ s/Mouse::(?:Util::)?is_class_loaded/Class::MOP::is_class_loaded/g;
101                     $src =~ s/Mouse::(?:Util::)?load_class/Class::MOP::load_class/g;
102                     $src =~ s/Mouse/Moose/g;
103                     $src;
104                 };
105                 close $wfh;
106                 push @compat_tests, $tmpfile;
107             },
108             no_chdir => 1
109         },
110         't',
111     );
112     print "Compatibility tests created.\n";
113
114     clean_files "@compat_tests";
115 }
116