Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update tests to match POE 0.9999_03.

Add POE::Test::Loops and move the VERSION number there so that the
package name can be installed and/or depended upon.

Add keyword expansion to files that didn't have it set.

Bump the version to 0.98.
  • Loading branch information...
commit 4e129e718a398d519ac36ac112d8a1f68d1e902c 1 parent d16c911
Rocco Caputo authored
1  poe-test-loops/MANIFEST
@@ -5,6 +5,7 @@ Makefile.PL
5 5 README
6 6 bin/poe-gen-tests
7 7 lib/POE/Test/DondeEstan.pm
  8 +lib/POE/Test/Loops.pm
8 9 lib/POE/Test/Loops/all_errors.pm
9 10 lib/POE/Test/Loops/comp_tcp.pm
10 11 lib/POE/Test/Loops/comp_tcp_concurrent.pm
2  poe-test-loops/Makefile.PL
@@ -11,7 +11,7 @@ WriteMakefile(
11 11 AUTHOR => 'Rocco Caputo <rcaputo@cpan.org>',
12 12 ABSTRACT => 'POE::Loop test suite',
13 13 LICENSE => 'perl',
14   - VERSION_FROM => 'bin/poe-gen-tests',
  14 + VERSION_FROM => 'lib/POE/Test/Loops.pm',
15 15 PREREQ_PM => {
16 16 'Test::More' => 0,
17 17 },
7 poe-test-loops/bin/poe-gen-tests
@@ -5,10 +5,7 @@ use File::Spec;
5 5 use File::Path;
6 6 use File::Find;
7 7 use Getopt::Long;
8   -
9   -use vars qw($VERSION $REVISION);
10   -$VERSION = '0.97'; # NOTE - Should be #.## (two decimal places)
11   -$REVISION = do {my($r)=(q$Revision$=~/(\d+)/);sprintf"0.%04d",$r};
  8 +use POE::Test::Loops;
12 9
13 10 my $dir_base;
14 11 my $flag_help;
@@ -451,7 +448,7 @@ Rocco Caputo <rcaputo@cpan.org>.
451 448 Benjamin Smith <bsmith@cpan.org>.
452 449 Countless other people.
453 450
454   -These tests are Copyright 1998-2007 by Rocco Caputo, Benjamin Smith,
  451 +These tests are Copyright 1998-2008 by Rocco Caputo, Benjamin Smith,
455 452 and countless contributors. All rights are reserved. These tests are
456 453 free software; you may redistribute them and/or modify them under the
457 454 same terms as Perl itself.
37 poe-test-loops/lib/POE/Test/Loops.pm
... ... @@ -0,0 +1,37 @@
  1 +# $Id$
  2 +
  3 +package POE::Test::Loops;
  4 +
  5 +use strict;
  6 +use vars qw($VERSION);
  7 +
  8 +use vars qw($VERSION $REVISION);
  9 +$VERSION = '0.98'; # NOTE - Should be #.## (two decimal places)
  10 +$REVISION = do {my($r)=(q$Revision$=~/(\d+)/);sprintf"0.%04d",$r};
  11 +
  12 +1;
  13 +
  14 +__END__
  15 +
  16 +=head1 NAME
  17 +
  18 +POE::Test::Loops - Reusable tests for POE::Loop authors
  19 +
  20 +=head1 SYNOPSIS
  21 +
  22 +See L<poe-gen-tests>.
  23 +
  24 +=head1 DESCRIPTION
  25 +
  26 +See L<poe-gen-tests>, which is a utility to generate the actual tests
  27 +for your POE::Loop subclass.
  28 +
  29 +=head1 SEE ALSO
  30 +
  31 +L<POE::Loop> and L<poe-gen-tests>.
  32 +
  33 +=head1 AUTHOR & COPYRIGHT
  34 +
  35 +See L<poe-gen-tests>.
  36 +
  37 +=cut
11 poe-test-loops/lib/POE/Test/Loops/comp_tcp_concurrent.pm
@@ -17,7 +17,10 @@ BEGIN {
17 17 }
18 18 }
19 19
20   -use Test::More tests => (42);
  20 +my $NUM_CLIENTS;
  21 +BEGIN { $NUM_CLIENTS = 9 } # rt.cpan.org 32034
  22 +
  23 +use Test::More tests => $NUM_CLIENTS * 2;
21 24
22 25 diag( "You might see a 'disconnect' error during this test." );
23 26 diag( "It may be ignored." );
@@ -193,7 +196,7 @@ sub do_servers {
193 196 }
194 197
195 198 sub do_clients {
196   - foreach my $N (1..21) {
  199 + foreach my $N (1..$NUM_CLIENTS) {
197 200 DEBUG and warn "$$: SPAWN\n";
198 201 two_clients($N);
199 202 }
@@ -228,7 +231,7 @@ sub two_clients {
228 231 ServerInput => sub {
229 232 my ($heap, $input) = @_[HEAP, ARG0];
230 233 DEBUG and warn("$$: acceptor client $N got input ($input)");
231   - if( $input =~ /#21$/ ) {
  234 + if( $input =~ /#$NUM_CLIENTS$/ ) {
232 235 $_[HEAP]->{server}->put( 'quit' );
233 236 }
234 237
@@ -273,7 +276,7 @@ sub two_clients {
273 276 ServerInput => sub {
274 277 my ($heap, $input) = @_[HEAP, ARG0];
275 278 DEBUG and warn("$$: callback client $N got input ($input)");
276   - if( $input =~ /#21$/ ) {
  279 + if( $input =~ /#$NUM_CLIENTS$/ ) {
277 280 $_[HEAP]->{server}->put( 'quit' );
278 281 }
279 282 $_[KERNEL]->yield('shutdown');
4 poe-test-loops/lib/POE/Test/Loops/k_signals_rerun.pm
@@ -11,6 +11,7 @@ use strict;
11 11 use Test::More;
12 12
13 13 if ($^O eq "MSWin32") {
  14 + plan skip_all => "Perl can't handle these tests on $^O - it crashes";
14 15 eval 'use Win32::Console';
15 16 if ($@) {
16 17 plan skip_all => "Win32::Console is required on $^O - try ActivePerl";
@@ -21,6 +22,7 @@ if ($^O eq "MSWin32") {
21 22 if (exists $INC{'Event.pm'}) {
22 23 plan skip_all => "Perl crashes in this test with Event on $^O";
23 24 }
  25 + plan skip_all => "Perl on $^O is too fragile for this test - it crashes";
24 26 }
25 27
26 28 plan tests => 9;
@@ -37,6 +39,7 @@ foreach my $die_on_bad_exit ( 0, 1 ) {
37 39 inline_states => {
38 40 stdout => sub { },
39 41 stdin => sub { },
  42 + _parent => sub { },
40 43 _start => sub {
41 44 my ( $kernel, $session, $heap ) = @_[KERNEL, SESSION, HEAP];
42 45
@@ -88,6 +91,7 @@ foreach my $die_on_bad_exit ( 0, 1 ) {
88 91 },
89 92 _stop => sub { },
90 93 _child => sub { },
  94 + _parent => sub { },
91 95 },
92 96 );
93 97
2  poe-test-loops/lib/POE/Test/Loops/wheel_curses.pm
@@ -113,7 +113,7 @@ sub test_keystroke {
113 113
114 114 $heap->{child_input} .= $input;
115 115 if ($heap->{child_input} =~ /!/) {
116   - delete $heap->{curses}; }
  116 + delete $heap->{curses};
117 117 delete $heap->{readwrite};
118 118 ok( $heap->{child_input} eq "this is a test!", "got keystrokes" );
119 119 }
8 poe-test-loops/lib/POE/Test/Loops/wheel_readline.pm
@@ -132,14 +132,6 @@ BEGIN {
132 132 if ($^O eq "MSWin32") {
133 133 $error = "$^O cannot multiplex terminals";
134 134 }
135   - if ($^O eq "darwin") {
136   - foreach my $bad (qw(Event.pm IO/Poll.pm)) {
137   - if (exists $INC{$bad}) {
138   - $error = "$bad can't work with ttys under $^O";
139   - last;
140   - }
141   - }
142   - }
143 135 if (!-t STDIN) {
144 136 $error = "not running in a terminal";
145 137 }
29 poe-test-loops/lib/POE/Test/Loops/wheel_run.pm
@@ -29,6 +29,9 @@ BEGIN {
29 29 elsif (exists $INC{"Event.pm"}) {
30 30 $error = "$^O\'s fork() emulation breaks Event";
31 31 }
  32 + else {
  33 + $error = "Signal handling on $^O is too fragile - Perl crashes";
  34 + }
32 35
33 36 $RUNNING_WIN32 = 1;
34 37 }
@@ -84,7 +87,7 @@ if ($notify_eof_flag) {
84 87 sleep 10;
85 88 }
86 89 END
87   - $text =~ s/\n/ /g;
  90 + $text =~ s/\s+/ /g;
88 91
89 92 my $os_quote = ($^O eq 'MSWin32') ? q(") : q(');
90 93 $chld_program_string = [ $^X, "-we", "$text CORE::exit 0" ];
@@ -189,7 +192,7 @@ sub do_nonexistent {
189 192 }
190 193
191 194 sub do_error {
192   - DEBUG and warn "$_[HEAP]->{label}: $_[ARG0] error $_[ARG1]: $_[ARG2]";
  195 + DEBUG and warn "$_[HEAP]->{label}: $_[ARG0] error $_[ARG1]: $_[ARG2]\n";
193 196 }
194 197
195 198 # {{{ definition of the main test session
@@ -202,17 +205,17 @@ sub main_perform_state {
202 205 my $action = $heap->{expected}->[0][0];
203 206
204 207 unless (ref $action) {
205   - DEBUG and warn "$heap->{label}: performing put state: $action";
  208 + DEBUG and warn "$heap->{label}: performing put state: $action\n";
206 209 eval { $heap->{wheel}->put( $action ) };
207 210 } elsif ($action->[0] =~ m/^(?:pause|resume)_std(?:out|err)$/) {
208 211 my $method = $action->[0];
209   - DEBUG and warn "$heap->{label}: performing method state: $method";
  212 + DEBUG and warn "$heap->{label}: performing method state: $method\n";
210 213 $heap->{wheel}->$method();
211 214 } elsif ($action->[0] eq "kill") {
212   - DEBUG and warn "$heap->{label}: performing kill";
  215 + DEBUG and warn "$heap->{label}: performing kill\n";
213 216 $heap->{wheel}->kill();
214 217 } elsif ($action->[0] eq "shutdown_stdin") {
215   - DEBUG and warn "$heap->{label}: shutdown_stdin";
  218 + DEBUG and warn "$heap->{label}: shutdown_stdin\n";
216 219 $heap->{wheel}->shutdown_stdin();
217 220 } else {
218 221 warn "weird action @$action, this is a bug in the test script";
@@ -281,7 +284,7 @@ sub main_start {
281 284 # timeout delay
282 285 timeout_incref();
283 286
284   - DEBUG and warn "$heap->{label}: _start";
  287 + DEBUG and warn "$heap->{label}: _start\n";
285 288 }
286 289
287 290 my $x__ = 0;
@@ -294,14 +297,14 @@ sub main_stop {
294 297 is( $heap->{flushes}, $heap->{flushes_expected},
295 298 "$heap->{label} flush count ($$)" )
296 299 unless $heap->{ignore_flushes};
297   - DEBUG and warn "$heap->{label}: _stop ($$)";
  300 + DEBUG and warn "$heap->{label}: _stop ($$)\n";
298 301 }
299 302
300 303 sub main_stdin {
301 304 my $heap = $_[HEAP];
302 305 $heap->{flushes}++;
303 306 timeout_poke();
304   - DEBUG and warn "$heap->{label}: stdin flush";
  307 + DEBUG and warn "$heap->{label}: stdin flush\n";
305 308 }
306 309
307 310 sub main_output {
@@ -318,7 +321,7 @@ sub main_output {
318 321 is($input, "$prefix: ".$heap->{expected}->[0][1][1],
319 322 "$heap->{label} $state response");
320 323
321   - DEBUG and warn "$heap->{label}: $state $input";
  324 + DEBUG and warn "$heap->{label}: $state $input\n";
322 325
323 326 timeout_poke();
324 327
@@ -339,7 +342,7 @@ sub main_close {
339 342 delete $_[HEAP]->{wheel};
340 343 timeout_decref();
341 344 $kernel->sig("CHLD" => undef);
342   - DEBUG and warn "$heap->{label}: close";
  345 + DEBUG and warn "$heap->{label}: close\n";
343 346 }
344 347
345 348 sub main_sigchld {
@@ -347,7 +350,9 @@ sub main_sigchld {
347 350 my ($signame, $child_pid) = @_[ARG0, ARG1];
348 351
349 352 my $our_child = $heap->{wheel} ? $heap->{wheel}->PID : -1;
350   - DEBUG and warn "$heap->{label}: sigchld $signame for $child_pid ($our_child)";
  353 + DEBUG and warn(
  354 + "$heap->{label}: sigchld $signame for $child_pid ($our_child)\n"
  355 + );
351 356
352 357 return unless $heap->{wheel} and $our_child == $child_pid;
353 358
6 poe-test-loops/lib/POE/Test/Loops/wheel_sf_ipv6.pm
@@ -11,7 +11,7 @@ use Socket;
11 11 BEGIN {
12 12 my $error;
13 13
14   - eval 'use Socket6';
  14 + eval 'use Socket6 ()';
15 15 if ( length($@) or not exists($INC{"Socket6.pm"}) ) {
16 16 $error = "Socket6 is needed for IPv6 tests";
17 17 }
@@ -60,7 +60,7 @@ diag( "packets across your localhost interface." );
60 60 POE::Component::Server::TCP->new(
61 61 Port => $tcp_server_port,
62 62 Address => '::1',
63   - Domain => AF_INET6,
  63 + Domain => Socket6::AF_INET6,
64 64 Alias => 'server',
65 65 ClientConnected => \&server_got_connect,
66 66 ClientInput => \&server_got_input,
@@ -109,7 +109,7 @@ sub server_got_error {
109 109 POE::Component::Client::TCP->new(
110 110 RemoteAddress => '::1',
111 111 RemotePort => $tcp_server_port,
112   - Domain => AF_INET6,
  112 + Domain => Socket6::AF_INET6,
113 113 BindAddress => '::1',
114 114 Connected => \&client_got_connect,
115 115 ServerInput => \&client_got_input,
6 poe-test-loops/t/01_no_tests.t
... ... @@ -1,2 +1,6 @@
1 1 # $Id$
2   -print "1..0 # Skip This distribution consists of tests.\n";
  2 +
  3 +use warnings;
  4 +use strict;
  5 +use Test::More tests => 1;
  6 +use_ok("POE::Test::Loops");

0 comments on commit 4e129e7

Please sign in to comment.
Something went wrong with that request. Please try again.