I had pretty much this problem, with a program that sucked some html in, made many transformations, and outputted it, on thousands of files. The problem was, how to verify all the edge cases did what I wanted, all of what I wanted, and nothing but what I wanted. What I wound up doing is basically, a test script that looks like
perl fix_fonts_test.pl C:\thomasdata\thomasprojects\fixhtml\test\fonts +\stripStandard Fixtotext perl fix_fonts_test.pl C:\thomasdata\thomasprojects\fixhtml\test\fonts +\toClassWeiss Fixtoclassweiss perl fix_fonts_test.pl C:\thomasdata\thomasprojects\fixhtml\test\fonts +\toClassRot Fixtoclassrot perl fix_fonts_test.pl C:\thomasdata\thomasprojects\fixhtml\test\fonts +\toClassKlein Fixtoclassklein perl fix_fonts_test.pl C:\thomasdata\thomasprojects\fixhtml\test\fonts +\toClassesKleinNGrau Fixtoclasskleinandgrau
The first arg is a test target directory, the second arg is a "transformer" object. In the test directory, I had various subdirectories, some of which were just placeholders, while others had a "before.html" and "after.html" file inside. The ones with before and after files were identified as test target directories. The script transformed the "before", and compared compared the rest to the "after." Actually, to get this to work I had to put both before and after into a canonical format by trimming whitespace, other little tidbits, but that's the basic idea. Test script:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use File::Find; #custom modules use Modules::Htmlripper::Noreplaceroot::Fixtotext; use Modules::Htmlripper::Gotreplaceroot::Fixtoclassweiss; use Modules::Htmlripper::Gotreplaceroot::Fixtoclassrot; use Modules::Htmlripper::Gotreplaceroot::Fixtoclassklein; use Modules::Htmlripper::Gotnestedreplaceroot::Fixtoclasskleinandgrau; use Modules::Filecontrol qw(get_files); my $test_dir = shift or die "no test directory specified file\n"; opendir (DIR, $test_dir) or die "couldn't open directory: $test_dir"; closedir DIR; my $ripperClass = shift or die "no HTML ripper class specified"; my @test_dirs = Filecontrol::get_test_dirs($test_dir); my $ripper = $ripperClass->new(); #keys are directory names. for ( @test_dirs ) { print "Testing $ripperClass against directory $_: \n"; $ripper->test_dir($_); my $result = $ripper->test(); if ($result) { print "ok\n"; } else { print "not ok\n"; } }
Test dir grabber:
sub get_test_dirs { my $dir = shift or die "no directory specified."; opendir (DIR, $dir) or die "couldn't open directory: $dir"; my @directories_to_search = ("$dir"); my %dirs = (); find( sub { if (-d $File::Find::name) { # it's a dir my $current_dir = $File::Find::name; if ( (-f "$current_dir" . '/before.html') && (-f "$cur +rent_dir" . '/after.html') ) { #before and after files exist $dirs{$current_dir} = 1; } #end check if file } # end check if directory }, @directories_to_search ); my @dirs = keys %dirs; return @dirs; }
Maybe you can adopt this to your situation. Hope this helps!

In reply to Re: use Test; and output by tphyahoo
in thread use Test; and output by mrborisguy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.