Skip to content

Commit 41a2844

Browse files
committed
Clean up some pg_dump tests
1) Remove useless entries from "unlike" lists. Runs that are not listed in "like" don't need to be excluded in "unlike". 2) Ensure there is always a "like" list, even if it is empty. This makes the test more self-documenting. 3) Use predefined lists such as %full_runs where appropriate, instead of listing all runs separately. Also add code that checks 1 and 2 automatically and dies with an error for violations. Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://www.postgresql.org/message-id/flat/1f8cb371-e84e-434e-0367-6b716fb16fa1@eisentraut.org
1 parent d17ffc7 commit 41a2844

File tree

1 file changed

+21
-57
lines changed

1 file changed

+21
-57
lines changed

src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@
818818
regexp => qr/^\QALTER COLLATION public.test0 OWNER TO \E.+;/m,
819819
collation => 1,
820820
like => { %full_runs, section_pre_data => 1, },
821-
unlike => { %dump_test_schema_runs, no_owner => 1, },
821+
unlike => { no_owner => 1, },
822822
},
823823

824824
'ALTER FOREIGN DATA WRAPPER dummy OWNER TO' => {
@@ -977,7 +977,7 @@
977977
create_sql =>
978978
'ALTER SCHEMA public OWNER TO "regress_quoted \"" role";',
979979
regexp => qr/^(GRANT|REVOKE)/m,
980-
unlike => { defaults_public_owner => 1 },
980+
like => {},
981981
},
982982

983983
'ALTER SEQUENCE test_table_col1_seq' => {
@@ -1285,9 +1285,7 @@
12851285
{ %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
12861286
unlike => {
12871287
exclude_dump_test_schema => 1,
1288-
only_dump_test_table => 1,
12891288
no_owner => 1,
1290-
role => 1,
12911289
only_dump_measurement => 1,
12921290
},
12931291
},
@@ -1351,7 +1349,6 @@
13511349
binary_upgrade => 1,
13521350
no_large_objects => 1,
13531351
schema_only => 1,
1354-
section_pre_data => 1,
13551352
},
13561353
},
13571354

@@ -3210,7 +3207,6 @@
32103207
binary_upgrade => 1,
32113208
exclude_dump_test_schema => 1,
32123209
schema_only => 1,
3213-
only_dump_measurement => 1,
32143210
},
32153211
},
32163212
@@ -3457,7 +3453,6 @@
34573453
'Disabled trigger on partition is not created' => {
34583454
regexp => qr/CREATE TRIGGER test_trigger.*ON dump_test_second_schema/,
34593455
like => {},
3460-
unlike => { %full_runs, %dump_test_schema_runs },
34613456
},
34623457
34633458
# Triggers on partitions should not be dropped individually
@@ -3834,35 +3829,12 @@
38343829
\QCREATE INDEX measurement_city_id_logdate_idx ON ONLY dump_test.measurement USING\E
38353830
/xm,
38363831
like => {
3837-
binary_upgrade => 1,
3838-
clean => 1,
3839-
clean_if_exists => 1,
3840-
compression => 1,
3841-
createdb => 1,
3842-
defaults => 1,
3843-
exclude_test_table => 1,
3844-
exclude_test_table_data => 1,
3845-
no_toast_compression => 1,
3846-
no_large_objects => 1,
3847-
no_privs => 1,
3848-
no_owner => 1,
3849-
no_table_access_method => 1,
3850-
only_dump_test_schema => 1,
3851-
pg_dumpall_dbprivs => 1,
3852-
pg_dumpall_exclude => 1,
3853-
schema_only => 1,
3832+
%full_runs,
3833+
%dump_test_schema_runs,
38543834
section_post_data => 1,
3855-
test_schema_plus_large_objects => 1,
3856-
only_dump_measurement => 1,
3857-
exclude_measurement_data => 1,
38583835
},
38593836
unlike => {
38603837
exclude_dump_test_schema => 1,
3861-
only_dump_test_table => 1,
3862-
pg_dumpall_globals => 1,
3863-
pg_dumpall_globals_clean => 1,
3864-
role => 1,
3865-
section_pre_data => 1,
38663838
exclude_measurement => 1,
38673839
},
38683840
},
@@ -3913,7 +3885,6 @@
39133885
role => 1,
39143886
section_post_data => 1,
39153887
only_dump_measurement => 1,
3916-
exclude_measurement_data => 1,
39173888
},
39183889
unlike => {
39193890
exclude_measurement => 1,
@@ -3927,35 +3898,12 @@
39273898
\QALTER INDEX dump_test.measurement_pkey ATTACH PARTITION dump_test_second_schema.measurement_y2006m2_pkey\E
39283899
/xm,
39293900
like => {
3930-
binary_upgrade => 1,
3931-
clean => 1,
3932-
clean_if_exists => 1,
3933-
compression => 1,
3934-
createdb => 1,
3935-
defaults => 1,
3936-
exclude_dump_test_schema => 1,
3937-
exclude_test_table => 1,
3938-
exclude_test_table_data => 1,
3939-
no_toast_compression => 1,
3940-
no_large_objects => 1,
3941-
no_privs => 1,
3942-
no_owner => 1,
3943-
no_table_access_method => 1,
3944-
pg_dumpall_dbprivs => 1,
3945-
pg_dumpall_exclude => 1,
3901+
%full_runs,
39463902
role => 1,
3947-
schema_only => 1,
39483903
section_post_data => 1,
39493904
only_dump_measurement => 1,
3950-
exclude_measurement_data => 1,
39513905
},
39523906
unlike => {
3953-
only_dump_test_schema => 1,
3954-
only_dump_test_table => 1,
3955-
pg_dumpall_globals => 1,
3956-
pg_dumpall_globals_clean => 1,
3957-
section_pre_data => 1,
3958-
test_schema_plus_large_objects => 1,
39593907
exclude_measurement => 1,
39603908
},
39613909
},
@@ -4929,6 +4877,22 @@
49294877
$test_db = $tests{$test}->{database};
49304878
}
49314879
4880+
# Check for proper test definitions
4881+
#
4882+
# There should be a "like" list, even if it is empty. (This
4883+
# makes the test more self-documenting.)
4884+
if (!defined($tests{$test}->{like}))
4885+
{
4886+
die "missing \"like\" in test \"$test\"";
4887+
}
4888+
# Check for useless entries in "unlike" list. Runs that are
4889+
# not listed in "like" don't need to be excluded in "unlike".
4890+
if ($tests{$test}->{unlike}->{$test_key} &&
4891+
!defined($tests{$test}->{like}->{$test_key}))
4892+
{
4893+
die "useless \"unlike\" entry \"$test_key\" in test \"$test\"";
4894+
}
4895+
49324896
# Skip any collation-related commands if there is no collation support
49334897
if (!$collation_support && defined($tests{$test}->{collation}))
49344898
{

0 commit comments

Comments
 (0)