Skip threading tests on Test::More 2.00_01
[gitmo/Mouse.git] / Makefile.PL
1 # COMPAT_TEST=1 genrates Moose compatible tests
2 # for developpers:
3 BEGIN{
4     if(grep{ $_ eq '--author' } @ARGV){
5         print "$^X -S cpanm < author/requires.cpanm\n";
6         system "$^X -S cpanm < author/requires.cpanm";
7     }
8 }
9
10 use strict;
11 use warnings;
12 use inc::Module::Install 1.00;
13
14 # for co-developpers
15 use Module::Install::XSUtil 0.30;
16 use Module::Install::AuthorTests;
17
18 name     'Mouse';
19 all_from 'lib/Mouse.pm';
20
21 # Scalar::Util < 1.14 has a bug.
22 # > Fixed looks_like_number(undef) to return false for perl >= 5.009002
23 requires 'Scalar::Util' => 1.14;
24
25 test_requires 'Test::More'=> 0.88;
26
27 # to keep zero-dependencies
28 include 'Test::Exception::LessClever';
29 include 'Test::Requires';
30
31 my %suggests = (
32     'Any::Moose'                     => 0.10,
33
34     'MouseX::AttributeHelpers'       => 0.06,
35 );
36 while(my($mod, $least) = each %suggests){
37     my $status = system $^X, '-e', <<"CHECK";
38 if(eval q{ use $mod (); 1 }) {
39     if(eval q{ use $mod $least (); 1 }) {
40         exit 0; # installd, and new enough
41     }
42     else {
43         exit 1; # installed, but too old
44     }
45 }
46 CHECK
47
48     if($status != 0){
49         my $ver = `$^X -e "use $mod (); print $mod->VERSION"`;
50         warn("\n",
51             "WARNING: $mod is installed, but its version ($ver) is too old (< $least).\n",
52             "         Please update $mod after installation of Mouse.\n",
53             "\n"
54         );
55     }
56 }
57
58 # cc_want deals with the '--pp' and '--xs' options
59 my $use_xs = ($] >= 5.008_001 && want_xs());
60
61 if($use_xs){
62     print "Mouse configured with XS.\n";
63
64     use_ppport(3.19);
65     use_xshelper();
66     cc_warnings();
67     cc_src_paths('xs-src');
68 }
69 else{
70     print "Mouse configured with Pure Perl.\n";
71 }
72
73 tests 't/*.t t/*/*.t';
74 author_tests 'xt';
75
76 repository 'git://git.moose.perl.org/Mouse.git';
77
78 system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
79     or warn "Cannot generate Mouse::Tiny: $!";
80 makemaker_args PL_FILES => {
81     'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm',
82 };
83
84 if ($Module::Install::AUTHOR) {
85     require 'lib/Mouse/Spec.pm'; # for the version
86     my $require_version = Mouse::Spec->MooseVersion;
87
88     if ($ENV{COMPAT_TEST}
89             && eval { require Moose; Moose->VERSION($require_version) }) {
90         print "You have Moose ", Moose->VERSION, ".\n";
91         do 'tool/create-moose-compatibility-tests.pl';
92         # repeat testing
93         # see also ExtUtils::MM_Any::test_via_harness()
94         my $t_moose =  q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
95                       .q{ "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"}
96                       .q{ xt/compat/t/*/*.t } . "\n";
97
98         postamble qq{test :: test_moose\n\n}
99                 . qq{test_moose :: pure_all\n}
100                 . qq{\t} . $t_moose;
101     } else {
102         print "You don't have Moose $require_version. skipping moose compatibility test\n";
103     }
104
105     if($use_xs){
106         # repeat testing
107         # see also ExtUtils::MM_Any::test_via_harness()
108         my $t_pp =  q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
109                    .q{ "do 'tool/force-pp.pl'; test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"}
110                    .q{ $(TEST_FILES)} . "\n";
111
112         postamble qq{test :: test_pp\n\n}
113                 . qq{test_pp :: pure_all\n}
114                 . qq{\t} . $t_pp;
115     }
116
117     # Hack to disable Test::Exception, which might pull a perl internal bug.
118     # See also Test::Exception::LessClever.
119     open my $out, '>', 'inc/Test/Exception.pm' or die $!;
120     print $out <<'EOT';
121 package Test::Exception; # wapper to T::E::LessClever
122 require Test::Exception::LessClever;
123 $INC{'Test/Exception.pm'} = __FILE__;
124 sub import {
125     shift;
126     Test::Exception::LessClever->export_to_level(1, @_);
127 }
128 1;
129 EOT
130     close $out or die $!;
131 }
132
133 clean_files q{
134     lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
135     *.out
136     cover_db xs-src/*.gc{v,no,da}
137 };
138
139 WriteAll check_nmake => 0;