X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=maint%2FMakefile.PL.inc%2F11_authortests.pl;h=dc3eb4cebf537dfe739cb5c96c6a8e996288bea4;hb=3ba58fe4768f0cca6731dad6ac669b5ab049980e;hp=b8f00b40bc593a8d03041d4462a9d543df17b8a3;hpb=df65d4da1dbe1d485bb7a35f9e71898d1193e277;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/maint/Makefile.PL.inc/11_authortests.pl b/maint/Makefile.PL.inc/11_authortests.pl index b8f00b4..dc3eb4c 100644 --- a/maint/Makefile.PL.inc/11_authortests.pl +++ b/maint/Makefile.PL.inc/11_authortests.pl @@ -1,22 +1,46 @@ -# temporary(?) until I get around to fix M::I wrt xt/ -# needs Module::Install::AuthorTests -eval { - # this should not be necessary since the autoloader is supposed - # to work, but there were reports of it failing - require Module::Install::AuthorTests; - recursive_author_tests (qw/xt/); - 1; -} || do { - if (! $args->{skip_author_deps}) { - my $err = $@; - - # better error message in case of missing dep - eval { require Module::Install::AuthorTests } - || die "\nYou need Module::Install::AuthorTests installed to run this Makefile.PL in author mode (or add --skip-author-deps):\n\n$@\n"; - - die $err; - } -}; +require File::Spec; +require File::Find; + +my $xt_dirs; +File::Find::find(sub { + return if $xt_dirs->{$File::Find::dir}; + $xt_dirs->{$File::Find::dir} = 1 if ( + $_ =~ /\.t$/ and -f $_ + ); +}, 'xt'); + +my @xt_tests = map { File::Spec->catfile($_, '*.t') } sort keys %$xt_dirs; + +# this will add the xt tests to the `make test` target among other things +Meta->tests(join (' ', map { $_ || () } Meta->tests, @xt_tests ) ); + +# inject an explicit xt test run for the create_distdir target +postamble <<"EOP"; + +create_distdir : test_xt + +test_xt : pm_to_blib +@{[ + # When xt tests are explicitly requested, we want to run with RELEASE_TESTING=1 + # so that all optdeps are turned into a hard failure + # However portably modifying ENV for a single command is surprisingly hard + # So instead we (ab)use perl's ability to stack -e options, and simply modify + # the ENV from within perl itself + $mm_proto->test_via_harness( + # perl cmd + join( ' ', + '$(ABSPERLRUN)', + # $'s need to be escaped (doubled) before inserting into the Makefile + map { $mm_proto->quote_literal($_) } qw(-e $$ENV{RELEASE_TESTING}=1;) + ), + # test list + join( ' ', + map { $mm_proto->quote_literal($_) } @xt_tests + ), + ) +]} + +EOP # keep the Makefile.PL eval happy 1;