aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2021-10-12 09:45:57 +0200
committerPeter Eisentraut <peter@eisentraut.org>2021-10-12 09:55:07 +0200
commitc0280bc3edeb9e9958efc14083b6f301d2ef79d5 (patch)
treeed9d0f0b0e084ee5b5515e73a3dc62bbcd571331 /src
parentf9c4cb686800d46ef9e9e90ed5133493b23962af (diff)
downloadpostgresql-c0280bc3edeb9e9958efc14083b6f301d2ef79d5.tar.gz
postgresql-c0280bc3edeb9e9958efc14083b6f301d2ef79d5.zip
psql: More tests
Add some basic tests for command-line option handling and help output, similar to what we have for other command-line programs. This also creates a place to put some more one-off test cases later. Discussion: https://www.postgresql.org/message-id/2570e2ae-fa0f-aac9-f72f-bb59a9983a20@enterprisedb.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/t/001_basic.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl
new file mode 100644
index 00000000000..38426a69d7a
--- /dev/null
+++ b/src/bin/psql/t/001_basic.pl
@@ -0,0 +1,33 @@
+
+# Copyright (c) 2021, PostgreSQL Global Development Group
+
+use strict;
+use warnings;
+
+use PostgresNode;
+use TestLib;
+use Test::More tests => 23;
+
+program_help_ok('psql');
+program_version_ok('psql');
+program_options_handling_ok('psql');
+
+my ($stdout, $stderr);
+my $result;
+
+# test --help=foo, analogous to program_help_ok()
+foreach my $arg (qw(commands variables))
+{
+ $result = IPC::Run::run [ 'psql', "--help=$arg" ], '>', \$stdout, '2>', \$stderr;
+ ok($result, "psql --help=$arg exit code 0");
+ isnt($stdout, '', "psql --help=$arg goes to stdout");
+ is($stderr, '', "psql --help=$arg nothing to stderr");
+}
+
+my $node = PostgresNode->new('main');
+$node->init;
+$node->start;
+
+$node->command_like([ 'psql', '-c', '\copyright' ], qr/Copyright/, '\copyright');
+$node->command_like([ 'psql', '-c', '\help' ], qr/ALTER/, '\help without arguments');
+$node->command_like([ 'psql', '-c', '\help SELECT' ], qr/SELECT/, '\help');