syntax check is faster, always runs, and tests for warnings as well
This commit is contained in:
parent
ca0bfd54dd
commit
4eada61d8d
1 changed files with 44 additions and 16 deletions
|
|
@ -18,27 +18,55 @@ use WebGUI::Session;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
|
|
||||||
plan skip_all => 'set TEST_SYNTAX to enable this test' unless $ENV{TEST_SYNTAX};
|
|
||||||
|
|
||||||
my @modules;
|
|
||||||
my $wgLib = WebGUI::Test->lib;
|
my $wgLib = WebGUI::Test->lib;
|
||||||
my $wgRoot = WebGUI::Test->root;
|
my @modules = findModules($wgLib);
|
||||||
#diag("Checking modules in $wgLib");
|
my @scripts = findScripts(WebGUI::Test->root . '/docs/upgrades', WebGUI::Test->root . '/sbin');
|
||||||
File::Find::find( \&getWebGUIModules, $wgLib, File::Spec->join($wgRoot, 'sbin'), File::Spec->join($wgRoot, 'docs', 'upgrades') );
|
|
||||||
|
|
||||||
my $numTests = scalar @modules;
|
plan tests => 2 * (scalar @modules + scalar @scripts);
|
||||||
|
|
||||||
plan tests => $numTests;
|
foreach my $library (@modules) {
|
||||||
|
my $warnings = '';
|
||||||
|
local $^W = 1;
|
||||||
|
local $SIG{__WARN__} = sub {
|
||||||
|
$warnings .= shift;
|
||||||
|
};
|
||||||
|
eval {
|
||||||
|
require $library;
|
||||||
|
};
|
||||||
|
chomp $warnings;
|
||||||
|
is($@, '', "$library compiles successfully");
|
||||||
|
is($warnings, '', "$library compiles without warnings");
|
||||||
|
}
|
||||||
|
|
||||||
#diag("Planning on $numTests tests");
|
for my $script (@scripts) {
|
||||||
|
my $cmd = "$^X -wcI'$wgLib' $script 2>&1";
|
||||||
foreach my $package (@modules) {
|
my $output = `$cmd`;
|
||||||
my $command = "$^X -I$wgLib -wc $package 2>&1";
|
is($?, 0, "$script compiles successfully");
|
||||||
my $output = `$command`;
|
chomp $output;
|
||||||
is($?, 0, "syntax check for $package");
|
$output =~ s/^\Q$script\E (?:had compilation errors\.|syntax OK)$//m;
|
||||||
|
is($output, '', "$script compiles without warnings");
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------
|
#----------------------------------------
|
||||||
sub getWebGUIModules {
|
sub findModules {
|
||||||
push( @modules, $File::Find::name ) if /\.p[ml]$/;
|
my $libDir = shift;
|
||||||
|
my @modules;
|
||||||
|
File::Find::find( {
|
||||||
|
no_chdir => 1,
|
||||||
|
wanted => sub {
|
||||||
|
next unless $File::Find::name =~ /\.pm$/;
|
||||||
|
my $lib = File::Spec->abs2rel($File::Find::name, $libDir);
|
||||||
|
push @modules, $lib;
|
||||||
|
},
|
||||||
|
}, $libDir);
|
||||||
|
return @modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub findScripts {
|
||||||
|
my @scripts;
|
||||||
|
for my $dir (@_) {
|
||||||
|
push @scripts, glob("$dir/*.pl");
|
||||||
|
}
|
||||||
|
return @scripts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue