Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit187b899

Browse files
committed
Backport BackgroundPsql perl test module
Backport the new BackgroundPsql modules and the constructor functions,background_psql() and interactive_psql, to all supportedbranches. That makes it easier to backpatch tests that use it.BackgroundPsql was introduced in version 16. On version 16, thiscommit backports just the new timeout argument from master (commit334f512). On older branches, the whole facility. This includes thechange to `use warnings FATAL => 'all'`, which we haven't otherwisebackported, but it seems good to keep the file identical acrossbranches.Discussion:https://www.postgresql.org/message-id/b7c64f20-ea01-4f15-9088-0cd6832af149@iki.fi
1 parentb8f953d commit187b899

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

‎src/test/perl/PostgreSQL/Test/BackgroundPsql.pm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Copyright (c) 2021-2023, PostgreSQL Global Development Group
2+
# Copyright (c) 2021-2024, PostgreSQL Global Development Group
33

44
=pod
55
@@ -54,7 +54,7 @@ initiated by PostgreSQL::Test::Cluster.
5454
packagePostgreSQL::Test::BackgroundPsql;
5555

5656
use strict;
57-
use warnings;
57+
use warningsFATAL=>'all';
5858

5959
use Carp;
6060
use Config;
@@ -68,7 +68,7 @@ use Test::More;
6868
6969
=over
7070
71-
=itemPostgreSQL::Test::BackgroundPsql->new(interactive, @params)
71+
=itemPostgreSQL::Test::BackgroundPsql->new(interactive, @psql_params, timeout)
7272
7373
Builds a new object of classC<PostgreSQL::Test::BackgroundPsql> for either
7474
an interactive or background session and starts it. IfC<interactive> is
@@ -81,7 +81,7 @@ string. For C<interactive> sessions, IO::Pty is required.
8181
subnew
8282
{
8383
my$class =shift;
84-
my ($interactive,$psql_params) =@_;
84+
my ($interactive,$psql_params,$timeout) =@_;
8585
my$psql = {
8686
'stdin'=>'',
8787
'stdout'=>'',
@@ -96,8 +96,10 @@ sub new
9696
"Forbidden caller of constructor: package:$package, file:$file:$line"
9797
unless$package->isa('PostgreSQL::Test::Cluster');
9898

99-
$psql->{timeout} =
100-
IPC::Run::timeout($PostgreSQL::Test::Utils::timeout_default);
99+
$psql->{timeout} = IPC::Run::timeout(
100+
defined($timeout)
101+
?$timeout
102+
:$PostgreSQL::Test::Utils::timeout_default);
101103

102104
if ($interactive)
103105
{

‎src/test/perl/PostgreSQL/Test/Cluster.pm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,8 +1972,6 @@ sub psql
19721972
19731973
InvokeB<psql> onB<$dbname> and return a BackgroundPsql object.
19741974
1975-
A timeout of $PostgreSQL::Test::Utils::timeout_default is set up.
1976-
19771975
psql is invoked in tuples-only unaligned mode with reading ofB<.psqlrc>
19781976
disabled. That may be overridden by passing extra psql parameters.
19791977
@@ -1991,6 +1989,11 @@ By default, the B<psql> method invokes the B<psql> program with ON_ERROR_STOP=1
19911989
set, so SQL execution is stopped at the first error and exit code 3 is
19921990
returned. SetB<on_error_stop> to 0 to ignore errors instead.
19931991
1992+
=itemtimeout => 'interval'
1993+
1994+
Set a timeout for a background psql session. By default, timeout of
1995+
$PostgreSQL::Test::Utils::timeout_default is set up.
1996+
19941997
=itemreplication =>B<value>
19951998
19961999
If set, addB<replication=value> to the conninfo string.
@@ -2012,6 +2015,7 @@ sub background_psql
20122015
local%ENV =$self->_get_env();
20132016

20142017
my$replication =$params{replication};
2018+
my$timeout =undef;
20152019

20162020
my@psql_params = (
20172021
$self->installed_command('psql'),
@@ -2023,12 +2027,13 @@ sub background_psql
20232027
'-');
20242028

20252029
$params{on_error_stop} = 1unlessdefined$params{on_error_stop};
2030+
$timeout =$params{timeout}ifdefined$params{timeout};
20262031

20272032
push@psql_params,'-v','ON_ERROR_STOP=1'if$params{on_error_stop};
20282033
push@psql_params, @{$params{extra_params} }
20292034
ifdefined$params{extra_params};
20302035

2031-
return PostgreSQL::Test::BackgroundPsql->new(0, \@psql_params);
2036+
return PostgreSQL::Test::BackgroundPsql->new(0, \@psql_params,$timeout);
20322037
}
20332038

20342039
=pod

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp