Move a number of tests to xt, restructure extra lists
[dbsrgits/DBIx-Class.git] / maint / Makefile.PL.inc / 11_authortests.pl
1 require File::Spec;
2 require File::Find;
3
4 my $xt_dist_dirs;
5 File::Find::find(sub {
6   return if $xt_dist_dirs->{$File::Find::dir};
7   $xt_dist_dirs->{$File::Find::dir} = 1 if (
8     $_ =~ /\.t$/ and -f $_
9   );
10 }, 'xt/dist');
11
12 my @xt_dist_tests = map { File::Spec->catfile($_, '*.t') } sort keys %$xt_dist_dirs;
13
14 # inject an explicit xt test run, mainly to check the contents of
15 # lib and the generated POD's *before* anything is copied around
16 #
17 # at the end rerun the whitespace and footer tests in the distdir
18 # to make sure everything is pristine
19 postamble <<"EOP";
20
21 dbic_clonedir_copy_generated_pod : test_xt
22
23 test_xt : pm_to_blib
24 @{[
25   # When xt tests are explicitly requested, we want to run with RELEASE_TESTING=1
26   # so that all optdeps are turned into a hard failure
27   # However portably modifying ENV for a single command is surprisingly hard
28   # So instead we (ab)use perl's ability to stack -e options, and simply modify
29   # the ENV from within perl itself
30   $mm_proto->test_via_harness(
31     # perl cmd
32     join( ' ',
33       '$(ABSPERLRUN)',
34       map { $mm_proto->quote_literal($_) } qw(-e $ENV{RELEASE_TESTING}=1;$ENV{DBICTEST_NO_MAKEFILE_VERIFICATION}=1;)
35     ),
36     # test list
37     join( ' ',
38       map { $mm_proto->quote_literal($_) } @xt_dist_tests
39     ),
40   )
41 ]}
42
43 create_distdir : dbic_distdir_retest_ws_and_footers
44
45 dbic_distdir_retest_ws_and_footers :
46 \t@{[
47   $mm_proto->cd (
48     '$(DISTVNAME)',
49     $mm_proto->test_via_harness(
50       # perl cmd
51       join( ' ',
52         '$(ABSPERLRUN)',
53         map { $mm_proto->quote_literal($_) } qw(-Ilib -e $ENV{RELEASE_TESTING}=1;$ENV{DBICTEST_NO_MAKEFILE_VERIFICATION}=1;)
54       ),
55       'xt/dist/postdistdir/*.t',
56     )
57   )
58 ]}
59
60 EOP
61
62 # keep the Makefile.PL eval happy
63 1;