Skip to content

Commit

Permalink
remove last manual fork() to create a server in t/local/back.t so win…
Browse files Browse the repository at this point in the history
…32 stops emitting black smoke
  • Loading branch information
shadowcat-mst committed Mar 24, 2012
1 parent 657174d commit da11c71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
6 changes: 6 additions & 0 deletions Changes
Expand Up @@ -3,6 +3,12 @@ Revision history for WWW::Mechanize
Mech now has its own mailing list at Google Groups:
http://groups.google.com/group/www-mechanize-users

[TESTS]

Update t/local/back.t to use LocalServer for 404 checking to avoid fails
on win32. Fix by Matt S Trout, patient diagnostics and testing provided
by jayefuu of freenode #perl

[CHANGES]

1.72 Thu Feb 2 18:37:28 EST 2012
Expand Down
22 changes: 4 additions & 18 deletions t/local/back.t
Expand Up @@ -2,7 +2,7 @@

use warnings;
use strict;
use Test::More tests => 47;
use Test::More tests => 48;
use lib qw( t t/local );
use LocalServer;
use HTTP::Daemon;
Expand Down Expand Up @@ -128,24 +128,10 @@ my @links = qw(

is( scalar @{$mech->{page_stack}}, 0, 'Pre-404 check' );

my $server404 = HTTP::Daemon->new(LocalAddr => 'localhost') or die;
my $server404url = $server404->url;
my $server404 = LocalServer->spawn( html => '<html><body>ARGH</body></html>' );
isa_ok( $server404, 'LocalServer' );

die 'Cannot fork' if (! defined (my $pid404 = fork()));
END {
local $?;
kill KILL => $pid404 if $pid404; # Extreme prejudice intended, because we do not
# want the global cleanup to be done twice.
}

if (! $pid404) { # Fake HTTP server code: a true 404-compliant server!
while ( my $c = $server404->accept() ) {
while ( $c->get_request() ) {
$c->send_response( HTTP::Response->new(404) );
$c->close();
}
}
}
my $server404url = $server404->error_notfound('404check');

$mech->get($server404url);
is( $mech->status, 404 , '404 check') or
Expand Down

0 comments on commit da11c71

Please sign in to comment.