3 use inc::Module::Install;
6 all_from 'lib/Mouse.pm';
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;
14 test_requires 'Test::More' => 0.88;
15 test_requires 'Test::Exception' => 0.27;
16 # test_requires 'Test::Output' => 0.16; # too many dependencies!
18 include 'Test::Exception'; # work around 0.27_0x (its use of diehook might be wrong)
20 recommends 'MRO::Compat' if $] < 5.010;
22 if ($Module::Install::AUTHOR) {
23 local @INC = ('lib', @INC);
24 require 'lib/Mouse/Spec.pm';
25 my $require_version = Mouse::Spec->MooseVersion;
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');
32 print "you don't have a M::I::AuthorTests.\n";
35 print "you don't have Moose $require_version. skipping moose compatibility test\n";
37 system("author/generate-mouse-tiny.pl");
40 WriteAll check_nmake => 0;
42 sub create_moose_compatibility_test {
45 require File::Basename;
47 print "Creating compatibility tests in xt/compatibility/* ...\n";
49 File::Path::rmtree(File::Spec->catfile('xt', 'compatibility'));
51 # some test does not pass... currently skip it.
53 '016-trigger.t' => "trigger's argument is incompatble :(",
54 '010-isa-or.t' => "Mouse has a [BUG]",
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',
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",
63 '031_roles_applied_in_create.t' => 't/lib/* classes are not Moose classes/roles',
73 return if /failing/; # skip tests in failing/ directories which are Moose specific
75 return if /100_with_moose/; # tests with Moose
76 return if /deprecated/;
78 my $basename = File::Basename::basename($_);
79 return if $basename =~ /^\./;
81 if(exists $SKIP_TEST{$basename}){
82 print "# skip $basename because: $SKIP_TEST{$basename}\n";
86 my $dirname = File::Basename::dirname($_);
88 my $tmpdir = File::Spec->catfile('xt', 'compatibility', $dirname);
89 File::Path::mkpath($tmpdir);
91 my $tmpfile = File::Spec->catfile($tmpdir, $basename);
92 open my $wfh, '>', $tmpfile or die $!;
95 open my $rfh, '<', $_ or die $!;
96 my $s = do { local $/; <$rfh> };
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;
106 push @compat_tests, $tmpfile;
112 print "Compatibility tests created.\n";
114 clean_files "@compat_tests";