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: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
Test dir grabber:#!/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"; } }
Maybe you can adopt this to your situation. Hope this helps!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; }
In reply to Re: use Test; and output
by tphyahoo
in thread use Test; and output
by mrborisguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |