Skip to content

Commit 64fed20

Browse files
author
Jan Henning Thorsen
committed
Trying to fix t/telnet.t with \r\n on BSD
1 parent dc00ee1 commit 64fed20

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Changes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Revision history for Mojo-IOLoop-ReadWriteFork
22

3+
0.09
4+
* Trying to fix t/telnet.t with \r\n on BSD
5+
36
0.08 Sun Nov 16 14:16:47 2014
47
* Trying to fix t/telnet.t with localhost
58

t/telnet.t

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ plan skip_all => 'telnet is missing' unless grep { -x "$_/telnet" } split /:/, $
99

1010
my $address = 'localhost';
1111
my $port = Mojo::IOLoop::Server->generate_port;
12+
my $connected = 0;
1213

1314
# echo server
1415
Mojo::IOLoop->server({ address => $address, port => $port }, sub {
@@ -28,21 +29,22 @@ Mojo::IOLoop->server({ address => $address, port => $port }, sub {
2829
$run->on(read => sub {
2930
my ($run, $chunk) = @_;
3031
diag "client<<<($chunk)";
31-
$run->write("hey\n", sub { $drain++; }) if $chunk =~ /Connected/;
32-
$run->kill if $chunk =~ /I heard you say: hey/;
32+
$run->write("open $address $port\r\n") unless $connected++;
33+
$run->write("hey\r\n", sub { $drain++; }) if $chunk =~ /Connected/;
34+
$run->kill if $chunk =~ /I heard you say/;
3335
$output .= $chunk;
3436
});
3537

3638
$run->start(
3739
program => 'telnet',
38-
program_args => [$address => $port],
40+
program_args => [],
3941
conduit => 'pty',
4042
);
4143

4244
Mojo::IOLoop->timer(2 => sub { Mojo::IOLoop->stop }); # guard
4345
Mojo::IOLoop->start;
4446
like $output, qr{Connected}, 'Connected';
45-
like $output, qr{I heard you say: hey}, 'got echo';
47+
like $output, qr{I heard you say:.*hey}s, 'got echo';
4648
is $drain, 1, 'got drain event';
4749
}
4850

0 commit comments

Comments
 (0)