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) = @_;
43d819aa 17 $self->output_ok()
18 if $self->is_daemon;
3c3db18c 19 };
20
21 sub output_ok {
3543c999 22 my ($self) = @_;
23 my $count = 1;
7a4ac6b2 24 for ( 0 .. 3 ) {
3543c999 25 $Test->ok( $count++, "$count output_ok" );
26 sleep(1);
3c3db18c 27 }
3c3db18c 28 }
29 no Moose;
30}
31
32package main;
33use Cwd;
b916501e 34use strict;
35use warnings;
3c3db18c 36
37## Try to make sure we are in the test directory
38chdir 't' if ( Cwd::cwd() !~ m|/t$| );
39my $cwd = Cwd::cwd();
3543c999 40my $app = TestOutput->new(
41 pidbase => $cwd,
42 test_output => join( '/', $cwd, 'results' ),
43);
44daemonize_ok( $app, 'child forked okay' );
7a4ac6b2 45sleep(3); # give ourself a chance to produce some output
b916501e 46
47my $warnings = "";
48{
49 local $SIG{__WARN__} = sub { $warnings .= $_[0]; warn @_ };
50 $app->stop( no_exit => 1 );
51}
52
53is($warnings, "", "No warnings from stop");
3543c999 54
55check_test_output($app);
56unlink( $app->test_output );
7a4ac6b2 57exit;