Added a test for erroneous whitespace that screws up POD
This commit is contained in:
parent
448448e451
commit
e35760ce6a
1 changed files with 66 additions and 0 deletions
66
t/Whitespace.t
Normal file
66
t/Whitespace.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2005 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use FindBin qw($Bin);
|
||||
use lib "$FindBin::Bin/lib";
|
||||
|
||||
use File::Find;
|
||||
use Test::More tests => 1; # increment this value for each test you create
|
||||
use WebGUI::Test;
|
||||
|
||||
my (@modules, @failedModules);
|
||||
my $wgLib = WebGUI::Test->lib;
|
||||
File::Find::find( \&getWebGUIModules, $wgLib);
|
||||
|
||||
my $numFailedModules = checkModules();
|
||||
is($numFailedModules, 0, "No erroneous whitespace in or before POD");
|
||||
|
||||
if ($numFailedModules) {
|
||||
print "\n# The folling modules have erroneous whitespace in or before POD:\n";
|
||||
foreach my $module (@failedModules) {
|
||||
print "# - $module\n";
|
||||
}
|
||||
print "# Summary: $numFailedModules module".
|
||||
($numFailedModules == 1 ? '' : 's')." failed\n\n";
|
||||
}
|
||||
|
||||
#----------------------------------------
|
||||
sub getWebGUIModules {
|
||||
push( @modules, $File::Find::name ) if /\.pm$/;
|
||||
}
|
||||
|
||||
sub checkModules {
|
||||
foreach my $module (@modules) {
|
||||
open(FILE, "< $module") or die "Can't open file $module";
|
||||
my @content = <FILE>;
|
||||
close FILE;
|
||||
|
||||
if (checkContent(\@content)) {
|
||||
push(@failedModules, $module);
|
||||
}
|
||||
}
|
||||
return scalar(@failedModules);
|
||||
}
|
||||
|
||||
sub checkContent {
|
||||
my $content = shift;
|
||||
my @content = @{$content};
|
||||
|
||||
my $badEnd = 0;
|
||||
foreach my $line (@content) {
|
||||
my $isPodWord = ($line =~ m/^=/);
|
||||
return 1 if ($isPodWord && $badEnd);
|
||||
$badEnd = ($line =~ m/[ \t]$/);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue