keep namespaces clean
[gitmo/MooseX-Daemonize.git] / lib / Test / MooseX / Daemonize.pm
index 1f7239f..dbccc44 100644 (file)
@@ -1,26 +1,16 @@
-package Test::MooseX::Daemonize;
 use strict;
+use warnings;
+package Test::MooseX::Daemonize;
 
 # BEGIN CARGO CULTING
-use Sub::Exporter;
-use Test::Builder;
-
-our $VERSION   = '0.03';
-our $AUTHORITY = 'cpan:PERIGRIN';
-
-{
-    my @exports = qw[
-      daemonize_ok
-      check_test_output
-    ];
+use Sub::Exporter::ForMethods 'method_installer';
+use Sub::Exporter -setup => {
+    exports => [ qw(daemonize_ok check_test_output) ],
+    groups  => { default => [ qw(daemonize_ok check_test_output) ] },
+    installer => method_installer,
+};
 
-    Sub::Exporter::setup_exporter(
-        {
-            exports => \@exports,
-            groups  => { default => \@exports }
-        }
-    );
-}
+use Test::Builder;
 
 our $Test = Test::Builder->new;
 
@@ -51,20 +41,22 @@ sub check_test_output {
 
            # We don't just call ok(!$not), because that generates diagnostics of
            # its own for failures. We only want the diagnostics from the child.
-            my $num = $Test->current_test;
-            $Test->current_test( ++$num );
-            $Test->_print("$status $num - $text\n");
+            my $orig_no_diag = $Test->no_diag;
+            $Test->no_diag(1);
+            $Test->ok(!$not, $text);
+            $Test->no_diag($orig_no_diag);
         }
         elsif ( $line =~ s/\A#\s?// ) {
             $Test->diag($line);
         }
         else {
-            $Test->_print_diag("$label: $line (unrecognised)\n");
+            $Test->diag("$label: $line (unrecognised)\n");
         }
     }
 }
 
 package Test::MooseX::Daemonize::Testable;
+
 use Moose::Role;
 
 has test_output => (
@@ -98,12 +90,8 @@ __END__
 
 Test::MooseX::Daemonize - Tool to help test MooseX::Daemonize applications
 
-=head1 VERSION
-
-This document describes MooseX::Daemonize version 0.0.1
-
 =head1 SYNOPSIS
-    
+
     use File::Spec::Functions;
     use File::Temp qw(tempdir);
 
@@ -119,8 +107,8 @@ This document describes MooseX::Daemonize version 0.0.1
 
 =head1 DESCRIPTION
 
-This module provides some basic Test::Builder compatible test methods to 
-use when writing tests for you MooseX::Daemonize based modules. 
+This module provides some basic Test::Builder compatible test methods to
+use when writing tests for you MooseX::Daemonize based modules.
 
 =head1 EXPORTED FUNCTIONS
 
@@ -128,16 +116,16 @@ use when writing tests for you MooseX::Daemonize based modules.
 
 =item B<daemonize_ok ( $daemon, ?$msg )>
 
-This will attempt to daemonize your C<$daemon> returning ok on 
+This will attempt to daemonize your C<$daemon> returning ok on
 success and not ok on failure.
 
 =item B<check_test_output ( $daemon )>
 
-This is expected to be used with a C<$daemon> which does the 
+This is expected to be used with a C<$daemon> which does the
 B<Test::MooseX::Daemonize::Testable> role (included in this package
-see the source for more info). It will collect the test output 
-from your daemon and apply it in the parent process by mucking 
-around with L<Test::Builder> stuff, again, read the source for 
+see the source for more info). It will collect the test output
+from your daemon and apply it in the parent process by mucking
+around with L<Test::Builder> stuff, again, read the source for
 more info. If we get time we will document this more thoroughly.
 
 =back
@@ -164,7 +152,7 @@ Chris Prather  C<< <perigrin@cpan.org> >>
 
 =head1 LICENCE AND COPYRIGHT
 
-Copyright (c) 2007-2008, Chris Prather C<< <perigrin@cpan.org> >>. All rights reserved.
+Copyright (c) 2007-2011, Chris Prather C<< <perigrin@cpan.org> >>. All rights reserved.
 
 This module is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself. See L<perlartistic>.