diff options
| author | Tom Feist <shabble@metavore.org> | 2011-03-04 05:19:41 +0000 | 
|---|---|---|
| committer | Tom Feist <shabble@metavore.org> | 2011-03-04 05:19:41 +0000 | 
| commit | 41c95c731cae9d39468acce966ed3e14e39191cf (patch) | |
| tree | eef5ed6865c7d2cd6b4a79143c010570d754868b /testing/lib/Test/Irssi | |
| parent | working with TAP::Harness (diff) | |
| download | irssi-scripts-41c95c731cae9d39468acce966ed3e14e39191cf.tar.gz irssi-scripts-41c95c731cae9d39468acce966ed3e14e39191cf.zip | |
testing: mostly working TAP output, test.pl uses TAP::Harness to run tests.  now
we just need some tests.
Diffstat (limited to 'testing/lib/Test/Irssi')
| -rw-r--r-- | testing/lib/Test/Irssi/Driver.pm | 5 | ||||
| -rw-r--r-- | testing/lib/Test/Irssi/Test.pm | 30 | 
2 files changed, 26 insertions, 9 deletions
| diff --git a/testing/lib/Test/Irssi/Driver.pm b/testing/lib/Test/Irssi/Driver.pm index 81e4f28..6b4e5e5 100644 --- a/testing/lib/Test/Irssi/Driver.pm +++ b/testing/lib/Test/Irssi/Driver.pm @@ -81,8 +81,9 @@ sub STOP {      $self->restore_term_settings($heap);      $self->parent->_logfile_fh->close(); -    say "\n\n"; -    $self->parent->summarise_test_results(); +    if (not $self->parent->generate_tap) { +        $self->parent->summarise_test_results(); +    }  }  ### Handle terminal STDIN.  Send it to the background program's STDIN. diff --git a/testing/lib/Test/Irssi/Test.pm b/testing/lib/Test/Irssi/Test.pm index 752a01d..cd0a6f9 100644 --- a/testing/lib/Test/Irssi/Test.pm +++ b/testing/lib/Test/Irssi/Test.pm @@ -93,7 +93,7 @@ class Test::Irssi::Test {          for (0..$state_count-1) {              my $state  = $self->states->[$_];              my $result = $self->results->[$_]; -            say( "\t" . $state->{type} . " - " . $state->{desc} . " " +            say( "#\t" . $state->{type} . " - " . $state->{desc} . " "                . " = " .( $result?"ok":"not ok"));          }      } @@ -102,6 +102,7 @@ class Test::Irssi::Test {      method add_input_sequence(Str $input) {          $self->add_state({type  => 'command', +                          of    => 'input',                            input => $input,                            desc  => 'input'}); @@ -110,6 +111,7 @@ class Test::Irssi::Test {      method add_delay (Num $delay) {          $self->add_state({type  => 'command', +                          of    => 'delay',                            desc  => 'delay',                            delay => $delay });          $self->log("Adding $delay as delay"); @@ -124,6 +126,12 @@ class Test::Irssi::Test {          $self->log("Adding $input ($code) as input");      } +    sub add_diag { +        my ($self, $diag) = @_; +        $self->add_state({type => 'command', +                          of   => 'diag', +                          desc => $diag }); +    }      sub add_pattern_match {          my ($self, $pattern, $constraints, $desc) = @_; @@ -155,6 +163,7 @@ class Test::Irssi::Test {                            desc => $desc});      } +      ############# END OF API FUNCTIONS #################################### @@ -191,6 +200,8 @@ class Test::Irssi::Test {              $line = $self->parent->get_topic_line;          } +        $self->log("Testing pattern against: '$line'"); +          if ($line =~ m/$pattern/) {              $self->log("Pattern $pattern passed");              $self->results->[$self->this_state] = 1; @@ -218,19 +229,24 @@ class Test::Irssi::Test {              my $type = $state->{type};              if ($type eq 'command') { +                my $subtype = $state->{of}; -                if (exists($state->{delay})) { +                if ($subtype eq 'diag') { +                    if ($self->parent->generate_tap) { +                        say STDOUT '#' . $state->{desc}; +                    } +                } +                if ($subtype eq 'input') { +                    $self->parent->inject_text($state->{input}); +                    $self->log("input: ". $state->{input}); +                } +                if ($subtype eq 'delay') {                      $self->log("inserting delay");                      $self->parent->apply_delay($state->{delay});                      $self->results->[$self->this_state] = 1;                      return;                  } -                if (exists $state->{input}) { -                    $self->parent->inject_text($state->{input}); -                    $self->log("input: ". $state->{input}); -                } -                  # all commands are considered to succeed.                  $self->results->[$self->this_state] = 1; | 
