Fail more gracefully on non-loadable compiled module parts
Peter Rabbitson [Wed, 4 Nov 2015 14:48:23 +0000 (15:48 +0100)]
Without this in my current system state `prove -l t/09sqlt-diagram.t` gives

...Can't load producer 'Diagram' : Error loading Diagram as SQL::Translator::Producer::Diagram :
Can't load '.../5.16.2/lib/site_perl/5.16.2/x86_64-linux-thread-multi-ld/auto/GD/GD.so' for module GD:
libgd.so.2: cannot open shared object file: No such file or directory at
.../5.16.2/lib/5.16.2/x86_64-linux-thread-multi-ld/DynaLoader.pm line 190.

lib/Test/SQL/Translator.pm
t/09sqlt-diagram.t

index 0b2ade7..5803536 100644 (file)
@@ -459,6 +459,9 @@ sub maybe_plan {
         elsif ($@ =~ /([\w\:]+ version [\d\.]+) required.+?this is only version/) {
             push @errors, $1;
         }
+        elsif ($@ =~ /Can't load .+? for module .+?DynaLoader\.pm/i ) {
+          push @errors, $module;
+        }
     }
 
     if (@errors) {
index 85d5598..0c6930b 100644 (file)
@@ -11,9 +11,10 @@ use Text::ParseWords qw(shellwords);
 BEGIN {
     maybe_plan(
         3,
-        'SQL::Translator::Parser::MySQL',
-        'SQL::Translator::Producer::Diagram',
+        'GD',
         'Graph::Directed',
+        'SQL::Translator::Producer::Diagram',
+        'SQL::Translator::Parser::MySQL',
     );
 }