From 719e6746ab3ef0c6a0557fb063d7b7748a845a59 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 14 Apr 2011 09:07:23 -0500 Subject: remove test numbering --- t/01-basic.t | 62 ------------------------------ t/02-read-write.t | 98 ------------------------------------------------ t/03-write-to-termcast.t | 56 --------------------------- t/basic.t | 62 ++++++++++++++++++++++++++++++ t/read-write.t | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ t/write-to-termcast.t | 56 +++++++++++++++++++++++++++ 6 files changed, 216 insertions(+), 216 deletions(-) delete mode 100644 t/01-basic.t delete mode 100644 t/02-read-write.t delete mode 100644 t/03-write-to-termcast.t create mode 100644 t/basic.t create mode 100644 t/read-write.t create mode 100644 t/write-to-termcast.t (limited to 't') diff --git a/t/01-basic.t b/t/01-basic.t deleted file mode 100644 index bf85edb..0000000 --- a/t/01-basic.t +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; -use Test::Requires 'Test::TCP'; -use IO::Pty::Easy; - -use App::Termcast; - -pipe(my $cread, my $swrite); -pipe(my $sread, my $cwrite); - -test_tcp( - client => sub { - my $port = shift; - close $swrite; - close $sread; - { sysread($cread, my $buf, 1) } - my $inc = join ':', grep { !ref } @INC; - 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); - syswrite($cwrite, 'a'); - { sysread($cread, my $buf, 1) } - is($pty->read, 'foo', 'got the right thing on stdout'); - }, - server => sub { - my $port = shift; - close $cwrite; - close $cread; - 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 - syswrite($swrite, 'a'); - my $client = $sock->accept; - { sysread($sread, my $buf, 1) } - my $login; - $client->recv($login, 4096); - is($login, - "hello test tset\n\e\[H\x00{\"geometry\":[80,24]}\xff\e\[H\e\[2J", - "got the correct login info"); - $client->send("hello, test\n"); - my $output; - $client->recv($output, 4096); - is($output, "foo", 'sent the right data to the server'); - syswrite($swrite, 'a'); - }, -); - -done_testing; diff --git a/t/02-read-write.t b/t/02-read-write.t deleted file mode 100644 index 0979955..0000000 --- a/t/02-read-write.t +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; -use Test::Requires 'Test::TCP'; -use IO::Pty::Easy; - -use App::Termcast; - -pipe(my $cread, my $swrite); -pipe(my $sread, my $cwrite); - -test_tcp( - client => sub { - my $port = shift; - close $swrite; - close $sread; - { sysread($cread, my $buf, 1) } - my $inc = join ':', grep { !ref } @INC; - my $client_script = <new( - host => '127.0.0.1', port => $port, - user => 'test', password => 'tset'); - \$tc->run('$^X', "-e", "while (<>) { last if /\\\\./; print; print qq{---\\n}; }"); -EOF - my $pty = IO::Pty::Easy->new; - $pty->spawn("$^X", "-e", $client_script); - syswrite($cwrite, 'a'); - { sysread($cread, my $buf, 1) } - $pty->write("foo\n"); - syswrite($cwrite, 'a'); - { sysread($cread, my $buf, 1) } - { - local $SIG{ALRM} = sub { fail("got the right thing on stdout") }; - alarm 10; - my $read = ''; - $read .= $pty->read until $read =~ /---/; - alarm 0; - is($read, "foo\r\nfoo\r\n---\r\n", 'got the right thing on stdout'); - } - $pty->write("bar\n"); - syswrite($cwrite, 'a'); - { sysread($cread, my $buf, 1) } - { - local $SIG{ALRM} = sub { fail("got the right thing on stdout") }; - alarm 10; - my $read = ''; - $read .= $pty->read until $read =~ /---/; - alarm 0; - is($read, "bar\r\nbar\r\n---\r\n", 'got the right thing on stdout'); - } - $pty->write(".\n"); - syswrite($cwrite, 'a'); - { sysread($cread, my $buf, 1) } - is($pty->read, ".\r\n", "didn't get too much data"); - }, - server => sub { - my $port = shift; - close $cwrite; - close $cread; - 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 - syswrite($swrite, 'a'); - my $client = $sock->accept; - { sysread($sread, my $buf, 1) } - my $login; - $client->recv($login, 4096); - is($login, - "hello test tset\n\e\[H\x00{\"geometry\":[80,24]}\xff\e\[H\e\[2J", - "got the correct login info"); - $client->send("hello, test\n"); - - syswrite($swrite, 'a'); - my $output; - my $total_out = ''; - while (1) { - { sysread($sread, my $buf, 1) } - $client->recv($output, 4096); - last unless defined($output) && length($output); - $total_out .= $output; - syswrite($swrite, 'a'); - } - is($total_out, "foo\r\nfoo\r\n---\r\nbar\r\nbar\r\n---\r\n.\r\n", - 'sent the right data to the server'); - syswrite($swrite, 'a'); - }, -); - -done_testing; diff --git a/t/03-write-to-termcast.t b/t/03-write-to-termcast.t deleted file mode 100644 index 47321ec..0000000 --- a/t/03-write-to-termcast.t +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; -use Test::Requires 'Test::TCP'; - -use App::Termcast; - -no warnings 'redefine'; -local *App::Termcast::_termsize = sub { return (80, 24) }; -use warnings 'redefine'; - -pipe(my $cread, my $swrite); -pipe(my $sread, my $cwrite); - -test_tcp( - client => sub { - my $port = shift; - close $swrite; - close $sread; - { sysread($cread, my $buf, 1) } - my $tc = App::Termcast->new( - host => '127.0.0.1', port => $port, - user => 'test', password => 'tset'); - $tc->write_to_termcast('foo'); - syswrite($cwrite, 'a'); - { sysread($cread, my $buf, 1) } - ok(!$tc->meta->find_attribute_by_name('pty')->has_value($tc), - "pty isn't created"); - }, - server => sub { - my $port = shift; - close $cwrite; - close $cread; - 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 - syswrite($swrite, 'a'); - my $client = $sock->accept; - my $login; - $client->recv($login, 4096); - is($login, - "hello test tset\n\e\[H\x00{\"geometry\":[80,24]}\xff\e\[H\e\[2J", - "got the correct login info"); - $client->send("hello, test\n"); - { sysread($sread, my $buf, 1) } - - my $buf; - $client->recv($buf, 4096); - is($buf, 'foo', 'wrote correctly'); - syswrite($swrite, 'a'); - }, -); - -done_testing; diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..bf85edb --- /dev/null +++ b/t/basic.t @@ -0,0 +1,62 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Requires 'Test::TCP'; +use IO::Pty::Easy; + +use App::Termcast; + +pipe(my $cread, my $swrite); +pipe(my $sread, my $cwrite); + +test_tcp( + client => sub { + my $port = shift; + close $swrite; + close $sread; + { sysread($cread, my $buf, 1) } + my $inc = join ':', grep { !ref } @INC; + 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); + syswrite($cwrite, 'a'); + { sysread($cread, my $buf, 1) } + is($pty->read, 'foo', 'got the right thing on stdout'); + }, + server => sub { + my $port = shift; + close $cwrite; + close $cread; + 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 + syswrite($swrite, 'a'); + my $client = $sock->accept; + { sysread($sread, my $buf, 1) } + my $login; + $client->recv($login, 4096); + is($login, + "hello test tset\n\e\[H\x00{\"geometry\":[80,24]}\xff\e\[H\e\[2J", + "got the correct login info"); + $client->send("hello, test\n"); + my $output; + $client->recv($output, 4096); + is($output, "foo", 'sent the right data to the server'); + syswrite($swrite, 'a'); + }, +); + +done_testing; diff --git a/t/read-write.t b/t/read-write.t new file mode 100644 index 0000000..0979955 --- /dev/null +++ b/t/read-write.t @@ -0,0 +1,98 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Requires 'Test::TCP'; +use IO::Pty::Easy; + +use App::Termcast; + +pipe(my $cread, my $swrite); +pipe(my $sread, my $cwrite); + +test_tcp( + client => sub { + my $port = shift; + close $swrite; + close $sread; + { sysread($cread, my $buf, 1) } + my $inc = join ':', grep { !ref } @INC; + my $client_script = <new( + host => '127.0.0.1', port => $port, + user => 'test', password => 'tset'); + \$tc->run('$^X', "-e", "while (<>) { last if /\\\\./; print; print qq{---\\n}; }"); +EOF + my $pty = IO::Pty::Easy->new; + $pty->spawn("$^X", "-e", $client_script); + syswrite($cwrite, 'a'); + { sysread($cread, my $buf, 1) } + $pty->write("foo\n"); + syswrite($cwrite, 'a'); + { sysread($cread, my $buf, 1) } + { + local $SIG{ALRM} = sub { fail("got the right thing on stdout") }; + alarm 10; + my $read = ''; + $read .= $pty->read until $read =~ /---/; + alarm 0; + is($read, "foo\r\nfoo\r\n---\r\n", 'got the right thing on stdout'); + } + $pty->write("bar\n"); + syswrite($cwrite, 'a'); + { sysread($cread, my $buf, 1) } + { + local $SIG{ALRM} = sub { fail("got the right thing on stdout") }; + alarm 10; + my $read = ''; + $read .= $pty->read until $read =~ /---/; + alarm 0; + is($read, "bar\r\nbar\r\n---\r\n", 'got the right thing on stdout'); + } + $pty->write(".\n"); + syswrite($cwrite, 'a'); + { sysread($cread, my $buf, 1) } + is($pty->read, ".\r\n", "didn't get too much data"); + }, + server => sub { + my $port = shift; + close $cwrite; + close $cread; + 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 + syswrite($swrite, 'a'); + my $client = $sock->accept; + { sysread($sread, my $buf, 1) } + my $login; + $client->recv($login, 4096); + is($login, + "hello test tset\n\e\[H\x00{\"geometry\":[80,24]}\xff\e\[H\e\[2J", + "got the correct login info"); + $client->send("hello, test\n"); + + syswrite($swrite, 'a'); + my $output; + my $total_out = ''; + while (1) { + { sysread($sread, my $buf, 1) } + $client->recv($output, 4096); + last unless defined($output) && length($output); + $total_out .= $output; + syswrite($swrite, 'a'); + } + is($total_out, "foo\r\nfoo\r\n---\r\nbar\r\nbar\r\n---\r\n.\r\n", + 'sent the right data to the server'); + syswrite($swrite, 'a'); + }, +); + +done_testing; diff --git a/t/write-to-termcast.t b/t/write-to-termcast.t new file mode 100644 index 0000000..47321ec --- /dev/null +++ b/t/write-to-termcast.t @@ -0,0 +1,56 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; +use Test::Requires 'Test::TCP'; + +use App::Termcast; + +no warnings 'redefine'; +local *App::Termcast::_termsize = sub { return (80, 24) }; +use warnings 'redefine'; + +pipe(my $cread, my $swrite); +pipe(my $sread, my $cwrite); + +test_tcp( + client => sub { + my $port = shift; + close $swrite; + close $sread; + { sysread($cread, my $buf, 1) } + my $tc = App::Termcast->new( + host => '127.0.0.1', port => $port, + user => 'test', password => 'tset'); + $tc->write_to_termcast('foo'); + syswrite($cwrite, 'a'); + { sysread($cread, my $buf, 1) } + ok(!$tc->meta->find_attribute_by_name('pty')->has_value($tc), + "pty isn't created"); + }, + server => sub { + my $port = shift; + close $cwrite; + close $cread; + 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 + syswrite($swrite, 'a'); + my $client = $sock->accept; + my $login; + $client->recv($login, 4096); + is($login, + "hello test tset\n\e\[H\x00{\"geometry\":[80,24]}\xff\e\[H\e\[2J", + "got the correct login info"); + $client->send("hello, test\n"); + { sysread($sread, my $buf, 1) } + + my $buf; + $client->recv($buf, 4096); + is($buf, 'foo', 'wrote correctly'); + syswrite($swrite, 'a'); + }, +); + +done_testing; -- cgit v1.2.3-54-g00ecf