Re: pgsql: Add basic TAP tests for psql's tab-completion logic.
Peter Geoghegan <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.devel.general |
|---|---|
| Message-ID | <CAH2-WzkqStzPVGCQXdd428GEUCs_VGc9kY_VhcCVt6bKNEc1zQ@mail.gmail.com> |
On Sat, Jan 4, 2020 at 3:39 PM Tom Lane <[email protected]> wrote: > Hm, well, HEAD still has the hackery with explicit accounting for > escape sequences. Could you try it with the patch I showed to unset > TERM and remove that stuff? (It won't apply exactly to HEAD, but > the diffs are simple enough, or you could revert to 60ab7c80b first.) With the attached patch against HEAD (which is based on your earlier unset-TERM-in-tab-completion-test.patch), I find that the tests fail as follows: cd /code/postgresql/patch/build/../source/src/bin/psql && TESTDIR='/code/postgresql/patch/build/src/bin/psql' PATH="/code/postgresql/patch/build/tmp_install/code/postgresql/patch/install/bin:$PATH" LD_LIBRARY_PATH="/code/postgresql/patch/build/tmp_install/code/postgresql/patch/install/lib" PGPORT='65432' PG_REGRESS='/code/postgresql/patch/build/src/bin/psql/../../../src/test/regress/pg_regress' REGRESS_SHLIB='/code/postgresql/patch/build/src/test/regress/regress.so' /usr/bin/prove -I /code/postgresql/patch/build/../source/src/test/perl/ -I /code/postgresql/patch/build/../source/src/bin/psql t/*.pl t/010_tab_completion.pl .. 8/? # Failed test 'offer multiple table choices' # at t/010_tab_completion.pl line 112. # Actual output was "\r\n\e[01;35mmytab\e[0m\e[K123\e[0m\e[K \e[01;35mmytab\e[0m\e[K246\e[0m\e[K \r\npostgres=# select * from mytab\r\n\e[01;35mmytab\e[0m\e[K123\e[0m\e[K \e[01;35mmytab\e[0m\e[K246\e[0m\e[K \r\npostgres=# select * from mytab" # # Looks like you failed 1 test of 12. t/010_tab_completion.pl .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/12 subtests Test Summary Report ------------------- t/010_tab_completion.pl (Wstat: 256 Tests: 12 Failed: 1) Failed test: 8 Non-zero exit status: 1 Files=1, Tests=12, 7 wallclock secs ( 0.02 usr 0.00 sys + 0.36 cusr 0.12 csys = 0.50 CPU) Result: FAIL Makefile:87: recipe for target 'check' failed make: *** [check] Error 1 -- Peter Geoghegan
HEAD-unset-TERM-in-tab-completion-test.patch
(application/octet-stream, 1.5 KB)
diff --git a/src/bin/psql/t/010_tab_completion.pl b/src/bin/psql/t/010_tab_completion.pl
index 0f1d596b2b..ebf603f82e 100644
--- a/src/bin/psql/t/010_tab_completion.pl
+++ b/src/bin/psql/t/010_tab_completion.pl
@@ -38,11 +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>") . "'";
-
-# 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 = '';
@@ -107,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 ",