Thanks to a suggestion by David Wheeler, I was able to build a tool that
works for me. Here's the simple testing script I came up with. You are
free to use and modify it for your own purposes:
#!/usr/bin/perl -w
# Check all our static HTML pages in a www tree to see if they are made of valid HTML
# originally by Mark Stosberg on 02/05/04
# based on code by Andy Lester
use Test::More;
use strict;
use XML::LibXML;
use File::Spec;
use File::Find::Rule;
my $startpath = $ARGV[0] || die "usage: $0 path/to/www";
my $rule = File::Find::Rule->new;
$rule->or( $rule->new->directory->name('CVS')->prune->discard,
# $rule->new->directory->name('Templates')->prune->discard,
$rule->new->file->name('*.html') );
my @html = $rule->in( $startpath );
my $nfiles = scalar @html;
# Only try to run the tests if we have any static files
if ($nfiles) {
plan( tests => $nfiles );
for my $filename ( @html ) {
eval {
my $parser = XML::LibXML->new;
$parser->validation(1);
$parser->parse_file($filename);
};
is($@,'', "$filename is valid XHTML");
}
}
else {
diag " ( No static files found. No tests ran. ) ";
}
__END__
Mark
--
. . . . . . . . . . . . . . . . . . . . . . . . . . .
Mark Stosberg Principal Developer
[EMAIL PROTECTED] Summersault, LLC
765-939-9301 ext 202 database driven websites
. . . . . http://www.summersault.com/ . . . . . . . .