Commit | Line | Data |
972340a6 |
1 | # COMPAT_TEST=1 genrates Moose compatible tests |
e8c583d3 |
2 | # for developpers: |
3 | BEGIN{ |
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 |
10 | use strict; |
11 | use warnings; |
9c96124c |
12 | BEGIN { |
1746908e |
13 | unshift @INC, 'inc'; |
14 | |
9c96124c |
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; |
884bf37f |
36 | |
c3398f5b |
37 | all_from 'lib/Mouse.pm'; |
38 | |
ec53d678 |
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; |
272a1930 |
42 | |
9c96124c |
43 | test_requires 'Test::More' => 0.88; |
f7f4955d |
44 | |
45 | # to keep zero-dependencies |
46 | include 'Test::Exception::LessClever'; |
47 | include 'Test::Requires'; |
179ac6cc |
48 | |
3310ddf2 |
49 | my %suggests = ( |
af1c2a64 |
50 | 'Any::Moose' => 0.10, |
8e4a10a8 |
51 | |
3310ddf2 |
52 | 'MouseX::AttributeHelpers' => 0.06, |
32ec255c |
53 | 'MouseX::NativeTraits' => 1.00, |
3310ddf2 |
54 | ); |
3310ddf2 |
55 | while(my($mod, $least) = each %suggests){ |
6741954a |
56 | my $status = system $^X, '-e', <<"CHECK"; |
57 | if(eval q{ use $mod (); 1 }) { |
58 | if(eval q{ use $mod $least (); 1 }) { |
c4f4f5e3 |
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 | ); |
3310ddf2 |
74 | } |
75 | } |
76 | |
ec7a9423 |
77 | # cc_want deals with the '--pp' and '--xs' options |
78 | my $use_xs = ($] >= 5.008_001 && want_xs()); |
0e81c55d |
79 | |
80 | if($use_xs){ |
2af88019 |
81 | print "Mouse configured with XS.\n"; |
bb543d7f |
82 | |
fdee07cc |
83 | use_ppport(3.19); |
8e4a10a8 |
84 | use_xshelper(); |
2af88019 |
85 | cc_warnings(); |
0e81c55d |
86 | cc_src_paths('xs-src'); |
758664cd |
87 | if($use_xs){ |
38f4a557 |
88 | test_target test_pp => ( |
89 | env => { PERL_ONLY => 1 }, |
90 | ($Module::Install::AUTHOR ? (alias => 'test') : ()), |
91 | ); |
758664cd |
92 | } |
38f4a557 |
93 | } |
0e81c55d |
94 | else{ |
7b92a82b |
95 | print "Mouse configured with Pure Perl.\n"; |
0e81c55d |
96 | } |
97 | |
125dc1a8 |
98 | tests 't/*.t t/*/*.t'; |
1e2f2888 |
99 | author_tests 'xt'; |
100 | |
125dc1a8 |
101 | repository 'git://git.moose.perl.org/Mouse.git'; |
102 | |
823419c5 |
103 | system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0 |
104 | or warn "Cannot generate Mouse::Tiny: $!"; |
105 | makemaker_args PL_FILES => { |
106 | 'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm', |
107 | }; |
108 | |
af1c2a64 |
109 | if ($Module::Install::AUTHOR) { |
110 | require 'lib/Mouse/Spec.pm'; # for the version |
121acb8a |
111 | my $require_version = Mouse::Spec->MooseVersion; |
bf9f3f91 |
112 | |
972340a6 |
113 | if ($ENV{COMPAT_TEST} |
114 | && eval { require Moose; Moose->VERSION($require_version) }) { |
92ff14d0 |
115 | print "You have Moose ", Moose->VERSION, ".\n"; |
2af88019 |
116 | do 'tool/create-moose-compatibility-tests.pl'; |
38f4a557 |
117 | test_target test_moose => ( |
118 | tests => ['xt/compat/t/*/*.t'], |
119 | alias => 'test', |
120 | ); |
314fe304 |
121 | } else { |
92ff14d0 |
122 | print "You don't have Moose $require_version. skipping moose compatibility test\n"; |
314fe304 |
123 | } |
4358792d |
124 | |
f7f4955d |
125 | |
126 | # Hack to disable Test::Exception, which might pull a perl internal bug. |
127 | # See also Test::Exception::LessClever. |
128 | open my $out, '>', 'inc/Test/Exception.pm' or die $!; |
129 | print $out <<'EOT'; |
130 | package Test::Exception; # wapper to T::E::LessClever |
131 | require Test::Exception::LessClever; |
132 | $INC{'Test/Exception.pm'} = __FILE__; |
133 | sub import { |
134 | shift; |
135 | Test::Exception::LessClever->export_to_level(1, @_); |
136 | } |
137 | 1; |
138 | EOT |
139 | close $out or die $!; |
314fe304 |
140 | } |
141 | |
af1c2a64 |
142 | clean_files q{ |
143 | lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log |
144 | *.out |
145 | cover_db xs-src/*.gc{v,no,da} |
146 | }; |
1e2f2888 |
147 | |
eb88905f |
148 | WriteAll check_nmake => 0; |