Move the SQLite test dependency specification to optdeps
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 12_authordeps.pl
CommitLineData
fc4b0448 1my ($optdep_msg, $opt_testdeps);
2
3if ($args->{skip_author_deps}) {
4 $optdep_msg = <<'EOW';
5
6******************************************************************************
7******************************************************************************
8*** ***
9*** IGNORING AUTHOR MODE: no optional test dependencies will be forced. ***
10*** ***
11*** If you are using this checkout with the intention of submitting a DBIC ***
12*** patch, you are *STRONGLY ENCOURAGED* to install all dependencies, so ***
13*** that every possible unit-test will run. ***
14*** ***
15******************************************************************************
16******************************************************************************
17
18EOW
19}
20else {
21 $optdep_msg = <<'EOW';
22
23******************************************************************************
24******************************************************************************
25*** ***
26*** AUTHOR MODE: all optional test dependencies converted to hard requires ***
df65d4da 27*** ( to disable re-run Makefile.PL with --skip-author-deps ) ***
fc4b0448 28*** ***
29******************************************************************************
30******************************************************************************
31
32EOW
33
34 require DBIx::Class::Optional::Dependencies;
fc4b0448 35
36 # exclude the rdbms_* groups which are for DBIC users
4841171c 37 # and the moose-related stuff iff we are under 5.8.3
31c31b8d 38 $opt_testdeps = DBIx::Class::Optional::Dependencies->req_list_for([
39 grep {
4841171c 40 !/^rdbms_|^dist_/
41 and
42 ($] > 5.008002 or !/^ (?: test_ )? (?: admin | admin_script | replicated ) $/x )
31c31b8d 43 } keys %{DBIx::Class::Optional::Dependencies->req_group_list}
44 ]);
fc4b0448 45
7975645b 46 # this one is "special" - we need it both in optdeps and as a hard dep
47 delete $opt_testdeps->{'DBD::SQLite'};
48
fc4b0448 49 print "Including all optional deps\n";
50 $reqs->{test_requires} = {
51 %{$reqs->{test_requires}},
52 %$opt_testdeps
53 };
54}
55
56# nasty hook into both M::AI init and the prompter, so that the optdep message
57# comes at the right places (on top and then right above the prompt)
58{
59 require Module::AutoInstall;
60 no warnings 'redefine';
61 no strict 'refs';
62
63 for (qw/_prompt import/) {
64 my $meth = "Module::AutoInstall::$_";
65 my $orig = \&{$meth};
66 *{$meth} = sub {
67 print $optdep_msg;
68 goto $orig;
69 };
70 }
71}
72
73# this will run after the Makefile is written and the main Makefile.PL terminates
74#
75END {
745b54f5 76 # shit already hit the fan
77 return if $?;
78
fc4b0448 79 # Re-write META.yml at the end to _exclude_ all forced build-requires (we do not
80 # want to ship this) We are also not using M::I::AuthorRequires as this will be
81 # an extra dep, and deps in Makefile.PL still suck
82 # Also always test the result so we stop shipping borked dependency lists to CPAN
83
84 # FIXME test_requires is not yet part of META
85 my %original_build_requires = ( %$build_requires, %$test_requires );
86 my @all_build_requires = @{delete Meta->{values}{build_requires}||[]};
87 my %removed_build_requires;
88
89 for (@all_build_requires) {
90 if ($original_build_requires{$_->[0]}) {
91 push @{Meta->{values}{build_requires}}, $_;
92 }
93 else {
94 $removed_build_requires{$_->[0]} = $_->[1]
95 unless $_->[0] eq 'ExtUtils::MakeMaker';
96 }
97 }
98
99 if (keys %removed_build_requires) {
100 print "Regenerating META with author requires excluded\n";
3440100b 101 # M::I understands unicode in meta but does not write with the right
102 # layers - fhtagn!!!
103 local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /Wide character in print/ };
fc4b0448 104 Meta->write;
105 }
106
204f57da 107 # strip possible crlf from META
108 if ($^O eq 'MSWin32' or $^O eq 'cygwin') {
109 local $ENV{PERLIO} = 'unix';
110 system( $^X, qw( -MExtUtils::Command -e dos2unix -- META.yml), );
111 }
112
fc4b0448 113 # test that we really took things away (just in case, happened twice somehow)
114 if (! -f 'META.yml') {
115 warn "No META.yml generated?! aborting...\n";
116 unlink 'Makefile';
117 exit 1;
118 }
119 my $meta = do { local @ARGV = 'META.yml'; local $/; <> };
120
90d4cbcc 121 $meta =~ /^\Qname: DBIx-Class\E$/m or do {
122 warn "Seemingly malformed META.yml...?\n";
123 unlink 'Makefile';
124 exit 1;
125 };
126
fc4b0448 127 # this is safe as there is a fatal check earlier in the main Makefile.PL
65a231a8 128 # to make sure there are no duplicates (i.e. $opt_testdeps does not contain
fc4b0448 129 # any real dependencies)
130 my @illegal_leftovers = grep
131 { $meta =~ /^ \s+ \Q$_\E \: \s+ /mx }
132 ( sort keys %$opt_testdeps )
133 ;
134
135 if (@illegal_leftovers) {
136 warn join ("\n",
137 "\n\nFATAL FAIL! It looks like some author dependencies made it to the META.yml:\n",
138 map { "\t$_" } @illegal_leftovers
139 ) . "\n\n";
140 unlink 'Makefile';
141 exit 1;
142 }
143}
144
145# keep the Makefile.PL eval happy
1461;