okay,.. I think this is ready for release
[gitmo/MooseX-Daemonize.git] / t / 02.stdout.t
CommitLineData
3c3db18c 1use Test::More no_plan => 1;
2use Test::Builder;
3use Test::MooseX::Daemonize;
3543c999 4use MooseX::Daemonize;
3c3db18c 5
6my $Test = Test::Builder->new;
3c3db18c 7
8{
9
10 package TestOutput;
11 use Moose;
12 with qw(MooseX::Daemonize);
3543c999 13 with qw(Test::MooseX::Daemonize::Testable); # setup our test environment
14
3c3db18c 15 after start => sub {
16 my ($self) = @_;
3543c999 17 $self->output_ok();
3c3db18c 18 };
19
20 sub output_ok {
3543c999 21 my ($self) = @_;
22 my $count = 1;
7a4ac6b2 23 for ( 0 .. 3 ) {
3543c999 24 $Test->ok( $count++, "$count output_ok" );
25 sleep(1);
3c3db18c 26 }
3c3db18c 27 }
28 no Moose;
29}
30
31package main;
32use Cwd;
b916501e 33use strict;
34use warnings;
3c3db18c 35
36## Try to make sure we are in the test directory
37chdir 't' if ( Cwd::cwd() !~ m|/t$| );
38my $cwd = Cwd::cwd();
3543c999 39my $app = TestOutput->new(
40 pidbase => $cwd,
41 test_output => join( '/', $cwd, 'results' ),
42);
43daemonize_ok( $app, 'child forked okay' );
7a4ac6b2 44sleep(3); # give ourself a chance to produce some output
b916501e 45
46my $warnings = "";
47{
48 local $SIG{__WARN__} = sub { $warnings .= $_[0]; warn @_ };
49 $app->stop( no_exit => 1 );
50}
51
52is($warnings, "", "No warnings from stop");
3543c999 53
54check_test_output($app);
55unlink( $app->test_output );
7a4ac6b2 56exit;