[Bps-public-commit] HTTP-Server-Simple-Mason branch, master, updated. 4a150599c0b18d9f767776efa045b78345687c6d

Ruslan Zakirov ruz at bestpractical.com
Fri Oct 2 00:02:32 EDT 2009


The branch, master has been updated
       via  4a150599c0b18d9f767776efa045b78345687c6d (commit)
      from  ab48b2a7756b6aaaea647884fc98c17f8fca0c22 (commit)

Summary of changes:
 t/01live.t            |   19 ++++++++++++-------
 t/04unhandlederrors.t |   12 +++++++++---
 t/05handlederrors.t   |   12 +++++++++---
 3 files changed, 30 insertions(+), 13 deletions(-)

- Log -----------------------------------------------------------------
commit 4a150599c0b18d9f767776efa045b78345687c6d
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Fri Oct 2 08:00:08 2009 +0400

    cleanup after tests
    
    these three tests start servers and then kill process.
    killing a process leaves tempdirs. Instead we create tempdir
    in the main test program and cleanup it there

diff --git a/t/01live.t b/t/01live.t
index b028757..1788c0f 100644
--- a/t/01live.t
+++ b/t/01live.t
@@ -8,9 +8,11 @@ BEGIN {
     }
 }
 
-use_ok( HTTP::Server::Simple::Mason);
+use_ok(HTTP::Server::Simple::Mason);
 
-my $s=MyApp::Server->new(13432);
+use File::Temp qw/tempdir/;
+my $mason_root = tempdir( CLEANUP => 1 );
+my $s=MyApp::Server->new(13432, $mason_root);
 is($s->port(),13432,"Constructor set port correctly");
 my $pid=$s->background();
 like($pid, qr/^-?\d+$/,'pid is numeric');
@@ -20,16 +22,19 @@ like($content,qr/2$/,"Returns a page containing only 2");
 is(kill(9,$pid),1,'Signaled 1 process successfully');
 
 
-
-
 package MyApp::Server;
 use base qw/HTTP::Server::Simple::Mason/;
 use File::Spec;
 
-use File::Temp qw/tempdir/;
+my $root;
+sub new {
+    $root = $_[2];
+    return shift->SUPER::new( @_ );
+}
+
 sub mason_config {
-    my $root = tempdir( CLEANUP => 1 );
-    open (PAGE, '>', File::Spec->catfile($root, 'index.html')) or die $!;
+    open (PAGE, '>', File::Spec->catfile($root, 'index.html'))
+        or die $!;
     print PAGE '<%1+1%>';
     close (PAGE);
     return ( comp_root => $root );
diff --git a/t/04unhandlederrors.t b/t/04unhandlederrors.t
index 2cb49df..578542c 100644
--- a/t/04unhandlederrors.t
+++ b/t/04unhandlederrors.t
@@ -10,7 +10,9 @@ BEGIN {
 
 use_ok( HTTP::Server::Simple::Mason);
 
-my $s=MyApp::Server->new(13432);
+use File::Temp qw/tempdir/;
+my $mason_root = tempdir( CLEANUP => 1 );
+my $s=MyApp::Server->new(13432, $mason_root);
 is($s->port(),13432,"Constructor set port correctly");
 my $pid=$s->background();
 like($pid, qr/^-?\d+$/,'pid is numeric');
@@ -25,10 +27,14 @@ is(kill(9,$pid),1,'Signaled 1 process successfully');
 package MyApp::Server;
 use base qw/HTTP::Server::Simple::Mason/;
 use File::Spec;
-use File::Temp qw/tempdir/;
+
+my $root;
+sub new {
+    $root = $_[2];
+    return shift->SUPER::new( @_ );
+}
 
 sub mason_config {
-    my $root =  tempdir( CLEANUP => 1 );
     open (PAGE, '>', File::Spec->catfile($root, 'index.html')) or die $!;
     print PAGE '<%die%>';
     close (PAGE);
diff --git a/t/05handlederrors.t b/t/05handlederrors.t
index 1ed77bd..8cf74a4 100644
--- a/t/05handlederrors.t
+++ b/t/05handlederrors.t
@@ -10,7 +10,9 @@ BEGIN {
 
 use_ok( HTTP::Server::Simple::Mason);
 
-my $s=MyApp::Server->new(13432);
+use File::Temp qw/tempdir/;
+my $mason_root = tempdir( CLEANUP => 1 );
+my $s=MyApp::Server->new(13432, $mason_root);
 is($s->port(),13432,"Constructor set port correctly");
 my $pid=$s->background();
 like($pid, qr/^-?\d+$/,'pid is numeric');
@@ -25,10 +27,14 @@ is(kill(9,$pid),1,'Signaled 1 process successfully');
 package MyApp::Server;
 use base qw/HTTP::Server::Simple::Mason/;
 use File::Spec;
-use File::Temp qw/tempdir/;
+
+my $root;
+sub new {
+    $root = $_[2];
+    return shift->SUPER::new( @_ );
+}
 
 sub mason_config {
-    my $root = tempdir(CLEANUP => 1);
     open (PAGE, '>', File::Spec->catfile($root, 'index.html')) or die $!;
     print PAGE '<%die%>';
     close (PAGE);

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list