use strictures in all tests
[gitmo/MooseX-Daemonize.git] / t / 02.stdout.t
index b506f25..d9a23ee 100644 (file)
@@ -1,4 +1,7 @@
-use Test::More no_plan => 1;
+use strict;
+use warnings;
+
+use Test::More 'no_plan';
 use Test::Builder;
 use Test::MooseX::Daemonize;
 use MooseX::Daemonize;
@@ -14,34 +17,46 @@ my $Test = Test::Builder->new;
 
     after start => sub {
         my ($self) = @_;
-        $self->output_ok();
+        $self->output_ok() 
+            if $self->is_daemon;
     };
 
     sub output_ok {
         my ($self) = @_;
         my $count = 1;
-        while (1) {
+        for ( 0 .. 3 ) {
             $Test->ok( $count++, "$count output_ok" );
             sleep(1);
         }
-
     }
     no Moose;
 }
 
 package main;
-use Cwd;
+use strict;
+use warnings;
+
+use File::Spec::Functions;
+use File::Temp qw(tempdir);
+
+my $dir = tempdir( CLEANUP => 1 );
 
 ## Try to make sure we are in the test directory
-chdir 't' if ( Cwd::cwd() !~ m|/t$| );
-my $cwd = Cwd::cwd();
 my $app = TestOutput->new(
-    pidbase     => $cwd,
-    test_output => join( '/', $cwd, 'results' ),
+    pidbase     => $dir,
+    test_output => catfile($dir, 'results'),
 );
 daemonize_ok( $app, 'child forked okay' );
-sleep(5);    # give ourself a chance to produce some output
-$app->stop( no_exit => 1 );
+sleep(3);    # give ourself a chance to produce some output
+
+my $warnings = "";
+{
+       local $SIG{__WARN__} = sub { $warnings .= $_[0]; warn @_ };
+       $app->stop( no_exit => 1 );
+}
+
+is($warnings, "", "No warnings from stop");
 
 check_test_output($app);
 unlink( $app->test_output );
+exit;