From 1063657c9145eed77b9228066488c91880093391 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Mon, 28 Feb 2011 00:32:04 +0000 Subject: refactor everything to make tests more test-like. --- testing/lib/Test/Irssi/Driver.pm | 40 ++++++++++++++++++++++------------------ testing/lib/Test/Irssi/Test.pm | 14 +++++--------- 2 files changed, 27 insertions(+), 27 deletions(-) (limited to 'testing/lib/Test/Irssi') diff --git a/testing/lib/Test/Irssi/Driver.pm b/testing/lib/Test/Irssi/Driver.pm index 80199ef..3b6000b 100644 --- a/testing/lib/Test/Irssi/Driver.pm +++ b/testing/lib/Test/Irssi/Driver.pm @@ -39,6 +39,7 @@ sub START { InputEvent => "got_terminal_stdin", Filter => POE::Filter::Stream->new(), ); + $self->log("stdio options: " . dump(@stdio_options)); # Start the terminal reader/writer. @@ -75,7 +76,7 @@ sub STOP { $self->parent->_logfile_fh->close(); say "\n\n"; - $self->parent->summarise_test_results(); + #$self->parent->summarise_test_results(); } ### Handle terminal STDIN. Send it to the background program's STDIN. @@ -161,32 +162,35 @@ sub testing_ready { # begin by fetching a test from the pending queue. $self->log("Starting to run tests"); $self->log("-" x 80); - $self->parent->run_tests(); + $self->parent->run_test; +} + +sub execute_test { + my ($self, $heap, $kernel, $test) = @_[OBJECT,HEAP, KERNEL, ARG0]; + # do some stuff here to evaluate it. + + $test->evaluate_test; + } -sub testing_complete { +sub test_complete { my ($self, $kernel) = @_[OBJECT, KERNEL]; - # make sure all tests have run to completion. - my $done = 1; - $self->log("Testing to see if we can quit: "); - foreach my $test ($self->parent->all_tests) { - if (not $test->complete) { - $self->log("\t" . $test->name . " is not complete"); - $done = 0; - } - } - if ($done) { - $kernel->yield('shutdown'); - } else { - # ??? - $self->parent->active_test->resume_from_timer; + + $self->parent->complete_test; + + if ($self->parent->tests_remaining) { + $self->parent->run_test; } + + # otherwise, we're done, and can shutdown. + #$kernel->yield('shutdown'); + } sub timer_created { my ($self, $heap, $kernel, $duration) = @_[OBJECT, HEAP, KERNEL, ARG0]; $kernel->delay(got_delay => $duration); - $self->log("Timer created"); + $self->log("Timer created for $duration"); } sub timer_expired { diff --git a/testing/lib/Test/Irssi/Test.pm b/testing/lib/Test/Irssi/Test.pm index 45e9bb1..7ee511f 100644 --- a/testing/lib/Test/Irssi/Test.pm +++ b/testing/lib/Test/Irssi/Test.pm @@ -7,6 +7,7 @@ class Test::Irssi::Test { use Test::Irssi; use Test::Irssi::Driver; use feature qw/say/; + use Data::Dump qw/dump/; has 'parent' => ( @@ -167,17 +168,11 @@ class Test::Irssi::Test { return $item; } - sub execute { - my ($self) = @_; - # set this as hte currently active test. - $self->parent->active_test($self); - $self->evaluate_test; - } - sub evaluate_test { my ($self) = @_; while (my $state = $self->get_next_state) { + $self->log("Evaluating Test: " . dump($state)); # stimuli if ( exists($state->{delay})) { @@ -208,11 +203,12 @@ class Test::Irssi::Test { } } + + $poe_kernel->post(IrssiTestDriver => 'test_complete'); + $self->complete(1); $self->log("Test Execution Finished"); - - $poe_kernel->post('IrssiTestDriver' => 'test_complete'); } sub resume_from_timer { -- cgit v1.2.3