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

Commitda44ff3

Browse files
committed
Set readline-relevant ENV vars in interactive_psql(), not caller.
Commit664d757 pulled 010_tab_completion.pl's infrastructure forinvoking an interactive psql session out into a generally-useful testfunction, but it didn't move enough stuff. We need to set up variousenvironment variables that readline will look at, both to ensurestability of test results and to prevent test actions from clutteringthe calling user's ~/.psql_history. Expecting calling scripts toremember to do that is too failure-prone: the other existing caller001_password.pl did not do it. Hence, remove those initializationsteps from 010_tab_completion.pl and put them into interactive_psql().Since interactive_psql was already making a local ENV hash, this hasno effect on calling scripts.Discussion:https://postgr.es/m/794610.1703182896@sss.pgh.pa.us
1 parent3e2e0d5 commitda44ff3

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

‎src/bin/psql/t/010_tab_completion.pl

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,6 @@
4646
."CREATE TYPE enum1 AS ENUM ('foo', 'bar', 'baz', 'BLACK');\n"
4747
."CREATE PUBLICATION some_publication;\n");
4848

49-
# Developers would not appreciate this test adding a bunch of junk to
50-
# their ~/.psql_history, so be sure to redirect history into a temp file.
51-
# We might as well put it in the test log directory, so that buildfarm runs
52-
# capture the result for possible debugging purposes.
53-
my$historyfile ="${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt";
54-
$ENV{PSQL_HISTORY} =$historyfile;
55-
56-
# Another pitfall for developers is that they might have a ~/.inputrc
57-
# file that changes readline's behavior enough to affect this test.
58-
# So ignore any such file.
59-
$ENV{INPUTRC} ='/dev/null';
60-
61-
# Unset $TERM so that readline/libedit won't use any terminal-dependent
62-
# escape sequences; that leads to way too many cross-version variations
63-
# in the output.
64-
delete$ENV{TERM};
65-
# Some versions of readline inspect LS_COLORS, so for luck unset that too.
66-
delete$ENV{LS_COLORS};
67-
6849
# In a VPATH build, we'll be started in the source directory, but we want
6950
# to run in the build directory so that we can use relative paths to
7051
# access the tab_comp_dir subdirectory; otherwise the output from filename
@@ -91,8 +72,13 @@
9172
print$FH"other stuff\n";
9273
close$FH;
9374

75+
# Arrange to capture, not discard, the interactive session's history output.
76+
# Put it in the test log directory, so that buildfarm runs capture the result
77+
# for possible debugging purposes.
78+
my$historyfile ="${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt";
79+
9480
# fire up an interactive psql session
95-
my$h =$node->interactive_psql('postgres');
81+
my$h =$node->interactive_psql('postgres',history_file=>$historyfile);
9682

9783
# Simple test case: type something and see if psql responds as expected
9884
subcheck_completion

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,14 +2128,17 @@ Errors occurring later are the caller's problem.
21282128
21292129
Be sure to "quit" the returned object when done with it.
21302130
2131-
The only extra parameter currently accepted is
2132-
21332131
=over
21342132
21352133
=itemextra_params => ['--single-transaction']
21362134
21372135
If given, it must be an array reference containing additional parameters toB<psql>.
21382136
2137+
=itemhistory_file =>B<path>
2138+
2139+
Cause the interactiveB<psql> session to write its command history toB<path>.
2140+
If not given, the history is sent toB</dev/null>.
2141+
21392142
=back
21402143
21412144
This requires IO::Pty in addition to IPC::Run.
@@ -2148,6 +2151,27 @@ sub interactive_psql
21482151

21492152
local%ENV =$self->_get_env();
21502153

2154+
# Since the invoked psql will believe it's interactive, it will use
2155+
# readline/libedit if available. We need to adjust some environment
2156+
# settings to prevent unwanted side-effects.
2157+
2158+
# Developers would not appreciate tests adding a bunch of junk to
2159+
# their ~/.psql_history, so redirect readline history somewhere else.
2160+
# If the calling script doesn't specify anything, just bit-bucket it.
2161+
$ENV{PSQL_HISTORY} =$params{history_file} ||'/dev/null';
2162+
2163+
# Another pitfall for developers is that they might have a ~/.inputrc
2164+
# file that changes readline's behavior enough to affect the test.
2165+
# So ignore any such file.
2166+
$ENV{INPUTRC} ='/dev/null';
2167+
2168+
# Unset TERM so that readline/libedit won't use any terminal-dependent
2169+
# escape sequences; that leads to way too many cross-version variations
2170+
# in the output.
2171+
delete$ENV{TERM};
2172+
# Some versions of readline inspect LS_COLORS, so for luck unset that too.
2173+
delete$ENV{LS_COLORS};
2174+
21512175
my@psql_params = (
21522176
$self->installed_command('psql'),
21532177
'-XAt','-d',$self->connstr($dbname));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp