diff options
author | Tom Feist <shabble@metavore.org> | 2011-02-21 01:58:22 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2011-02-21 01:58:22 +0000 |
commit | 71c173db56f8e462fbaa8c0472788c04982478db (patch) | |
tree | cb47d04905cc897be7e3d90d39d0c971e7d5184d | |
parent | modified gitignore to ignore compilation products from modules/ subdirs (diff) | |
download | irssi-scripts-71c173db56f8e462fbaa8c0472788c04982478db.tar.gz irssi-scripts-71c173db56f8e462fbaa8c0472788c04982478db.zip |
start of makign this a proper module
-rw-r--r-- | testing/Changes | 0 | ||||
-rw-r--r-- | testing/MANIFEST | 8 | ||||
-rw-r--r-- | testing/Makefile.PL | 30 | ||||
-rw-r--r-- | testing/README | 0 | ||||
-rwxr-xr-x | testing/auto-testing.pl | 49 | ||||
-rw-r--r-- | testing/lib/Test/Irssi.pm | 90 | ||||
-rwxr-xr-x | testing/t/001-use.t | 25 |
7 files changed, 183 insertions, 19 deletions
diff --git a/testing/Changes b/testing/Changes new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/testing/Changes diff --git a/testing/MANIFEST b/testing/MANIFEST new file mode 100644 index 0000000..8548d92 --- /dev/null +++ b/testing/MANIFEST @@ -0,0 +1,8 @@ +Makefile.PL +MANIFEST +README +Changes +t/001-use.t + + +lib/Test/Irssi.pm diff --git a/testing/Makefile.PL b/testing/Makefile.PL new file mode 100644 index 0000000..3312c95 --- /dev/null +++ b/testing/Makefile.PL @@ -0,0 +1,30 @@ +use strict; +use warnings; +use Cwd; +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. + +WriteMakefile( + NAME => 'Test::Irssi', + AUTHOR => 'shabble <shabble+cpan@metavore.org>', + VERSION_FROM => 'lib/Test/Irssi.pm', # finds $VERSION + ABSTRACT_FROM => 'lib/Test/Irssi.pm', + PL_FILES => {}, + # LIBS => ["-L/opt/local/lib -lcprops"], + # INC => "-I/opt/local/include/cprops", + PREREQ_PM => { + 'Test::More' => 0, + 'Carp' => 0, + 'MooseX::Declare' => 0, + 'IO::File' => 0, + 'Term::VT102' => 0, + 'Term::Terminfo' => 0, + 'strictures' => 0, + 'Data::Dump' => 0, + }, + dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, + # clean => { + # FILES => 'CProps-Trie-* Trie.inl _Inline' + # }, + ); diff --git a/testing/README b/testing/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/testing/README diff --git a/testing/auto-testing.pl b/testing/auto-testing.pl index 31a9e5e..9f47b6c 100755 --- a/testing/auto-testing.pl +++ b/testing/auto-testing.pl @@ -1,5 +1,9 @@ -package Test::Irssi; + +#package Test::Irssi; + +# requires the latest pre-release POE from +# https://github.com/rcaputo/poe until a new release is...released. use warnings; use strict; @@ -8,6 +12,10 @@ use strict; use lib $ENV{HOME} . "/projects/poe/lib"; sub PROGRAM () { "/opt/stow/repo/irssi-debug/bin/irssi" } +sub IRSSI_HOME () { $ENV{HOME} . "/projects/tmp/test/irssi-debug" } + +sub ROWS () { 24 } +sub COLS () { 80 } use POSIX; @@ -20,25 +28,16 @@ use Data::Dumper; use IO::File; my $logfile = "irssi.log"; -#open my $logfh, ">", $logfile or die "Couldn't open $logfile for writing: $!"; my $logfh = IO::File->new($logfile, 'w'); die "Couldn't open $logfile for writing: $!" unless defined $logfh; + $logfh->autoflush(1); my $ti = Term::Terminfo->new(); +my $vt = Term::VT102->new(rows => ROWS, cols => COLS); -my $vt = Term::VT102->new(rows => 24, cols => 80); - -$vt->callback_set(OUTPUT => \&vt_output, undef); -$vt->callback_set(ROWCHANGE => \&vt_rowchange, undef); -$vt->callback_set(CLEAR => \&vt_clear, undef); -$vt->callback_set(SCROLL_DOWN => \&vt_scr_dn, undef); -$vt->callback_set(SCROLL_UP => \&vt_scr_up, undef); -$vt->callback_set(GOTO => \&vt_goto, undef); - -$vt->option_set(LINEWRAP => 1); -$vt->option_set(LFTOCRLF => 1); +vt_configure_callbacks($vt); sub vt_output { my ($vt, $cb_name, $cb_data, $priv_data) = @_; @@ -60,10 +59,9 @@ sub vt_rowchange { say $logfh $vt->row_plaintext($bottom_line); say $logfh "-" x 100; - # -# print $ti->getstr("clear"); - # print vt_dump(); + # print $ti->getstr("clear"); + # print vt_dump(); } sub vt_clear { @@ -85,7 +83,7 @@ sub vt_goto { sub vt_dump { my $str = ''; - for my $y (1..24) { + for my $y (1..ROWS) { $str .= $vt->row_sgrtext($y) . "\n"; } return $str; @@ -113,9 +111,9 @@ sub handle_start { # Start the asynchronous child process. $heap->{program} = POE::Wheel::Run->new( Program => PROGRAM, - ProgramArgs => [qw/--noconnect/], + ProgramArgs => ['--noconnect', '--home=' . IRSSI_HOME ], Conduit => "pty", - Winsize => [24, 80, 0, 0], + Winsize => [ROWS, COLS, 0, 0], StdoutEvent => "got_child_stdout", StdioFilter => POE::Filter::Stream->new(), ); @@ -209,6 +207,19 @@ sub save_term_settings { $heap->{stderr_tio}->getattr(2); } +sub vt_configure_callbacks { + my ($vt) = @_; + $vt->callback_set(OUTPUT => \&vt_output, undef); + $vt->callback_set(ROWCHANGE => \&vt_rowchange, undef); + $vt->callback_set(CLEAR => \&vt_clear, undef); + $vt->callback_set(SCROLL_DOWN => \&vt_scr_dn, undef); + $vt->callback_set(SCROLL_UP => \&vt_scr_up, undef); + $vt->callback_set(GOTO => \&vt_goto, undef); + # options + $vt->option_set(LINEWRAP => 1); + $vt->option_set(LFTOCRLF => 1); +} + ### Start POE's main loop, which runs the session until it's done. $poe_kernel->run(); exit 0; diff --git a/testing/lib/Test/Irssi.pm b/testing/lib/Test/Irssi.pm new file mode 100644 index 0000000..cb350ee --- /dev/null +++ b/testing/lib/Test/Irssi.pm @@ -0,0 +1,90 @@ +use strictures 1; +use MooseX::Declare + +our $VERSION = 0.01; + +class Test::Irssi { + + use Term::VT102; + use Term::Terminfo; + use feature qw/say switch/; + use Data::Dump; + use IO::File; + + has 'irssi_binary' + => ( + is => 'ro', + isa => 'Str', + required => 1, + ); + + has 'irssi_homedir' + => ( + is => 'ro', + isa => 'Str', + required => 1, + ); + + has 'terminal_width' + => ( + is => 'ro', + isa => 'Int', + required => 1, + default => 80, + ); + + has 'terminal_height' + => ( + is => 'ro', + isa => 'Int', + required => 1, + default => 24, + ); + + has 'logfile' + => ( + is => 'ro', + isa => 'Str', + required => 1, + default => 'irssi-test.log', + ); + + has '_logfile_fh' + => ( + is => 'ro', + isa => 'IO::File', + required => 1, + lazy => 1, + builder => '_build_logfile_fh', + ); + + + method _build_logfile_fh { + my $fh = IO::File->new($self->logfile, 'w'); + die "Couldn't open $logfile for writing: $!" unless defined $fh; + $fh->autoflush(1); + + return $fh; + } + + + + + + method log (Str $msg) { + say $self->_logfile_fh $msg; + } +} +__END__ + +=head1 NAME + +Test::Irssi + +=head1 ABSTRACT + +Abstract goes here + +=head1 SYNOPSIS + +blah blah blah diff --git a/testing/t/001-use.t b/testing/t/001-use.t new file mode 100755 index 0000000..60f1bb9 --- /dev/null +++ b/testing/t/001-use.t @@ -0,0 +1,25 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Test::More; +use Data::Dumper; + +BEGIN { + use_ok 'Test::Irssi'; +} + + +my $test = new_ok 'Test::Irssi'; +my @methods = qw/logfile terminal_height terminal_width irssi_homedir irssi_binary/; +can_ok($trie, @methodss); + +undef $test + +done_testing; + +__END__ + + + |