diff options
| author | Tom Lane | 2023-12-23 16:50:33 +0000 |
|---|---|---|
| committer | Tom Lane | 2023-12-23 16:50:33 +0000 |
| commit | da44ff312ea3b2868b8fab68944017cb56427709 (patch) | |
| tree | 3434d3e1bf0faec241030e9a44c54ee93c45e13a /src/bin/psql | |
| parent | 3e2e0d5ad7fcb89d18a71cbfc885ef184e1b6f2e (diff) | |
Set readline-relevant ENV vars in interactive_psql(), not caller.
Commit 664d75753 pulled 010_tab_completion.pl's infrastructure for
invoking an interactive psql session out into a generally-useful test
function, but it didn't move enough stuff. We need to set up various
environment variables that readline will look at, both to ensure
stability of test results and to prevent test actions from cluttering
the calling user's ~/.psql_history. Expecting calling scripts to
remember to do that is too failure-prone: the other existing caller
001_password.pl did not do it. Hence, remove those initialization
steps from 010_tab_completion.pl and put them into interactive_psql().
Since interactive_psql was already making a local ENV hash, this has
no effect on calling scripts.
Discussion: https://postgr.es/m/794610.1703182896@sss.pgh.pa.us
Diffstat (limited to 'src/bin/psql')
| -rw-r--r-- | src/bin/psql/t/010_tab_completion.pl | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl index 4cd0fa46803..f2d2809aef6 100644 --- a/src/bin/psql/t/010_tab_completion.pl +++ b/src/bin/psql/t/010_tab_completion.pl @@ -46,25 +46,6 @@ $node->safe_psql('postgres', . "CREATE TYPE enum1 AS ENUM ('foo', 'bar', 'baz', 'BLACK');\n" . "CREATE PUBLICATION some_publication;\n"); -# Developers would not appreciate this test adding a bunch of junk to -# their ~/.psql_history, so be sure to redirect history into a temp file. -# We might as well put it in the test log directory, so that buildfarm runs -# capture the result for possible debugging purposes. -my $historyfile = "${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt"; -$ENV{PSQL_HISTORY} = $historyfile; - -# Another pitfall for developers is that they might have a ~/.inputrc -# file that changes readline's behavior enough to affect this 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}; - # In a VPATH build, we'll be started in the source directory, but we want # to run in the build directory so that we can use relative paths to # access the tab_comp_dir subdirectory; otherwise the output from filename @@ -91,8 +72,13 @@ open $FH, ">", "tab_comp_dir/afile456" print $FH "other stuff\n"; close $FH; +# Arrange to capture, not discard, the interactive session's history output. +# Put it in the test log directory, so that buildfarm runs capture the result +# for possible debugging purposes. +my $historyfile = "${PostgreSQL::Test::Utils::log_path}/010_psql_history.txt"; + # fire up an interactive psql session -my $h = $node->interactive_psql('postgres'); +my $h = $node->interactive_psql('postgres', history_file => $historyfile); # Simple test case: type something and see if psql responds as expected sub check_completion |
