better reporting
[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;
23 while (1) {
24 $Test->ok( $count++, "$count output_ok" );
25 sleep(1);
3c3db18c 26 }
3543c999 27
3c3db18c 28 }
29 no Moose;
30}
31
32package main;
33use Cwd;
34
35## Try to make sure we are in the test directory
36chdir 't' if ( Cwd::cwd() !~ m|/t$| );
37my $cwd = Cwd::cwd();
3543c999 38my $app = TestOutput->new(
39 pidbase => $cwd,
40 test_output => join( '/', $cwd, 'results' ),
41);
42daemonize_ok( $app, 'child forked okay' );
43sleep(5); # give ourself a chance to produce some output
44$app->stop( no_exit => 1 );
45
46check_test_output($app);
47unlink( $app->test_output );