whitespace fixes
[gitmo/MooseX-Daemonize.git] / t / 02.stdout.t
CommitLineData
5fd0553e 1use strict;
2use warnings;
3
45b2dbae 4use Test::More;
3c3db18c 5use Test::Builder;
6use Test::MooseX::Daemonize;
3543c999 7use MooseX::Daemonize;
3c3db18c 8
9my $Test = Test::Builder->new;
3c3db18c 10
11{
12
13 package TestOutput;
14 use Moose;
15 with qw(MooseX::Daemonize);
3543c999 16 with qw(Test::MooseX::Daemonize::Testable); # setup our test environment
17
3c3db18c 18 after start => sub {
19 my ($self) = @_;
f3372ec9 20 $self->output_ok()
43d819aa 21 if $self->is_daemon;
3c3db18c 22 };
23
24 sub output_ok {
3543c999 25 my ($self) = @_;
26 my $count = 1;
7a4ac6b2 27 for ( 0 .. 3 ) {
3543c999 28 $Test->ok( $count++, "$count output_ok" );
29 sleep(1);
3c3db18c 30 }
3c3db18c 31 }
32 no Moose;
33}
34
35package main;
b916501e 36use strict;
37use warnings;
3c3db18c 38
380acf65 39use File::Spec::Functions;
40use File::Temp qw(tempdir);
41
42my $dir = tempdir( CLEANUP => 1 );
43
3c3db18c 44## Try to make sure we are in the test directory
3543c999 45my $app = TestOutput->new(
380acf65 46 pidbase => $dir,
47 test_output => catfile($dir, 'results'),
3543c999 48);
49daemonize_ok( $app, 'child forked okay' );
7a4ac6b2 50sleep(3); # give ourself a chance to produce some output
b916501e 51
52my $warnings = "";
53{
f3372ec9 54 local $SIG{__WARN__} = sub { $warnings .= $_[0]; warn @_ };
55 $app->stop( no_exit => 1 );
b916501e 56}
57
58is($warnings, "", "No warnings from stop");
3543c999 59
60check_test_output($app);
61unlink( $app->test_output );
45b2dbae 62
63done_testing;
64
7a4ac6b2 65exit;