Ensure describe_environment does not break its output in half
[dbsrgits/DBIx-Class.git] / t / 00describe_environment.t
index a88c187..ed0378b 100644 (file)
@@ -57,7 +57,7 @@ use List::Util 'max';
 use ExtUtils::MakeMaker;
 
 use DBICTest::RunMode;
-use DBICTest::Util 'visit_namespaces';
+use DBIx::Class::_Util 'visit_namespaces';
 use DBIx::Class::Optional::Dependencies;
 
 my $known_paths = {
@@ -167,6 +167,8 @@ find({
   wanted => sub {
     -f $_ or return;
 
+    $_ =~ m|lib/DBIx/Class/_TempExtlib| and return;
+
     # can't just `require $fn`, as we need %INC to be
     # populated properly
     my ($mod) = $_ =~ /^ lib [\/\\] (.+) \.pm $/x
@@ -192,6 +194,7 @@ my $load_weights = {
 
 my @known_modules = sort
   { ($load_weights->{$b}||0) <=> ($load_weights->{$a}||0) }
+  qw( Data::Dumper ),
   keys %{
     DBIx::Class::Optional::Dependencies->req_list_for([
       grep
@@ -498,6 +501,11 @@ $final_out .= "=============================\n$discl\n\n";
 
 diag $final_out;
 
+# *very* large printouts may not finish flushing before the test exits
+# injecting a <testname> ... ok in the middle of the diag
+# http://www.cpantesters.org/cpan/report/fbdac74c-35ca-11e6-ab41-c893a58a4b8c
+select( undef, undef, undef, 0.2 );
+
 exit 0;
 
 
@@ -597,12 +605,21 @@ sub module_found_at_inc_index {
 
   my $fn = module_notional_filename($mod);
 
-  for my $i ( 0 .. $#$inc_dirs ) {
+  # trust INC if it specifies an existing path
+  if( -f ( my $existing_path = abs_unix_path( $INC{$fn} ) ) ) {
+    for my $i ( 0 .. $#$inc_dirs ) {
+
+      # searching from here on out won't mean anything
+      # FIXME - there is actually a way to interrogate this safely, but
+      # that's a fight for another day
+      return undef if length ref $inc_dirs->[$i];
 
-    # searching from here on out won't mean anything
-    # FIXME - there is actually a way to interrogate this safely, but
-    # that's a fight for another day
-    return undef if length ref $inc_dirs->[$i];
+      return $i
+        if 0 == index( $existing_path, abs_unix_path( $inc_dirs->[$i] ) . '/' );
+    }
+  }
+
+  for my $i ( 0 .. $#$inc_dirs ) {
 
     if (
       -d $inc_dirs->[$i]