From 508218365c734253b7a0855084031be28446de66 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 15 Jun 2010 21:20:26 -0500 Subject: dzil stuff --- t/000-load.t | 8 ------- t/001-basic.t | 41 ----------------------------------- t/002-read-write.t | 55 ----------------------------------------------- t/003-write-to-termcast.t | 37 ------------------------------- t/01-basic.t | 41 +++++++++++++++++++++++++++++++++++ t/02-read-write.t | 55 +++++++++++++++++++++++++++++++++++++++++++++++ t/03-write-to-termcast.t | 37 +++++++++++++++++++++++++++++++ 7 files changed, 133 insertions(+), 141 deletions(-) delete mode 100644 t/000-load.t delete mode 100644 t/001-basic.t delete mode 100644 t/002-read-write.t delete mode 100644 t/003-write-to-termcast.t create mode 100644 t/01-basic.t create mode 100644 t/02-read-write.t create mode 100644 t/03-write-to-termcast.t (limited to 't') diff --git a/t/000-load.t b/t/000-load.t deleted file mode 100644 index 3561825..0000000 --- a/t/000-load.t +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 1; - -package Foo; -::use_ok('App::Termcast') - or ::BAIL_OUT("couldn't load App::Termcast"); diff --git a/t/001-basic.t b/t/001-basic.t deleted file mode 100644 index 7dd9a7e..0000000 --- a/t/001-basic.t +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; -use App::Termcast; -use IO::Pty::Easy; -BEGIN { - eval "use Test::TCP;"; - plan skip_all => "Test::TCP is required for this test" if $@; - plan tests => 3; -} - -test_tcp( - client => sub { - my $port = shift; - my $client_script = <new(host => '127.0.0.1', port => $port, - user => 'test', password => 'tset'); - \$tc->run('$^X', "-e", "print 'foo'"); -EOF - my $pty = IO::Pty::Easy->new; - $pty->spawn("$^X", "-e", $client_script); - is($pty->read, 'foo', 'got the right thing on stdout'); - sleep 1; # because the server gets killed when the client exits - }, - server => sub { - my $port = shift; - my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', - LocalPort => $port, - Listen => 1); - $sock->accept; # signal to the client that the port is available - my $client = $sock->accept; - my $login; - $client->recv($login, 4096); - is($login, "hello test tset\n", 'got the correct login info'); - my $output; - $client->recv($output, 4096); - is($output, "foo", 'sent the right data to the server'); - }, -); diff --git a/t/002-read-write.t b/t/002-read-write.t deleted file mode 100644 index a03effb..0000000 --- a/t/002-read-write.t +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; -use App::Termcast; -use IO::Pty::Easy; -BEGIN { - eval "use Test::TCP;"; - plan skip_all => "Test::TCP is required for this test" if $@; - plan tests => 5; -} - -test_tcp( - client => sub { - my $port = shift; - my $client_script = <new( - host => '127.0.0.1', port => $port, - user => 'test', password => 'tset'); - \$tc->run('$^X', "-e", "while (<>) { last if /\\\\./; print }"); -EOF - my $pty = IO::Pty::Easy->new; - $pty->spawn("$^X", "-e", $client_script); - $pty->write("foo\n"); - sleep 1; # give the subprocess time to generate its output - is($pty->read, "foo\r\nfoo\r\n", 'got the right thing on stdout'); - $pty->write("bar\n"); - sleep 1; # give the subprocess time to generate its output - is($pty->read, "bar\r\nbar\r\n", 'got the right thing on stdout'); - $pty->write(".\n"); - is($pty->read, ".\r\n", "didn't get too much data"); - sleep 1; # because the server gets killed when the client exits - }, - server => sub { - my $port = shift; - my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', - LocalPort => $port, - Listen => 1); - $sock->accept; # signal to the client that the port is available - my $client = $sock->accept; - my $login; - $client->recv($login, 4096); - is($login, "hello test tset\n", 'got the correct login info'); - my $output; - my $total_out = ''; - while (1) { - $client->recv($output, 4096); - last unless defined($output) && length($output); - $total_out .= $output; - } - is($total_out, "foo\r\nfoo\r\nbar\r\nbar\r\n.\r\n", - 'sent the right data to the server'); - }, -); diff --git a/t/003-write-to-termcast.t b/t/003-write-to-termcast.t deleted file mode 100644 index 04045cf..0000000 --- a/t/003-write-to-termcast.t +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; -use App::Termcast; -BEGIN { - eval "use Test::TCP;"; - plan skip_all => "Test::TCP is required for this test" if $@; - plan tests => 3; -} - -test_tcp( - client => sub { - my $port = shift; - my $tc = App::Termcast->new( - host => '127.0.0.1', port => $port, - user => 'test', password => 'tset'); - $tc->write_to_termcast('foo'); - ok(!$tc->meta->find_attribute_by_name('pty')->has_value($tc), - "pty isn't created"); - sleep 1; - }, - server => sub { - my $port = shift; - my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', - LocalPort => $port, - Listen => 1); - $sock->accept; # signal to the client that the port is available - my $client = $sock->accept; - my $login; - $client->recv($login, 4096); - is($login, "hello test tset\n", 'got the correct login info'); - my $buf; - $client->recv($buf, 4096); - is($buf, 'foo', 'wrote correctly'); - }, -); diff --git a/t/01-basic.t b/t/01-basic.t new file mode 100644 index 0000000..7dd9a7e --- /dev/null +++ b/t/01-basic.t @@ -0,0 +1,41 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use App::Termcast; +use IO::Pty::Easy; +BEGIN { + eval "use Test::TCP;"; + plan skip_all => "Test::TCP is required for this test" if $@; + plan tests => 3; +} + +test_tcp( + client => sub { + my $port = shift; + my $client_script = <new(host => '127.0.0.1', port => $port, + user => 'test', password => 'tset'); + \$tc->run('$^X', "-e", "print 'foo'"); +EOF + my $pty = IO::Pty::Easy->new; + $pty->spawn("$^X", "-e", $client_script); + is($pty->read, 'foo', 'got the right thing on stdout'); + sleep 1; # because the server gets killed when the client exits + }, + server => sub { + my $port = shift; + my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', + LocalPort => $port, + Listen => 1); + $sock->accept; # signal to the client that the port is available + my $client = $sock->accept; + my $login; + $client->recv($login, 4096); + is($login, "hello test tset\n", 'got the correct login info'); + my $output; + $client->recv($output, 4096); + is($output, "foo", 'sent the right data to the server'); + }, +); diff --git a/t/02-read-write.t b/t/02-read-write.t new file mode 100644 index 0000000..a03effb --- /dev/null +++ b/t/02-read-write.t @@ -0,0 +1,55 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use App::Termcast; +use IO::Pty::Easy; +BEGIN { + eval "use Test::TCP;"; + plan skip_all => "Test::TCP is required for this test" if $@; + plan tests => 5; +} + +test_tcp( + client => sub { + my $port = shift; + my $client_script = <new( + host => '127.0.0.1', port => $port, + user => 'test', password => 'tset'); + \$tc->run('$^X', "-e", "while (<>) { last if /\\\\./; print }"); +EOF + my $pty = IO::Pty::Easy->new; + $pty->spawn("$^X", "-e", $client_script); + $pty->write("foo\n"); + sleep 1; # give the subprocess time to generate its output + is($pty->read, "foo\r\nfoo\r\n", 'got the right thing on stdout'); + $pty->write("bar\n"); + sleep 1; # give the subprocess time to generate its output + is($pty->read, "bar\r\nbar\r\n", 'got the right thing on stdout'); + $pty->write(".\n"); + is($pty->read, ".\r\n", "didn't get too much data"); + sleep 1; # because the server gets killed when the client exits + }, + server => sub { + my $port = shift; + my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', + LocalPort => $port, + Listen => 1); + $sock->accept; # signal to the client that the port is available + my $client = $sock->accept; + my $login; + $client->recv($login, 4096); + is($login, "hello test tset\n", 'got the correct login info'); + my $output; + my $total_out = ''; + while (1) { + $client->recv($output, 4096); + last unless defined($output) && length($output); + $total_out .= $output; + } + is($total_out, "foo\r\nfoo\r\nbar\r\nbar\r\n.\r\n", + 'sent the right data to the server'); + }, +); diff --git a/t/03-write-to-termcast.t b/t/03-write-to-termcast.t new file mode 100644 index 0000000..04045cf --- /dev/null +++ b/t/03-write-to-termcast.t @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use App::Termcast; +BEGIN { + eval "use Test::TCP;"; + plan skip_all => "Test::TCP is required for this test" if $@; + plan tests => 3; +} + +test_tcp( + client => sub { + my $port = shift; + my $tc = App::Termcast->new( + host => '127.0.0.1', port => $port, + user => 'test', password => 'tset'); + $tc->write_to_termcast('foo'); + ok(!$tc->meta->find_attribute_by_name('pty')->has_value($tc), + "pty isn't created"); + sleep 1; + }, + server => sub { + my $port = shift; + my $sock = IO::Socket::INET->new(LocalAddr => '127.0.0.1', + LocalPort => $port, + Listen => 1); + $sock->accept; # signal to the client that the port is available + my $client = $sock->accept; + my $login; + $client->recv($login, 4096); + is($login, "hello test tset\n", 'got the correct login info'); + my $buf; + $client->recv($buf, 4096); + is($buf, 'foo', 'wrote correctly'); + }, +); -- cgit v1.2.3-54-g00ecf