Re: pgsql: Add basic TAP tests for psql's tab-completion logic. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pgsql: Add basic TAP tests for psql's tab-completion logic.
Date
Msg-id 4659.1578171401@sss.pgh.pa.us
Whole thread Raw
In response to Re: pgsql: Add basic TAP tests for psql's tab-completion logic.  (Peter Geoghegan <pg@bowt.ie>)
Responses Re: pgsql: Add basic TAP tests for psql's tab-completion logic.  (Peter Geoghegan <pg@bowt.ie>)
Re: pgsql: Add basic TAP tests for psql's tab-completion logic.  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-hackers
Peter Geoghegan <pg@bowt.ie> writes:
> FWIW, I find it very surprising that it was possible for the test to
> fail on my workstation/server, without it failing on any buildfarm
> animals.

Yeah, there is still something unexplained about that.  We've so far
failed to pin the blame on either readline version or environment
settings ... but what else could be causing you to get different
results?

For the record, I'm currently running around and trying the attached
(on top of latest HEAD, 60ab7c80b) on the various configurations
I have here.  Could you confirm that it works, or doesn't, in your
environment --- and if it doesn't, what's the output?

            regards, tom lane

diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl
index 1dc87b5..ebf603f 100644
--- a/src/bin/psql/t/010_tab_completion.pl
+++ b/src/bin/psql/t/010_tab_completion.pl
@@ -38,14 +38,12 @@ $node->safe_psql('postgres',
 my $historyfile = "${TestLib::log_path}/010_psql_history.txt";
 $ENV{PSQL_HISTORY} = $historyfile;

-# Debug investigation
-note "TERM is set to '" . ($ENV{TERM} || "<undef>") . "'";
-
-# Ensure that readline/libedit puts out xterm escapes, not something else.
-$ENV{TERM} = 'xterm';
-
-# regexp to match one xterm escape sequence (CSI style only, for now)
-my $escseq = "(\e\\[[0-9;]*[A-Za-z])";
+# 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};

 # fire up an interactive psql session
 my $in  = '';
@@ -110,12 +108,8 @@ check_completion(
     "select \\* from my\a?tab",
     "complete my<tab> to mytab when there are multiple choices");

-# some versions of readline/libedit require two tabs here, some only need one.
-# also, some might issue escape sequences to reposition the cursor, clear the
-# line, etc, instead of just printing some spaces.
-check_completion(
-    "\t\t",
-    "mytab$escseq*123( |$escseq)+mytab$escseq*246",
+# some versions of readline/libedit require two tabs here, some only need one
+check_completion("\t\t", "mytab123 +mytab246",
     "offer multiple table choices");

 check_completion("2\t", "246 ",

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pgsql: Add basic TAP tests for psql's tab-completion logic.
Next
From: Peter Geoghegan
Date:
Subject: Re: pgsql: Add basic TAP tests for psql's tab-completion logic.