Avoid Test::Exception problems with T::E::LessClever
[gitmo/Mouse.git] / Makefile.PL
CommitLineData
972340a6 1# COMPAT_TEST=1 genrates Moose compatible tests
e8c583d3 2# for developpers:
3BEGIN{
4 if(grep{ $_ eq '--author' } @ARGV){
01f38ab1 5 print "$^X -S cpanm < author/requires.cpanm\n";
e8c583d3 6 system "$^X -S cpanm < author/requires.cpanm";
7 }
8}
9
08f7a8db 10use strict;
11use warnings;
533ed4d6 12use inc::Module::Install 1.00;
c3398f5b 13
884bf37f 14# for co-developpers
8e4a10a8 15use Module::Install::XSUtil 0.30;
d202164d 16use Module::Install::AuthorTests;
884bf37f 17
c3398f5b 18name 'Mouse';
19all_from 'lib/Mouse.pm';
20
ec53d678 21# Scalar::Util < 1.14 has a bug.
22# > Fixed looks_like_number(undef) to return false for perl >= 5.009002
23requires 'Scalar::Util' => 1.14;
272a1930 24
f7f4955d 25test_requires 'Test::More'=> 0.88;
26
27# to keep zero-dependencies
28include 'Test::Exception::LessClever';
29include 'Test::Requires';
179ac6cc 30
3310ddf2 31my %suggests = (
af1c2a64 32 'Any::Moose' => 0.10,
8e4a10a8 33
3310ddf2 34 'MouseX::AttributeHelpers' => 0.06,
35);
3310ddf2 36while(my($mod, $least) = each %suggests){
6741954a 37 my $status = system $^X, '-e', <<"CHECK";
38if(eval q{ use $mod (); 1 }) {
39 if(eval q{ use $mod $least (); 1 }) {
c4f4f5e3 40 exit 0; # installd, and new enough
41 }
42 else {
43 exit 1; # installed, but too old
44 }
45}
46CHECK
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 );
3310ddf2 55 }
56}
57
ec7a9423 58# cc_want deals with the '--pp' and '--xs' options
59my $use_xs = ($] >= 5.008_001 && want_xs());
0e81c55d 60
61if($use_xs){
2af88019 62 print "Mouse configured with XS.\n";
bb543d7f 63
fdee07cc 64 use_ppport(3.19);
8e4a10a8 65 use_xshelper();
2af88019 66 cc_warnings();
0e81c55d 67 cc_src_paths('xs-src');
0e81c55d 68}
69else{
7b92a82b 70 print "Mouse configured with Pure Perl.\n";
0e81c55d 71}
72
125dc1a8 73tests 't/*.t t/*/*.t';
1e2f2888 74author_tests 'xt';
75
125dc1a8 76repository 'git://git.moose.perl.org/Mouse.git';
77
823419c5 78system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
79 or warn "Cannot generate Mouse::Tiny: $!";
80makemaker_args PL_FILES => {
81 'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm',
82};
83
af1c2a64 84if ($Module::Install::AUTHOR) {
85 require 'lib/Mouse/Spec.pm'; # for the version
121acb8a 86 my $require_version = Mouse::Spec->MooseVersion;
bf9f3f91 87
972340a6 88 if ($ENV{COMPAT_TEST}
89 && eval { require Moose; Moose->VERSION($require_version) }) {
92ff14d0 90 print "You have Moose ", Moose->VERSION, ".\n";
2af88019 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}
f7f4955d 95 .q{ "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"}
2af88019 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;
314fe304 101 } else {
92ff14d0 102 print "You don't have Moose $require_version. skipping moose compatibility test\n";
314fe304 103 }
4358792d 104
105 if($use_xs){
f47ebad0 106 # repeat testing
107 # see also ExtUtils::MM_Any::test_via_harness()
108 my $t_pp = q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
f7f4955d 109 .q{ "do 'tool/force-pp.pl'; test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"}
f47ebad0 110 .q{ $(TEST_FILES)} . "\n";
111
2af88019 112 postamble qq{test :: test_pp\n\n}
f47ebad0 113 . qq{test_pp :: pure_all\n}
114 . qq{\t} . $t_pp;
4358792d 115 }
f7f4955d 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';
121package Test::Exception; # wapper to T::E::LessClever
122require Test::Exception::LessClever;
123$INC{'Test/Exception.pm'} = __FILE__;
124sub import {
125 shift;
126 Test::Exception::LessClever->export_to_level(1, @_);
127}
1281;
129EOT
130 close $out or die $!;
314fe304 131}
132
af1c2a64 133clean_files q{
134 lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
135 *.out
136 cover_db xs-src/*.gc{v,no,da}
137};
1e2f2888 138
eb88905f 139WriteAll check_nmake => 0;