Fix appclass actions in the tests
[catagits/Test-WWW-Mechanize-Catalyst.git] / t / lib / ExternalCatty.pm
1 package ExternalCatty;
2 use strict;
3 use warnings;
4 use Catalyst qw/-Engine=HTTP/;
5
6 __PACKAGE__->config( name => 'ExternalCatty' );
7 __PACKAGE__->setup;
8
9 # The Cat HTTP server background option is useless here :-(
10 # Thus we have to provide our own background method.
11 sub background {
12     my $self  = shift;
13     my $port  = shift;
14     my $child = fork;
15     die "Can't fork Cat HTTP server: $!" unless defined $child;
16     return $child if $child;
17
18     if ( $^O !~ /MSWin32/ ) {
19         require POSIX;
20         POSIX::setsid() or die "Can't start a new session: $!";
21     }
22
23     $self->run($port);
24 }
25
26 1;
27