aboutsummaryrefslogtreecommitdiff
path: root/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/perl/PostgreSQL/Test/BackgroundPsql.pm')
-rw-r--r--src/test/perl/PostgreSQL/Test/BackgroundPsql.pm28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
index 3c2aca1c5d7..c7a3d3e920d 100644
--- a/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
+++ b/src/test/perl/PostgreSQL/Test/BackgroundPsql.pm
@@ -68,7 +68,7 @@ use Test::More;
=over
-=item PostgreSQL::Test::BackgroundPsql->new(interactive, @psql_params, timeout)
+=item PostgreSQL::Test::BackgroundPsql->new(interactive, @psql_params, timeout, wait)
Builds a new object of class C<PostgreSQL::Test::BackgroundPsql> for either
an interactive or background session and starts it. If C<interactive> is
@@ -76,12 +76,15 @@ true then a PTY will be attached. C<psql_params> should contain the full
command to run psql with all desired parameters and a complete connection
string. For C<interactive> sessions, IO::Pty is required.
+This routine will not return until psql has started up and is ready to
+consume input. Set B<wait> to 0 to return immediately instead.
+
=cut
sub new
{
my $class = shift;
- my ($interactive, $psql_params, $timeout) = @_;
+ my ($interactive, $psql_params, $timeout, $wait) = @_;
my $psql = {
'stdin' => '',
'stdout' => '',
@@ -119,14 +122,25 @@ sub new
my $self = bless $psql, $class;
- $self->_wait_connect();
+ $wait = 1 unless defined($wait);
+ if ($wait)
+ {
+ $self->wait_connect();
+ }
return $self;
}
-# Internal routine for awaiting psql starting up and being ready to consume
-# input.
-sub _wait_connect
+=pod
+
+=item $session->wait_connect
+
+Returns once psql has started up and is ready to consume input. This is called
+automatically for clients unless requested otherwise in the constructor.
+
+=cut
+
+sub wait_connect
{
my ($self) = @_;
@@ -187,7 +201,7 @@ sub reconnect_and_clear
$self->{stdin} = '';
$self->{stdout} = '';
- $self->_wait_connect();
+ $self->wait_connect();
}
=pod