X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FAuthorCheck.pm;h=4507837a484a28d34227b0597161b605154e2eaa;hb=38ed54cd3980bd344e13fad27ed11b935ae932aa;hp=4d2a6f618b84cc40988d90378bdb02e6ef4fb998;hpb=ab340f7f379ff7c39908a01e82ca337009275eb1;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/lib/DBICTest/AuthorCheck.pm b/t/lib/DBICTest/AuthorCheck.pm index 4d2a6f6..4507837 100644 --- a/t/lib/DBICTest/AuthorCheck.pm +++ b/t/lib/DBICTest/AuthorCheck.pm @@ -27,24 +27,36 @@ sub _check_author_makefile { my $root = _find_co_root() or return; + my $optdeps = file('lib/DBIx/Class/Optional/Dependencies.pm'); + # not using file->stat as it invokes File::stat which in turn breaks stat(_) - my ($mf_pl_mtime, $mf_mtime) = ( map + my ($mf_pl_mtime, $mf_mtime, $optdeps_mtime) = ( map { (stat ($root->file ($_)) )[9] } - qw/Makefile.PL Makefile/ + (qw|Makefile.PL Makefile|, $optdeps) ); return unless $mf_pl_mtime; # something went wrong during co_root detection ? - if ( - not -d $root->subdir ('inc') - or - not $mf_mtime - or - $mf_mtime < $mf_pl_mtime - ) { - print STDERR <<'EOE'; + my @fail_reasons; + if(not -d $root->subdir ('inc')) { + push @fail_reasons, "Missing ./inc directory"; + } + if(not $mf_mtime) { + push @fail_reasons, "Missing ./Makefile"; + } + else { + if($mf_mtime < $mf_pl_mtime) { + push @fail_reasons, "./Makefile.PL is newer than ./Makefile"; + } + if($mf_mtime < $optdeps_mtime) { + push @fail_reasons, "./$optdeps is newer than ./Makefile"; + } + } + + if (@fail_reasons) { + print STDERR <<'EOE'; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -54,37 +66,52 @@ sub _check_author_makefile { We have a number of reasons to believe that this is a development checkout and that you, the user, did not run `perl Makefile.PL` before using this code. You absolutely _must_ perform this step, -as not doing so often results in a lot of wasted time for other -contributors trying to assit you with "it broke!" problems. +and ensure you have all required dependencies present. Not doing +so often results in a lot of wasted time for other contributors +trying to assit you with spurious "its broken!" problems. If you are seeing this message unexpectedly (i.e. you are in fact -attempting a regular installation be it through CPAN or manually, -set the variable DBICTEST_NO_MAKEFILE_VERIFICATION to a true value -so you can continue. Also _make_absolutely_sure_ to report this to -either the mailing list or to the irc channel as described in +attempting a regular installation be it through CPAN or manually), +please report the situation to either the mailing list or to the +irc channel as described in http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class.pm#GETTING_HELP/SUPPORT -Failure to do this will make us believe that all these checks are -indeed foolproof and we will remove the ability to override this -entirely. - The DBIC team +Reasons you received this message: EOE + foreach my $r (@fail_reasons) { + print STDERR " * $r\n"; + } + print STDERR "\n\n\n"; + exit 1; } } +# Mimic $Module::Install::AUTHOR +sub is_author { + + my $root = _find_co_root() + or return undef; + + return ( + ( not -d $root->subdir ('inc') ) + or + ( -e $root->subdir ('inc')->file ($^O eq 'VMS' ? '_author' : '.author') ) + ); +} + # Try to determine the root of a checkout/untar if possible # or return undef sub _find_co_root { my @mod_parts = split /::/, (__PACKAGE__ . '.pm'); - my $rel_path = file (@mod_parts); + my $rel_path = join ('/', @mod_parts); # %INC stores paths with / regardless of OS return undef unless ($INC{$rel_path}); @@ -93,7 +120,7 @@ sub _find_co_root { # - do 'cd ..' as many times as necessary to get to t/lib/../.. my $root = dir ($INC{$rel_path}); - for (0 .. @mod_parts + 1) { + for (1 .. @mod_parts + 2) { $root = $root->parent; }