Subject: | Test script to detect missing modules |
I've run into an error that turned out to be a colleague renaming a
module used, but the corresponding configuration was not updated. To
prevent that, I've written a test script that checks the configuration
for modules which may not exist.
This might be a good thing to add by default to a new installation.
Something like:
use 5.10.0;
use strict;
use warnings;
use Test::More 0.61;
use lib 'lib';
use_ok 'MyApp';
my $config = MyApp->config;
foreach my $key (%{ $config }) {
if (ref($config->{$key}) eq 'HASH') {
if ($key =~ /^Plugin::/) {
use_ok "Catalyst::${key}" or BAIL_OUT "Missing module";
} elsif ($key =~ /^(Model|View|Controller)::/) {
my $name = $config->{name} // "MyApp";
use_ok "${name}::${key}" or BAIL_OUT "Missing module";
}
}
}
done_testing;