X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTest%2FMooseX%2FDaemonize.pm;h=281fcd354242979efe8d9030c2d0989d292b0ac7;hb=5231273c6ddb272733286beb5e3d5faf94cfd437;hp=c5efab6a100d34435e4d35d00db6137cb53013ea;hpb=fe0eeebc050311829e0f93a2d86018be78598d47;p=gitmo%2FMooseX-Daemonize.git diff --git a/lib/Test/MooseX/Daemonize.pm b/lib/Test/MooseX/Daemonize.pm index c5efab6..281fcd3 100644 --- a/lib/Test/MooseX/Daemonize.pm +++ b/lib/Test/MooseX/Daemonize.pm @@ -1,12 +1,13 @@ -package Test::MooseX::Daemonize; use strict; +use warnings; +package Test::MooseX::Daemonize; + +our $AUTHORITY = 'cpan:PERIGRIN'; # BEGIN CARGO CULTING use Sub::Exporter; use Test::Builder; -our $VERSION = '0.03'; -our $AUTHORITY = 'cpan:PERIGRIN'; { my @exports = qw[ @@ -51,15 +52,16 @@ 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"); } } } @@ -98,30 +100,25 @@ __END__ Test::MooseX::Daemonize - Tool to help test MooseX::Daemonize applications -=head1 VERSION +=head1 SYNOPSIS -This document describes MooseX::Daemonize version 0.0.1 + use File::Spec::Functions; + use File::Temp qw(tempdir); -=head1 SYNOPSIS - - package main; - use Cwd; + 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 $file = join( '/', $cwd, 'im_alive' ); - my $daemon = FileMaker->new( pidbase => '.', filename => $file ); + my $file = catfile( $dir, "im_alive" ); + my $daemon = FileMaker->new( pidbase => $dir, filename => $file ); daemonize_ok( $daemon, 'child forked okay' ); ok( -e $file, "$file exists" ); - unlink($file); =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 @@ -129,16 +126,16 @@ use when writing tests for you MooseX::Daemonize based modules. =item B -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 -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 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 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 stuff, again, read the source for more info. If we get time we will document this more thoroughly. =back @@ -165,7 +162,7 @@ Chris Prather C<< >> =head1 LICENCE AND COPYRIGHT -Copyright (c) 2007, Chris Prather C<< >>. All rights reserved. +Copyright (c) 2007-2011, Chris Prather C<< >>. 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.