BAIL_OUT if any of the classes warn on load (catches things like no methods for an...
Dave Rolsky [Fri, 4 Feb 2011 22:33:21 +0000 (16:33 -0600)]
moose-class/exercises/t/lib/MooseClass/Tests.pm

index c3a333a..f47c867 100644 (file)
@@ -369,8 +369,16 @@ sub has_meta {
 
     local $Test::Builder::Level = $Test::Builder::Level + 1;
 
-    use_ok($package)
-        or BAIL_OUT("$package cannot be loaded");
+    {
+        my @warn;
+        local $SIG{__WARN__} = sub { push @warn, @_ };
+
+        use_ok($package)
+            or BAIL_OUT("$package cannot be loaded");
+
+        BAIL_OUT("Warning when loading $package: @warn")
+            if @warn;
+    }
 
     ok( $package->can('meta'), "$package has a meta() method" )
         or BAIL_OUT(