Rewrite all Makefile oneliners in terms of EU::MM::oneliner
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 11_authortests.pl
1 require File::Spec;
2 require File::Find;
3
4 my $xt_dirs;
5 File::Find::find(sub {
6   return if $xt_dirs->{$File::Find::dir};
7   $xt_dirs->{$File::Find::dir} = 1 if (
8     $_ =~ /\.t$/ and -f $_
9   );
10 }, 'xt');
11
12 my @xt_tests = map { File::Spec->catfile($_, '*.t') } sort keys %$xt_dirs;
13
14 # this will add the xt tests to the `make test` target among other things
15 Meta->tests(join (' ', map { $_ || () } Meta->tests, @xt_tests ) );
16
17 # inject an explicit xt test run for the create_distdir target
18 postamble <<"EOP";
19
20 create_distdir : test_xt
21
22 test_xt : pm_to_blib
23 @{[
24   # When xt tests are explicitly requested, we want to run with RELEASE_TESTING=1
25   # so that all optdeps are turned into a hard failure
26   # However portably modifying ENV for a single command is surprisingly hard
27   # So instead we (ab)use perl's ability to stack -e options, and simply modify
28   # the ENV from within perl itself
29   $mm_proto->test_via_harness(
30     # perl cmd
31     join( ' ',
32       '$(ABSPERLRUN)',
33       # $'s need to be escaped (doubled) before inserting into the Makefile
34       map { $mm_proto->quote_literal($_) } qw(-e $$ENV{RELEASE_TESTING}=1;) 
35     ),
36     # test list
37     join( ' ',
38       map { $mm_proto->quote_literal($_) } @xt_tests
39     ),
40   )
41 ]}
42
43 EOP
44
45 # keep the Makefile.PL eval happy
46 1;