add test to psql for coverage with --help, \e option, encoding option
Started by Dong Wook Leeover 3 years ago2 messages
Hi hackers,
I try to add to psql test about --help, \e, and the encoding option.
---
Regards,
DongWook Lee.
Re: add test to psql for coverage with --help, \e option, encoding option
I confirmed that I missed the patch file.
And the current code is different from when I wrote the patch, so I
don't think my patch will be meaningful anymore.
Show quoted text
On Sat, Sep 3, 2022 at 6:08 PM Dong Wook Lee <sh95119@gmail.com> wrote:
Hi hackers,
I try to add to psql test about --help, \e, and the encoding option.---
Regards,
DongWook Lee.
Attachments:
v1_add_test_to_psql.patchapplication/octet-stream; name=v1_add_test_to_psql.patchDownload
From e9a8d6d08265888bfd7534884c5d3207610559d6 Mon Sep 17 00:00:00 2001
From: Lee Dong Wook <sh95119@gmail.com>
Date: Tue, 5 Jul 2022 18:31:26 +0900
Subject: [PATCH] add test for psql command with paramenter.
- \help with parameter
- \e
- \encoding
---
src/bin/psql/t/001_basic.pl | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl
index 57486ceffdb7..d2ba512867b5 100644
--- a/src/bin/psql/t/001_basic.pl
+++ b/src/bin/psql/t/001_basic.pl
@@ -70,7 +70,39 @@ sub psql_fails_like
psql_like($node, '\copyright', qr/Copyright/, '\copyright');
psql_like($node, '\help', qr/ALTER/, '\help without arguments');
-psql_like($node, '\help SELECT', qr/SELECT/, '\help with argument');
+
+# ready \help with arguments
+my $help_str = $node->safe_psql('postgres', '\help');
+my @help_commands = split('\n', $help_str);
+shift @help_commands;
+
+map { s/^\s+|\s+$//g; } @help_commands;
+
+my @result;
+foreach (@help_commands) {
+ my @commands = (substr($_, 0, 33), substr($_, 33));
+ push @result, @commands;
+}
+
+s{^\s+|\s+$}{}g foreach @result;
+
+# \help with arguments
+foreach my $args (@result) {
+ psql_like($node, "\\help $args", qr/$args/, "\\help with $args arguments");
+}
+
+# test \e
+$ENV{'PSQL_EDITOR'} = ($PostgreSQL::Test::Utils::windows_os) ? "type" : "/bin/cat";
+
+# create some junk files for \e testing.
+$node->safe_psql('postgres',
+ "\\o e.out\n"
+ . "SELECT 1;\n");
+
+psql_like($node, "\\e e.out", qr/1/, "test \e");
+
+# test \encoding
+psql_like($node, "\\encoding", qr/UTF8/, "test \encoding");
# Test clean handling of unsupported replication command responses
psql_fails_like(