Mouse::Util::does_role() respects $thing->does() method
[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 BEGIN {
13     unshift @INC, 'inc';
14
15         # author requires, or bundled modules
16     my @devmods = qw(
17         inc::Module::Install             1.00
18         Module::Install::TestTarget      0.13
19         Module::Install::AuthorTests     0.002
20         Module::Install::XSUtil          0.36
21                 Test::Exception::LessClever      0.005
22                 Test::Requires                   0.06
23     );
24     my @not_available;
25         while(my($mod, $ver) = splice @devmods, 0, 2) {
26         eval qq{use $mod $ver (); 1} or push @not_available, $mod;
27     }
28     if(@not_available) {
29         print qq{# The following modules are not available.\n};
30         print qq{# `perl $0 | cpanm` will install them:\n};
31         print $_, "\n" for @not_available;
32                 exit 1;
33      }
34 }
35 use inc::Module::Install;
36
37 all_from 'lib/Mouse.pm';
38
39 # Scalar::Util < 1.14 has a bug.
40 # > Fixed looks_like_number(undef) to return false for perl >= 5.009002
41 requires 'Scalar::Util' => 1.14;
42
43 test_requires 'Test::More' => 0.88;
44
45 # to keep zero-dependencies
46 include 'Test::Exception::LessClever';
47 include 'Test::Requires';
48
49 my %suggests = (
50     'Any::Moose'                     => 0.10,
51
52     'MouseX::AttributeHelpers'       => 0.06,
53     'MouseX::NativeTraits'           => 1.00,
54 );
55 while(my($mod, $least) = each %suggests){
56     my $status = system $^X, '-e', <<"CHECK";
57 if(eval q{ use $mod (); 1 }) {
58     if(eval q{ use $mod $least (); 1 }) {
59         exit 0; # installd, and new enough
60     }
61     else {
62         exit 1; # installed, but too old
63     }
64 }
65 CHECK
66
67     if($status != 0){
68         my $ver = `$^X -e "use $mod (); print $mod->VERSION"`;
69         warn("\n",
70             "WARNING: $mod is installed, but its version ($ver) is too old (< $least).\n",
71             "         Please update $mod after installation of Mouse.\n",
72             "\n"
73         );
74     }
75 }
76
77 # cc_want deals with the '--pp' and '--xs' options
78 my $use_xs = ($] >= 5.008_001 && want_xs());
79
80 if($use_xs){
81     print "Mouse configured with XS.\n";
82
83     use_ppport(3.19);
84     use_xshelper();
85     cc_warnings();
86     cc_src_paths('xs-src');
87     if($use_xs){
88                 test_target test_pp => (
89                         env => { PERL_ONLY => 1 },
90                         ($Module::Install::AUTHOR ? (alias => 'test') : ()),
91                 );
92     }
93 }
94 else{
95     print "Mouse configured with Pure Perl.\n";
96 }
97
98 tests 't/*.t t/*/*.t';
99 author_tests 'xt';
100
101 homepage   'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Mouse.git';
102 repository 'git://git.moose.perl.org/Mouse.git';
103 # or web interface:
104 # http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Mouse.git;a=summary
105
106 system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
107     or warn "Cannot generate Mouse::Tiny: $!";
108 makemaker_args PL_FILES => {
109     'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm',
110 };
111
112 if ($Module::Install::AUTHOR) {
113     require 'lib/Mouse/Spec.pm'; # for the version
114     my $require_version = Mouse::Spec->MooseVersion;
115
116     if ($ENV{COMPAT_TEST}
117             && eval { require Moose; Moose->VERSION($require_version) }) {
118         print "You have Moose ", Moose->VERSION, ".\n";
119         do 'tool/create-moose-compatibility-tests.pl';
120         test_target test_moose => (
121             tests => ['xt/compat/t/*/*.t'],
122             alias => 'test',
123         );
124     } else {
125         print "You don't have Moose $require_version. skipping moose compatibility test\n";
126     }
127
128
129     # Hack to disable Test::Exception, which might pull a perl internal bug.
130     # See also Test::Exception::LessClever.
131     open my $out, '>', 'inc/Test/Exception.pm' or die $!;
132     print $out <<'EOT';
133 package Test::Exception; # wapper to T::E::LessClever
134 require Test::Exception::LessClever;
135 $INC{'Test/Exception.pm'} = __FILE__;
136 sub import {
137     shift;
138     Test::Exception::LessClever->export_to_level(1, @_);
139 }
140 1;
141 EOT
142     close $out or die $!;
143 }
144
145 clean_files q{
146     lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
147     xshelper.h
148     *.out
149     cover_db xs-src/*.gc{v,no,da}
150 };
151
152 WriteAll check_nmake => 0;