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