summaryrefslogtreecommitdiffstats
path: root/t/01-basic.t
diff options
context:
space:
mode:
Diffstat (limited to 't/01-basic.t')
-rw-r--r--t/01-basic.t16
1 files changed, 14 insertions, 2 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
index 48bea2c..d3ae485 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -7,9 +7,15 @@ 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 = <<EOF;
BEGIN { \@INC = split /:/, '$inc' }
@@ -20,24 +26,30 @@ test_tcp(
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');
- sleep 1; # because the server gets killed when the client exits
},
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);
- my $auth_regexp = qr/^hello test tset\n\e\[H\x00.+?\xff\e\[H\e\[2J/;
+ my $auth_regexp = qr/^hello test tset\n(?:\e\[H\x00.+?\xff\e\[H\e\[2J)?/;
like($login, $auth_regexp, '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');
},
);