Permalink
Browse files

Perl::Critic clean-up of test suites.

  • Loading branch information...
1 parent 70f6e31 commit 93f34fa9e8c65cefadb90a7bf31e70e08ed850b1 @rjray committed Feb 17, 2014
View
@@ -1,54 +1,63 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
use strict;
-use vars qw(@MODULES @APACHE_MODULES $do_apache $do_libxml);
+use warnings;
+use Module::Load;
use Test::More;
# Verify that the individual modules will load
-BEGIN
-{
- @MODULES = qw(
- RPC::XML
- RPC::XML::Client
- RPC::XML::Parser
- RPC::XML::Parser::XMLLibXML
- RPC::XML::Parser::XMLParser
- RPC::XML::ParserFactory
- RPC::XML::Procedure
- RPC::XML::Server
- );
- @APACHE_MODULES = qw(Apache::RPC::Server Apache::RPC::Status);
-
- # If mod_perl is not available, Apache::RPC::Server cannot be blamed
- eval "use Apache";
- $do_apache = $@ ? 0 : 1;
-
- # If XML::LibXML is not installed, also skip RPC::XML::Parser::XMLLibXML
- eval "use XML::LibXML";
- $do_libxml = $@ ? 0 : 1;
-
- plan tests => (scalar(@MODULES) + scalar(@APACHE_MODULES));
-}
+my @MODULES = qw(
+ RPC::XML
+ RPC::XML::Client
+ RPC::XML::Parser
+ RPC::XML::Parser::XMLParser
+ RPC::XML::ParserFactory
+ RPC::XML::Procedure
+ RPC::XML::Server
+);
+my @APACHE_MODULES = qw(Apache::RPC::Server Apache::RPC::Status);
+my @LIBXML_MODULES = qw(RPC::XML::Parser::XMLLibXML);
+
+# If mod_perl is not available, Apache::RPC::Server cannot be blamed
+my $do_apache = eval { load Apache; 1; };
+
+# If XML::LibXML is not installed, also skip RPC::XML::Parser::XMLLibXML
+my $do_libxml = eval { load XML::LibXML; 1; };
+
+plan tests => (@MODULES + @APACHE_MODULES + @LIBXML_MODULES);
# Core modules
for my $module (@MODULES)
{
- SKIP: {
- skip 'XML::LibXML not installed', 1
- if (($module eq 'RPC::XML::Parser::XMLLibXML') &&
- (! $do_libxml));
+ use_ok $module;
+}
- use_ok($module);
+# Test these only if XML::LibXML is available
+SKIP: {
+ if (! $do_libxml)
+ {
+ skip 'No XML::LibXML detected', scalar @LIBXML_MODULES;
+ }
+
+ for my $module (@LIBXML_MODULES)
+ {
+ use_ok $module;
}
}
# Test these only if Apache (v1) is available
SKIP: {
- skip "No mod_perl 1.X detected", scalar(@APACHE_MODULES) unless $do_apache;
+ if (! $do_apache)
+ {
+ skip 'No mod_perl 1.X detected', scalar @APACHE_MODULES;
+ }
- use_ok($_) for (@APACHE_MODULES);
+ for my $module (@APACHE_MODULES)
+ {
+ use_ok $module;
+ }
}
exit 0;
Oops, something went wrong.

0 comments on commit 93f34fa

Please sign in to comment.