aboutsummaryrefslogtreecommitdiff
path: root/src/test/perl/PostgreSQL/Test/Cluster.pm
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/perl/PostgreSQL/Test/Cluster.pm')
-rw-r--r--src/test/perl/PostgreSQL/Test/Cluster.pm28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 131edb07418..5f0f04b5558 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -2048,14 +2048,17 @@ Errors occurring later are the caller's problem.
Be sure to "quit" the returned object when done with it.
-The only extra parameter currently accepted is
-
=over
=item extra_params => ['--single-transaction']
If given, it must be an array reference containing additional parameters to B<psql>.
+=item history_file => B<path>
+
+Cause the interactive B<psql> session to write its command history to B<path>.
+If not given, the history is sent to B</dev/null>.
+
=back
This requires IO::Pty in addition to IPC::Run.
@@ -2068,6 +2071,27 @@ sub interactive_psql
local %ENV = $self->_get_env();
+ # Since the invoked psql will believe it's interactive, it will use
+ # readline/libedit if available. We need to adjust some environment
+ # settings to prevent unwanted side-effects.
+
+ # Developers would not appreciate tests adding a bunch of junk to
+ # their ~/.psql_history, so redirect readline history somewhere else.
+ # If the calling script doesn't specify anything, just bit-bucket it.
+ $ENV{PSQL_HISTORY} = $params{history_file} || '/dev/null';
+
+ # Another pitfall for developers is that they might have a ~/.inputrc
+ # file that changes readline's behavior enough to affect the test.
+ # So ignore any such file.
+ $ENV{INPUTRC} = '/dev/null';
+
+ # Unset TERM so that readline/libedit won't use any terminal-dependent
+ # escape sequences; that leads to way too many cross-version variations
+ # in the output.
+ delete $ENV{TERM};
+ # Some versions of readline inspect LS_COLORS, so for luck unset that too.
+ delete $ENV{LS_COLORS};
+
my @psql_params = (
$self->installed_command('psql'),
'-XAt', '-d', $self->connstr($dbname));