summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-04-14 08:52:04 -0500
committerJesse Luehrs <doy@tozt.net>2011-04-14 08:52:04 -0500
commit1db37bb0163fbb33801f8f66ba409a8202137508 (patch)
tree0b608aaf976f097f63d65204a457ded3b9f006b3 /t
parentfddf32a172ddc7588fa8818938b17e468ae9de09 (diff)
downloadapp-termcast-1db37bb0163fbb33801f8f66ba409a8202137508.tar.gz
app-termcast-1db37bb0163fbb33801f8f66ba409a8202137508.zip
override termsize calculation in tests, so it is consistent
Diffstat (limited to 't')
-rw-r--r--t/01-basic.t10
-rw-r--r--t/02-read-write.t10
-rw-r--r--t/03-write-to-termcast.t9
3 files changed, 23 insertions, 6 deletions
diff --git a/t/01-basic.t b/t/01-basic.t
index d3ae485..bf85edb 100644
--- a/t/01-basic.t
+++ b/t/01-basic.t
@@ -20,6 +20,11 @@ test_tcp(
my $client_script = <<EOF;
BEGIN { \@INC = split /:/, '$inc' }
use App::Termcast;
+
+ no warnings 'redefine';
+ local *App::Termcast::_termsize = sub { return (80, 24) };
+ use warnings 'redefine';
+
my \$tc = App::Termcast->new(host => '127.0.0.1', port => $port,
user => 'test', password => 'tset');
\$tc->run('$^X', "-e", "print 'foo'");
@@ -43,8 +48,9 @@ EOF
{ 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)?/;
- like($login, $auth_regexp, 'got the correct login info');
+ 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);
diff --git a/t/02-read-write.t b/t/02-read-write.t
index b7a26ac..0979955 100644
--- a/t/02-read-write.t
+++ b/t/02-read-write.t
@@ -20,6 +20,11 @@ test_tcp(
my $client_script = <<EOF;
BEGIN { \@INC = split /:/, '$inc' }
use App::Termcast;
+
+ no warnings 'redefine';
+ local *App::Termcast::_termsize = sub { return (80, 24) };
+ use warnings 'redefine';
+
my \$tc = App::Termcast->new(
host => '127.0.0.1', port => $port,
user => 'test', password => 'tset');
@@ -69,8 +74,9 @@ EOF
{ 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)?/;
- like($login, $auth_regexp, 'got the correct login info');
+ 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');
diff --git a/t/03-write-to-termcast.t b/t/03-write-to-termcast.t
index 5b7c4b2..47321ec 100644
--- a/t/03-write-to-termcast.t
+++ b/t/03-write-to-termcast.t
@@ -6,6 +6,10 @@ 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);
@@ -36,8 +40,9 @@ test_tcp(
my $client = $sock->accept;
my $login;
$client->recv($login, 4096);
- 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');
+ 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) }