diff options
author | Michael Paquier <michael@paquier.xyz> | 2025-01-22 14:47:13 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2025-01-22 14:47:13 +0900 |
commit | ce1b0f9da03e1cebc293f60b378079b22bd7cc0f (patch) | |
tree | 78c3030de2cc9d201168e8297b5754bf35e37fd2 /src/bin/psql/t/001_basic.pl | |
parent | 4a0e7314f11ee03adfe9df945598c068b4179314 (diff) | |
download | postgresql-ce1b0f9da03e1cebc293f60b378079b22bd7cc0f.tar.gz postgresql-ce1b0f9da03e1cebc293f60b378079b22bd7cc0f.zip |
Improve grammar of options for command arrays in TAP tests
This commit rewrites a good chunk of the command arrays in TAP tests
with a grammar based on the following rules:
- Fat commas are used between option names and their values, making it
clear to both humans and perltidy that values and names are bound
together. This is particularly useful for the readability of multi-line
command arrays, and there are plenty of them in the TAP tests. Most of
the test code is updated to use this style. Some commands used
parenthesis to show the link, or attached values and options in a single
string. These are updated to use fat commas instead.
- Option names are switched to use their long names, making them more
self-documented. Based on a suggestion by Andrew Dunstan.
- Add some trailing commas after the last item in multi-line arrays,
which is a common perl style.
Not all the places are taken care of, but this covers a very good chunk
of them.
Author: Dagfinn Ilmari Mannsåker
Reviewed-by: Michael Paquier, Peter Smith, Euler Taveira
Discussion: https://postgr.es/m/87jzc46d8u.fsf@wibble.ilmari.org
Diffstat (limited to 'src/bin/psql/t/001_basic.pl')
-rw-r--r-- | src/bin/psql/t/001_basic.pl | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index 3c381a35060..3170bc86856 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -216,11 +216,12 @@ $node->safe_psql('postgres', "CREATE TABLE tab_psql_single (a int);"); # Tests with ON_ERROR_STOP. $node->command_ok( [ - 'psql', '-X', - '--single-transaction', '-v', - 'ON_ERROR_STOP=1', '-c', - 'INSERT INTO tab_psql_single VALUES (1)', '-c', - 'INSERT INTO tab_psql_single VALUES (2)' + 'psql', + '--no-psqlrc', + '--single-transaction', + '--set' => 'ON_ERROR_STOP=1', + '--command' => 'INSERT INTO tab_psql_single VALUES (1)', + '--command' => 'INSERT INTO tab_psql_single VALUES (2)', ], 'ON_ERROR_STOP, --single-transaction and multiple -c switches'); my $row_count = @@ -231,11 +232,12 @@ is($row_count, '2', $node->command_fails( [ - 'psql', '-X', - '--single-transaction', '-v', - 'ON_ERROR_STOP=1', '-c', - 'INSERT INTO tab_psql_single VALUES (3)', '-c', - "\\copy tab_psql_single FROM '$tempdir/nonexistent'" + 'psql', + '--no-psqlrc', + '--single-transaction', + '--set' => 'ON_ERROR_STOP=1', + '--command' => 'INSERT INTO tab_psql_single VALUES (3)', + '--command' => "\\copy tab_psql_single FROM '$tempdir/nonexistent'" ], 'ON_ERROR_STOP, --single-transaction and multiple -c switches, error'); $row_count = @@ -252,9 +254,12 @@ append_to_file($copy_sql_file, append_to_file($insert_sql_file, 'INSERT INTO tab_psql_single VALUES (4);'); $node->command_ok( [ - 'psql', '-X', '--single-transaction', '-v', - 'ON_ERROR_STOP=1', '-f', $insert_sql_file, '-f', - $insert_sql_file + 'psql', + '--no-psqlrc', + '--single-transaction', + '--set' => 'ON_ERROR_STOP=1', + '--file' => $insert_sql_file, + '--file' => $insert_sql_file ], 'ON_ERROR_STOP, --single-transaction and multiple -f switches'); $row_count = @@ -265,9 +270,12 @@ is($row_count, '4', $node->command_fails( [ - 'psql', '-X', '--single-transaction', '-v', - 'ON_ERROR_STOP=1', '-f', $insert_sql_file, '-f', - $copy_sql_file + 'psql', + '--no-psqlrc', + '--single-transaction', + '--set' => 'ON_ERROR_STOP=1', + '--file' => $insert_sql_file, + '--file' => $copy_sql_file ], 'ON_ERROR_STOP, --single-transaction and multiple -f switches, error'); $row_count = @@ -281,11 +289,12 @@ is($row_count, '4', # transaction commits. $node->command_fails( [ - 'psql', '-X', - '--single-transaction', '-f', - $insert_sql_file, '-f', - $insert_sql_file, '-c', - "\\copy tab_psql_single FROM '$tempdir/nonexistent'" + 'psql', + '--no-psqlrc', + '--single-transaction', + '--file' => $insert_sql_file, + '--file' => $insert_sql_file, + '--command' => "\\copy tab_psql_single FROM '$tempdir/nonexistent'" ], 'no ON_ERROR_STOP, --single-transaction and multiple -f/-c switches'); $row_count = @@ -298,9 +307,12 @@ is($row_count, '6', # returns a success and the transaction commits. $node->command_ok( [ - 'psql', '-X', '--single-transaction', '-f', - $insert_sql_file, '-f', $insert_sql_file, '-f', - $copy_sql_file + 'psql', + '--no-psqlrc', + '--single-transaction', + '--file' => $insert_sql_file, + '--file' => $insert_sql_file, + '--file' => $copy_sql_file ], 'no ON_ERROR_STOP, --single-transaction and multiple -f switches'); $row_count = @@ -313,11 +325,12 @@ is($row_count, '8', # the transaction commit even if there is a failure in-between. $node->command_ok( [ - 'psql', '-X', - '--single-transaction', '-c', - 'INSERT INTO tab_psql_single VALUES (5)', '-f', - $copy_sql_file, '-c', - 'INSERT INTO tab_psql_single VALUES (6)' + 'psql', + '--no-psqlrc', + '--single-transaction', + '--command' => 'INSERT INTO tab_psql_single VALUES (5)', + '--file' => $copy_sql_file, + '--command' => 'INSERT INTO tab_psql_single VALUES (6)' ], 'no ON_ERROR_STOP, --single-transaction and multiple -c switches'); $row_count = |