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; |
533ed4d6 |
12 | use inc::Module::Install 1.00; |
c3398f5b |
13 | |
884bf37f |
14 | # for co-developpers |
8e4a10a8 |
15 | use Module::Install::XSUtil 0.30; |
d202164d |
16 | use Module::Install::AuthorTests; |
884bf37f |
17 | |
c3398f5b |
18 | name 'Mouse'; |
19 | all_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 |
23 | requires 'Scalar::Util' => 1.14; |
272a1930 |
24 | |
74dd795e |
25 | test_requires 'Test::More' => 0.88; |
26 | test_requires 'Test::Requires' => 0.06; # works on 5.6.0 |
27 | test_requires 'Test::Exception::LessClever' => 0.005; |
f7f4955d |
28 | |
29 | # to keep zero-dependencies |
30 | include 'Test::Exception::LessClever'; |
31 | include 'Test::Requires'; |
179ac6cc |
32 | |
3310ddf2 |
33 | my %suggests = ( |
af1c2a64 |
34 | 'Any::Moose' => 0.10, |
8e4a10a8 |
35 | |
3310ddf2 |
36 | 'MouseX::AttributeHelpers' => 0.06, |
32ec255c |
37 | 'MouseX::NativeTraits' => 1.00, |
3310ddf2 |
38 | ); |
3310ddf2 |
39 | while(my($mod, $least) = each %suggests){ |
6741954a |
40 | my $status = system $^X, '-e', <<"CHECK"; |
41 | if(eval q{ use $mod (); 1 }) { |
42 | if(eval q{ use $mod $least (); 1 }) { |
c4f4f5e3 |
43 | exit 0; # installd, and new enough |
44 | } |
45 | else { |
46 | exit 1; # installed, but too old |
47 | } |
48 | } |
49 | CHECK |
50 | |
51 | if($status != 0){ |
52 | my $ver = `$^X -e "use $mod (); print $mod->VERSION"`; |
53 | warn("\n", |
54 | "WARNING: $mod is installed, but its version ($ver) is too old (< $least).\n", |
55 | " Please update $mod after installation of Mouse.\n", |
56 | "\n" |
57 | ); |
3310ddf2 |
58 | } |
59 | } |
60 | |
ec7a9423 |
61 | # cc_want deals with the '--pp' and '--xs' options |
62 | my $use_xs = ($] >= 5.008_001 && want_xs()); |
0e81c55d |
63 | |
64 | if($use_xs){ |
2af88019 |
65 | print "Mouse configured with XS.\n"; |
bb543d7f |
66 | |
fdee07cc |
67 | use_ppport(3.19); |
8e4a10a8 |
68 | use_xshelper(); |
2af88019 |
69 | cc_warnings(); |
0e81c55d |
70 | cc_src_paths('xs-src'); |
0e81c55d |
71 | } |
758664cd |
72 | if($use_xs){ |
73 | # repeat testing |
74 | # see also ExtUtils::MM_Any::test_via_harness() |
75 | my $t_pp = q{$(FULLPERLRUN) -MExtUtils::Command::MM -e} |
76 | .q{ "do 'tool/force-pp.pl'; test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"} |
77 | .q{ $(TEST_FILES)} . "\n"; |
78 | |
79 | postamble qq{test_pp :: pure_all\n} |
80 | . qq{\t} . $t_pp; |
81 | if($Module::Install::AUTHOR) { |
82 | postamble qq{test :: test_pp }; |
83 | } |
84 | } |
0e81c55d |
85 | else{ |
7b92a82b |
86 | print "Mouse configured with Pure Perl.\n"; |
0e81c55d |
87 | } |
88 | |
125dc1a8 |
89 | tests 't/*.t t/*/*.t'; |
1e2f2888 |
90 | author_tests 'xt'; |
91 | |
125dc1a8 |
92 | repository 'git://git.moose.perl.org/Mouse.git'; |
93 | |
823419c5 |
94 | system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0 |
95 | or warn "Cannot generate Mouse::Tiny: $!"; |
96 | makemaker_args PL_FILES => { |
97 | 'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm', |
98 | }; |
99 | |
af1c2a64 |
100 | if ($Module::Install::AUTHOR) { |
101 | require 'lib/Mouse/Spec.pm'; # for the version |
121acb8a |
102 | my $require_version = Mouse::Spec->MooseVersion; |
bf9f3f91 |
103 | |
972340a6 |
104 | if ($ENV{COMPAT_TEST} |
105 | && eval { require Moose; Moose->VERSION($require_version) }) { |
92ff14d0 |
106 | print "You have Moose ", Moose->VERSION, ".\n"; |
2af88019 |
107 | do 'tool/create-moose-compatibility-tests.pl'; |
108 | # repeat testing |
109 | # see also ExtUtils::MM_Any::test_via_harness() |
110 | my $t_moose = q{$(FULLPERLRUN) -MExtUtils::Command::MM -e} |
f7f4955d |
111 | .q{ "test_harness($(TEST_VERBOSE), 'inc', '$(INST_LIB)', '$(INST_ARCHLIB)')"} |
2af88019 |
112 | .q{ xt/compat/t/*/*.t } . "\n"; |
113 | |
114 | postamble qq{test :: test_moose\n\n} |
115 | . qq{test_moose :: pure_all\n} |
116 | . qq{\t} . $t_moose; |
314fe304 |
117 | } else { |
92ff14d0 |
118 | print "You don't have Moose $require_version. skipping moose compatibility test\n"; |
314fe304 |
119 | } |
4358792d |
120 | |
f7f4955d |
121 | |
122 | # Hack to disable Test::Exception, which might pull a perl internal bug. |
123 | # See also Test::Exception::LessClever. |
124 | open my $out, '>', 'inc/Test/Exception.pm' or die $!; |
125 | print $out <<'EOT'; |
126 | package Test::Exception; # wapper to T::E::LessClever |
127 | require Test::Exception::LessClever; |
128 | $INC{'Test/Exception.pm'} = __FILE__; |
129 | sub import { |
130 | shift; |
131 | Test::Exception::LessClever->export_to_level(1, @_); |
132 | } |
133 | 1; |
134 | EOT |
135 | close $out or die $!; |
314fe304 |
136 | } |
137 | |
af1c2a64 |
138 | clean_files q{ |
139 | lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log |
140 | *.out |
141 | cover_db xs-src/*.gc{v,no,da} |
142 | }; |
1e2f2888 |
143 | |
eb88905f |
144 | WriteAll check_nmake => 0; |