aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
authorTom Feist <shabble@metavore.org>2011-03-04 04:12:47 +0000
committerTom Feist <shabble@metavore.org>2011-03-04 04:12:47 +0000
commit7ec10e516a04a05a85cb82b30a8f9982f13c6c90 (patch)
tree98e01316dbd57e4b0debb2d5d444b19cef5bf026 /testing
parenttesting: cleaned up a lot of the testing logic. Subtests are now reported at ... (diff)
downloadirssi-scripts-7ec10e516a04a05a85cb82b30a8f9982f13c6c90.tar.gz
irssi-scripts-7ec10e516a04a05a85cb82b30a8f9982f13c6c90.zip
working with TAP::Harness
Diffstat (limited to '')
-rw-r--r--testing/lib/Test/Irssi.pm24
-rwxr-xr-xtesting/t/002-init.t2
-rwxr-xr-xtesting/test.pl46
-rwxr-xr-xtesting/test2.pl38
-rwxr-xr-xtesting/tests/001-basic.t (renamed from testing/test3.pl)7
5 files changed, 35 insertions, 82 deletions
diff --git a/testing/lib/Test/Irssi.pm b/testing/lib/Test/Irssi.pm
index 72f69ed..f723285 100644
--- a/testing/lib/Test/Irssi.pm
+++ b/testing/lib/Test/Irssi.pm
@@ -1,7 +1,7 @@
use strictures 1;
use MooseX::Declare;
-our $VERSION = 0.01;
+our $VERSION = 0.02;
class Test::Irssi {
@@ -10,7 +10,6 @@ class Test::Irssi {
use lib $ENV{HOME} . "/projects/poe/lib";
use POE;
-
use Term::VT102;
use Term::Terminfo;
use feature qw/say switch/;
@@ -85,6 +84,9 @@ class Test::Irssi {
required => 1,
lazy => 1,
builder => '_build_driver_obj',
+ handles => {
+ run_headless => 'headless',
+ }
);
has '_callbacks'
@@ -118,7 +120,8 @@ class Test::Irssi {
default => sub { [] },
traits => [qw/Array/],
handles => {
- add_completed_test => 'push'
+ add_completed_test => 'push',
+ tests_completed => 'count',
},
);
@@ -176,6 +179,12 @@ class Test::Irssi {
# put the completed one onto the completed pile
my $old_test = $self->active_test;
$self->add_completed_test($old_test);
+
+ # TAP: print status.
+ my $tap = sprintf("%s %d - %s", $old_test->passed?'ok':'not ok',
+ $self->tests_completed,
+ $old_test->description);
+ say STDOUT $tap;
}
method run_test {
@@ -188,10 +197,15 @@ class Test::Irssi {
}
method run {
+
$self->driver->setup;
$self->_vt_setup;
$self->log("Driver setup complete");
### Start a session to encapsulate the previous features.
+
+ # TAP: print number of tests.
+ print STDOUT "1.." . $self->tests_remaining . "\n";
+
$poe_kernel->run();
}
@@ -248,8 +262,8 @@ class Test::Irssi {
method summarise_test_results {
foreach my $test (@{$self->completed_tests}) {
my $name = $test->name;
- printf("Test %s\t\t-\t%s\n", $name, $test->passed?"pass":"fail");
- $test->details();
+ #printf("Test %s\t\t-\t%s\n", $name, $test->passed?"pass":"fail");
+ #$test->details();
}
}
diff --git a/testing/t/002-init.t b/testing/t/002-init.t
index df61e1e..b688f9f 100755
--- a/testing/t/002-init.t
+++ b/testing/t/002-init.t
@@ -19,7 +19,7 @@ if (-f $test->logfile) {
ok(unlink $test->logfile, 'deleted old logfile');
}
-my $drv = $test->_driver;
+my $drv = $test->driver;
isa_ok($drv, 'Test::Irssi::Driver', 'driver created ok');
diag "Starting POE session";
diff --git a/testing/test.pl b/testing/test.pl
index ea90e1c..bf01530 100755
--- a/testing/test.pl
+++ b/testing/test.pl
@@ -4,42 +4,14 @@ use strict;
use warnings;
use feature qw/say/;
+#use lib 'blib/lib';
-use lib 'blib/lib';
+use TAP::Harness;
+my $harness = TAP::Harness->new({ verbosity => 1,
+ lib => 'blib/lib',
+ color => 1,
+ });
-use Test::Irssi;
-
-my $tester = Test::Irssi->new
- (irssi_binary => "/opt/stow/repo/irssi-debug/bin/irssi",
- irssi_homedir => $ENV{HOME} . "/projects/tmp/test/irssi-debug");
-
-say "Created test instance";
-
-
-
-my $test = $tester->new_test('test1');
-
-$test->add_input_sequence("/echo Hello cats\n");
-$test->add_delay(20);
-$test->add_input_sequence("/echo Hello Again\n");
-for (1..10) {
- $test->add_input_sequence($_);
- $test->add_delay(0.2);
-}
-$test->add_evaluation_function(sub { 1 }, 'this should succeed');
-$test->add_pattern_match(qr/2345/, 'prompt', 'prompt contains numbers');
-
-#$test->add_input_sequence("This is\x0acursor movement\x0a");
-# $test->add_delay(5);
-$test->add_input_sequence("\n");
-
-$test->add_input_sequence("/clear\n");
-
-
-my $test2 = $tester->new_test("Test2");
-$test2->add_input_sequence("hello from twooooooo");
-$test2->add_delay(5);
-$test2->add_pattern_match(qr/hello/, 'prompt', 'hello');
-
-
-$tester->run;
+my @tests = glob($ARGV[0]);
+say "Tests: " . join (", ", @tests);
+$harness->runtests(@tests);
diff --git a/testing/test2.pl b/testing/test2.pl
deleted file mode 100755
index 661e66b..0000000
--- a/testing/test2.pl
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env perl
-
-use strict;
-use warnings;
-
-use feature qw/say/;
-
-use lib 'blib/lib';
-
-use Test::Irssi;
-
-my $tester = Test::Irssi->new
- (irssi_binary => "/opt/stow/repo/irssi-debug/bin/irssi",
- irssi_homedir => $ENV{HOME} . "/projects/tmp/test/irssi-debug");
-
-my $test = $tester->new_test('test2');
-$test->add_input_sequence("/echo 'Window one'\n");
-$test->add_delay(5);
-$test->add_input_sequence("/window new hide\n");
-$test->add_input_sequence("/win 2\n");
-for (1..10) {
- $test->add_input_sequence($_);
- $test->add_delay(0.2);
-}
-$test->add_input_sequence("\x01/echo \x05\n");
-$test->add_delay(10);
-$test->add_input_sequence("\x1b\x31");
-$test->add_delay(10);
-#$test->add_input_sequence("This is\x0acursor movement\x0a");
-# $test->add_delay(5);
-
-
-
-# $test->add_expected_output("Hello");
-
-
-
-$tester->run;
diff --git a/testing/test3.pl b/testing/tests/001-basic.t
index 57be5ed..4373855 100755
--- a/testing/test3.pl
+++ b/testing/tests/001-basic.t
@@ -5,7 +5,7 @@ use warnings;
use feature qw/say/;
-use lib 'blib/lib';
+#use lib 'blib/lib';
use Test::Irssi;
@@ -14,8 +14,10 @@ my $tester = Test::Irssi->new
irssi_homedir => $ENV{HOME} . "/projects/tmp/test/irssi-debug");
say "Created test instance";
+$tester->run_headless(1);
my $test = $tester->new_test('test1');
+$test->description("simple echo tests");
$test->add_input_sequence("/echo Hello cats\n");
$test->add_delay(1);
@@ -26,6 +28,8 @@ $test->add_pattern_match(qw/longfdajkfd/, 'prompt', 'prompt contains hello');
my $test2 = $tester->new_test('test2');
+$test2->description("cursor movement and deletion");
+
$test2->add_delay(2);
$test2->add_input_sequence("\x01");
$test2->add_delay(0.1);
@@ -36,6 +40,7 @@ $test2->add_delay(0.1);
$test2->add_input_sequence("/echo moo\n");
my $quit = $tester->new_test('quit');
+$quit->description('quitting');
$quit->add_input_sequence("/quit\n");
# for (1..10) {