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

Commit11652f9

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 parent0977bd6 commit11652f9

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
@@ -2048,14 +2048,17 @@ Errors occurring later are the caller's problem.
20482048
20492049
Be sure to "quit" the returned object when done with it.
20502050
2051-
The only extra parameter currently accepted is
2052-
20532051
=over
20542052
20552053
=itemextra_params => ['--single-transaction']
20562054
20572055
If given, it must be an array reference containing additional parameters toB<psql>.
20582056
2057+
=itemhistory_file =>B<path>
2058+
2059+
Cause the interactiveB<psql> session to write its command history toB<path>.
2060+
If not given, the history is sent toB</dev/null>.
2061+
20592062
=back
20602063
20612064
This requires IO::Pty in addition to IPC::Run.
@@ -2068,6 +2071,27 @@ sub interactive_psql
20682071

20692072
local%ENV =$self->_get_env();
20702073

2074+
# Since the invoked psql will believe it's interactive, it will use
2075+
# readline/libedit if available. We need to adjust some environment
2076+
# settings to prevent unwanted side-effects.
2077+
2078+
# Developers would not appreciate tests adding a bunch of junk to
2079+
# their ~/.psql_history, so redirect readline history somewhere else.
2080+
# If the calling script doesn't specify anything, just bit-bucket it.
2081+
$ENV{PSQL_HISTORY} =$params{history_file} ||'/dev/null';
2082+
2083+
# Another pitfall for developers is that they might have a ~/.inputrc
2084+
# file that changes readline's behavior enough to affect the test.
2085+
# So ignore any such file.
2086+
$ENV{INPUTRC} ='/dev/null';
2087+
2088+
# Unset TERM so that readline/libedit won't use any terminal-dependent
2089+
# escape sequences; that leads to way too many cross-version variations
2090+
# in the output.
2091+
delete$ENV{TERM};
2092+
# Some versions of readline inspect LS_COLORS, so for luck unset that too.
2093+
delete$ENV{LS_COLORS};
2094+
20712095
my@psql_params = (
20722096
$self->installed_command('psql'),
20732097
'-XAt','-d',$self->connstr($dbname));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp