Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a test case from rt.cpan.org #54319. Verify Po::Wh::FollowTail

actually tails files.  Thanks to Bazerka on irc.perl.org for
submitting the basis of this test case.
  • Loading branch information...
commit c9ff00832cec870f535364530a3f586cf0bcdfa7 1 parent c4bcf0c
@rcaputo authored
View
2  poe-test-loops/MANIFEST
@@ -1,4 +1,3 @@
-# $Id$
CHANGES
MANIFEST
Makefile.PL
@@ -36,5 +35,6 @@ lib/POE/Test/Loops/z_leolo_wheel_run.pm
lib/POE/Test/Loops/z_merijn_sigchld_system.pm
lib/POE/Test/Loops/z_rt39872_sigchld.pm
lib/POE/Test/Loops/z_rt39872_sigchld_stop.pm
+lib/POE/Test/Loops/z_rt54319_bazerka_followtail.pm
lib/POE/Test/Loops/z_steinert_signal_integrity.pm
t/01_no_tests.t
View
2  poe-test-loops/lib/POE/Test/Loops.pm
@@ -6,7 +6,7 @@ use strict;
use vars qw($VERSION);
use vars qw($VERSION $REVISION);
-$VERSION = '1.031'; # NOTE - Should be #.### (three decimal places)
+$VERSION = '1.032'; # NOTE - Should be #.### (three decimal places)
$REVISION = do {my($r)=(q$Revision$=~/(\d+)/);sprintf"0.%04d",$r};
use File::Spec;
View
60 poe-test-loops/lib/POE/Test/Loops/z_rt54319_bazerka_followtail.pm
@@ -0,0 +1,60 @@
+#! /usr/bin/env perl
+# vim: ts=2 sw=2 expandtab
+
+# Verify that POE::Wheel::FollowTail does indeed follow a file's tail.
+
+use strict;
+use warnings;
+
+use IO::Handle;
+use POE qw(Wheel::FollowTail);
+
+use constant TESTS => 10;
+use Test::More;
+
+my $tailfile = "/tmp/powh-followtail-test-$$";
+my $write_count = 0;
+my $write_fh;
+
+open $write_fh, ">", $tailfile or plan(
+ skip_all => "can't write to temporary file $tailfile: $!"
+);
+$write_fh->autoflush(1);
+
+plan tests => 10;
+
+POE::Session->create(
+ inline_states => {
+ _start => sub {
+ $_[KERNEL]->yield("on_tick");
+ },
+ on_tick => sub {
+ print $write_fh ++$write_count, " ", time(), "\n";
+ $_[KERNEL]->delay("on_tick" => 1) if $write_count < TESTS;
+ },
+ }
+);
+
+POE::Session->create(
+ inline_states => {
+ _start => sub {
+ $_[HEAP]{tailor} = POE::Wheel::FollowTail->new(
+ Filename => $tailfile,
+ InputEvent => "got_log_line",
+ PollInterval => 3,
+ );
+ $_[KERNEL]->delay(timeout => 11);
+ },
+ got_log_line => sub {
+ my ($write, $time) = split /\s+/, $_[ARG0];
+ ok((time() - $time) < 3, "response time <3 seconds");
+ delete $_[HEAP]{tailor} if $write >= TESTS;
+ },
+ timeout => sub {
+ delete $_[HEAP]{tailor};
+ },
+ }
+);
+
+POE::Kernel->run();
+unlink $tailfile;
Please sign in to comment.
Something went wrong with that request. Please try again.