1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
use strict;
use warnings;
use Test::More 0.88;
use lib 't/lib';
use Test::DZil;
sub mkconfig {
my $root = shift;
my $t = Builder->from_config( { dist_root => $root }, { add_files => { 'source/dist.ini' => simple_ini(@_) } } );
$t->build;
return $t;
}
sub testeval(&&) {
my ( $evaler, $testcode ) = @_;
local $@;
eval { $evaler->(); };
my $lasterror = $@;
$testcode->( defined $lasterror, $lasterror );
}
testeval {
mkconfig( 'corpus/dist/DZT', [ 'BrokenPlugin' => {} ] );
}
sub {
my ( $died, $error ) = @_;
subtest "BrokenPlugin" => sub {
ok( $died, "Failure occurs when a plugin is broken" );
like( $error, qr{Compilation failed in require}, "Exception is a compilation failure" );
like( $error, qr{This plugin is broken!}, "Exception reports the original problem" );
};
};
testeval {
mkconfig( 'corpus/dist/DZT', [ 'BrokenPlugin2' => {} ] );
}
sub {
my ( $died, $error ) = @_;
subtest "BrokenPlugin2" => sub {
ok( $died, "Failure occurs when a plugin is broken" );
like( $error, qr{Compilation failed in require}, "Exception is a compilation failure" );
like( $error, qr{This plugin is broken!}, "Exception reports the original problem" );
};
};
testeval {
mkconfig( 'corpus/dist/DZT', [ 'BrokenPlugin3' => {} ] );
}
sub {
my ( $died, $error ) = @_;
subtest "BrokenPlugin3" => sub {
ok( $died, "Failure occurs when a plugin is broken" );
like( $error, qr{Compilation failed}, "Exception explains that it couldn't load the plugin" );
like( $error, qr{Missing right curly or square bracket}, "Exception reports the original problem" );
};
};
testeval {
mkconfig( 'corpus/dist/DZT', [ 'BrokenPlugin4' => {} ] );
}
sub {
my ( $died, $error ) = @_;
subtest "BrokenPlugin4" => sub {
ok( $died, "Failure occurs when a plugin is broken" );
like( $error, qr{Can't locate}, "Exception explains that it couldn't load the plugin 2-layers down" );
like( $error, qr{Some/Package/That/Does/Not/Exist/}, "Exception reports the original problem" );
};
};
testeval {
mkconfig( 'corpus/dist/DZT', [ 'Not::A::Plugin' => {} ] );
}
sub {
my ( $died, $error ) = @_;
subtest "Not::A::Plugin" => sub {
ok( $died, "Failure occurs when a plugin is missing" );
like( $error, qr{Not::A::Plugin.*isn't installed}, "Exception explains that the plugin is not installed" );
like( $error, qr{dzil authordeps}, "Exception suggests using authordeps" );
};
};
done_testing;
|