From: Matt S Trout Date: Wed, 22 Jun 2011 13:06:08 +0000 (+0100) Subject: add test_recursive method for easier multi-directory testing, factor out 'start every... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ccb22fec4bcc599cf272a6fb339c7217550d8748;p=scpubgit%2FTest-Harness-Selenium.git add test_recursive method for easier multi-directory testing, factor out 'start everything' into its own method --- diff --git a/lib/Test/Harness/Selenium.pm b/lib/Test/Harness/Selenium.pm index 3937119..added88 100644 --- a/lib/Test/Harness/Selenium.pm +++ b/lib/Test/Harness/Selenium.pm @@ -140,21 +140,44 @@ sub stop_app_server { } } -sub test_directory { - my ($self, $dir) = @_; +sub start_everything { + my ($self) = @_; if(!exists $self->{app_server_proc}) { $self->start_app_server; } if($self->{selenium_rc}{start} && !$self->{selenium_rc}{selenium_server_proc}) { $self->start_selenium_server; } - my @tests = File::Find::Rule->file()->name('*.html')->in($dir); +} + +sub test_recursive { + my ($self, @proto) = @_; + my (@files, @dirs); + if (@proto) { + @files = grep /\.html$/, @proto; + @dirs = grep !/\.htmL$/, @proto; + } else { + $0 =~ /^(t\/.*).t$/ or die "Can't guess directory from $0"; + @dirs = ($1); + } + $self->start_everything; + $self->test_file($_) for @files; + $self->test_directory($_) for + sort map File::Find::Rule->directory->in($_), @dirs; +} + +sub test_directory { + my ($self, $dir) = @_; + $self->start_everything; + my @tests = + sort File::Find::Rule->file->name('*.html')->maxdepth(1)->in($dir); + for my $test (@tests) { - $self->run_tests_for($test); + $self->test_file($test); } } -sub run_tests_for { +sub test_file { my ($self, $html_file) = @_; my $rows = $self->get_rows_for($html_file); $self->{src}->run_test_table($rows);