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