[Rt-commit] rt branch, psgi, updated. rt-3.9.4-135-g7a87826

Chia-liang Kao clkao at bestpractical.com
Thu Oct 7 12:56:22 EDT 2010


The branch, psgi has been updated
       via  7a87826e965ac158c22747c3be1a5cbfe03c5e86 (commit)
      from  e7e1d2f54244f42a051f73ab7d6e9afc8a709ea3 (commit)

Summary of changes:
 lib/RT/Test.pm     |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/RT/Test/Web.pm |    3 ++-
 2 files changed, 49 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 7a87826e965ac158c22747c3be1a5cbfe03c5e86
Author: Chia-liang Kao <clkao at bestpractical.com>
Date:   Fri Oct 8 00:52:08 2010 +0800

    external test with psgi server

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 0cab4db..8cfdf9f 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -1110,6 +1110,53 @@ sub started_ok {
     return $self->$function( $variant, @_ );
 }
 
+sub start_plack_server {
+    my $self = shift;
+
+    require Plack::Loader;
+    my $plack_server = Plack::Loader->load
+        ('Standalone',
+         port => $port,
+         server_ready => sub {
+             kill 'USR1' => getppid();
+         });
+
+    my $pid = fork();
+    die "failed to fork" unless defined $pid;
+
+    if ($pid) {
+        # We are expecting a USR1 from the child process after it's
+        # ready to listen.
+        my $handled;
+        $SIG{USR1} = sub { $handled = 1};
+        sleep 15;
+        Test::More::diag "did not get expected USR1 for test server readiness"
+            unless $handled;
+        push @SERVERS, $pid;
+        my $Tester = Test::Builder->new;
+        $Tester->ok(1, @_);
+
+        return ("http://localhost:$port", RT::Test::Web->new);
+    } else {
+        $RT::Handle = RT::Handle->new;
+        $RT::Handle->dbh( undef );
+        RT->ConnectToDatabase;
+
+        # the attribute cache holds on to a stale dbh
+        delete $RT::System->{attributes};
+    }
+
+    require POSIX;
+    if ( $^O !~ /MSWin32/ ) {
+        POSIX::setsid()
+            or die "Can't start a new session: $!";
+    }
+
+    require RT::Interface::Web::Handler;
+    $plack_server->run(RT::Interface::Web::Handler->PSGIApp);
+    exit;
+}
+
 sub start_inline_server {
     my $self = shift;
 
diff --git a/lib/RT/Test/Web.pm b/lib/RT/Test/Web.pm
index ce7131a..ded0270 100644
--- a/lib/RT/Test/Web.pm
+++ b/lib/RT/Test/Web.pm
@@ -175,7 +175,8 @@ sub goto_create_ticket {
 sub get_warnings {
     my $self = shift;
 
-    if ($self->isa('Test::WWW::Mechanize::PSGI')) {
+    # FIXME: need psgi mw for stashed warnings
+    if ($self->isa('Test::WWW::Mechanize::PSGI') || $ENV{'RT_TEST_WEB_HANDLER'} eq 'plack') {
         Test::More::ok(1);
         return;
     }

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


More information about the Rt-commit mailing list