Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31a8b77

Browse files
committed
Improve pg_dump regression tests and code coverage
These improvements bring the lines-of-code coverage of pg_dump.c up to87.7% (at least using LCOV 1.12, 1.11 seems to differ slightly). Nearlyevery function is covered, three of the four which aren't are onlycalled when talking to older PG instances.There is more which can, and should, be done here to improve thecoverage but it's past time to see what the buildfarm thinks of this.What has been added:- Coverage for many more command-line options- Use command_fails_like instead of command_exit_is- Operator classes, operator families- Text search configuration, templates, parsers, dictionaries- FDWs, servers, foreign tables- Materialized views- Improved Publications / Subscriptions test (though this needs work, see PG10 open items and tests marked with XXX in 002_pg_dump.pl)- Unlogged tables- Partitioned tables- Additional ACL testing for various object typesThere is room for improvement, specifically:- Various type-based option (alignment, storage, etc)- Composite type collation- Extra Procedural language functions (inline, validator)- Different function options (SRF, Transform, config, security definer, cost, leakproof)- OpClass options (default, storage, order by, recheck)- OpFamily options (order by, recheck)- Aggregate functions (combinefunc, serialfunc, deserialfunc, etc)- Text Search parser 'headline'- Text Search template 'init'- FDW options (handler, validator, options)- Server options (type, version, options)- User mapping options- Default ACLs for sequences, types- Security labels- View circular dependencies (last function that needs coverage)- Toast table autovacuum options- Replica identity options- Independent indexes (plus marking them as clustered on)- Deferrable / initially deferred constraints- Independent domain constraintsThere's bits of extension pg_dump'ing also not covered, but those willneed to go into test_pg_dump (such as having a filter for configtables).Last, but not least, this approximately halves the number of tests runwith 'ok()' by removing the ok()-based checking of if all runs arecovered by each test. Instead, 002_pg_dump.pl will just exit out insuch a case (with a message in the log file). In general, when addingtests, cover all runs unless there is a very good reason not to (such asadding a 'catch-all' case). With these changes, the resulting outputand number of "tests" run is actually reduced.
1 parent164bdbe commit31a8b77

File tree

2 files changed

+3340
-561
lines changed

2 files changed

+3340
-561
lines changed

‎src/bin/pg_dump/t/001_basic.pl

Lines changed: 85 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Config;
55
use PostgresNode;
66
use TestLib;
7-
use Test::Moretests=>42;
7+
use Test::Moretests=>70;
88

99
my$tempdir = TestLib::tempdir;
1010
my$tempdir_short = TestLib::tempdir_short;
@@ -28,82 +28,124 @@
2828
# Test various invalid options and disallowed combinations
2929
# Doesn't require a PG instance to be set up, so do this first.
3030

31-
command_exit_is(['pg_dump','qqq','abc' ],
32-
1,'pg_dump: too many command-line arguments (first is "asd")');
31+
command_fails_like(
32+
['pg_dump','qqq','abc' ],
33+
qr/\Qpg_dump: too many command-line arguments (first is "abc")\E/,
34+
'pg_dump: too many command-line arguments (first is "asd")');
3335

34-
command_exit_is(['pg_restore','qqq','abc' ],
35-
1,'pg_restore too many command-line arguments (first is "asd")');
36+
command_fails_like(
37+
['pg_restore','qqq','abc' ],
38+
qr/\Qpg_restore: too many command-line arguments (first is "abc")\E/,
39+
'pg_restore too many command-line arguments (first is "abc")');
3640

37-
command_exit_is(['pg_dumpall','qqq','abc' ],
38-
1,'pg_dumpall: too many command-line arguments (first is "qqq")');
41+
command_fails_like(
42+
['pg_dumpall','qqq','abc' ],
43+
qr/\Qpg_dumpall: too many command-line arguments (first is "qqq")\E/,
44+
'pg_dumpall: too many command-line arguments (first is "qqq")');
3945

40-
command_exit_is(
46+
command_fails_like(
4147
['pg_dump','-s','-a' ],
42-
1,
48+
qr/\Qpg_dump: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
4349
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
4450
);
4551

46-
command_exit_is(
52+
command_fails_like(
4753
['pg_restore','-s','-a' ],
48-
1,
54+
qr/\Qpg_restore: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
4955
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
5056
);
5157

52-
command_exit_is(['pg_restore','-d','xxx','-f','xxx' ],
53-
1,
58+
command_fails_like(
59+
['pg_restore','-d','xxx','-f','xxx' ],
60+
qr/\Qpg_restore: options -d\/--dbname and -f\/--file cannot be used together\E/,
5461
'pg_restore: options -d/--dbname and -f/--file cannot be used together');
5562

56-
command_exit_is(
63+
command_fails_like(
5764
['pg_dump','-c','-a' ],
58-
1,
65+
qr/\Qpg_dump: options -c\/--clean and -a\/--data-only cannot be used together\E/,
5966
'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
6067

61-
command_exit_is(
68+
command_fails_like(
6269
['pg_restore','-c','-a' ],
63-
1,
70+
qr/\Qpg_restore: options -c\/--clean and -a\/--data-only cannot be used together\E/,
6471
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
6572

66-
command_exit_is(
73+
command_fails_like(
6774
['pg_dump','--inserts','-o' ],
68-
1,
75+
qr/\Qpg_dump: options --inserts\/--column-inserts and -o\/--oids cannot be used together\E/,
6976
'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together'
7077
);
7178

72-
command_exit_is(['pg_dump','--if-exists' ],
73-
1,'pg_dump: option --if-exists requires option -c/--clean');
74-
75-
command_exit_is(['pg_dump','-j' ],
76-
1,'pg_dump: option requires an argument --\'j\'');
77-
78-
command_exit_is(['pg_dump','-j3' ],
79-
1,'pg_dump: parallel backup only supported by the directory format');
80-
81-
command_exit_is(
79+
command_fails_like(
80+
['pg_dump','--if-exists' ],
81+
qr/\Qpg_dump: option --if-exists requires option -c\/--clean\E/,
82+
'pg_dump: option --if-exists requires option -c/--clean');
83+
84+
command_fails_like(
85+
['pg_dump','-j' ],
86+
qr/\Qpg_dump: option requires an argument -- 'j'\E/,
87+
'pg_dump: option requires an argument --\'j\'');
88+
89+
command_fails_like(
90+
['pg_dump','-j3' ],
91+
qr/\Qpg_dump: parallel backup only supported by the directory format\E/,
92+
'pg_dump: parallel backup only supported by the directory format');
93+
94+
command_fails_like(
95+
['pg_dump','-j','-1' ],
96+
qr/\Qpg_dump: invalid number of parallel jobs\E/,
97+
'pg_dump: invalid number of parallel jobs');
98+
99+
command_fails_like(
100+
['pg_dump','-F','garbage' ],
101+
qr/\Qpg_dump: invalid output format\E/,
102+
'pg_dump: invalid output format');
103+
104+
command_fails_like(
105+
['pg_restore','-j','-1' ],
106+
qr/\Qpg_restore: invalid number of parallel jobs\E/,
107+
'pg_restore: invalid number of parallel jobs');
108+
109+
command_fails_like(
82110
['pg_restore','--single-transaction','-j3' ],
83-
1,
111+
qr/\Qpg_restore: cannot specify both --single-transaction and multiple jobs\E/,
84112
'pg_restore: cannot specify both --single-transaction and multiple jobs');
85113

86-
command_exit_is(['pg_restore','--if-exists' ],
87-
1,'pg_restore: option --if-exists requires option -c/--clean');
114+
command_fails_like(
115+
['pg_dump','-Z','-1' ],
116+
qr/\Qpg_dump: compression level must be in range 0..9\E/,
117+
'pg_dump: compression level must be in range 0..9');
118+
119+
command_fails_like(
120+
['pg_restore','--if-exists' ],
121+
qr/\Qpg_restore: option --if-exists requires option -c\/--clean\E/,
122+
'pg_restore: option --if-exists requires option -c/--clean');
123+
124+
command_fails_like(
125+
['pg_restore','-F','garbage' ],
126+
qr/\Qpg_restore: unrecognized archive format "garbage";\E/,
127+
'pg_dump: unrecognized archive format');
88128

89129
# pg_dumpall command-line argument checks
90-
command_exit_is(
130+
command_fails_like(
91131
['pg_dumpall','-g','-r' ],
92-
1,
93-
'pg_restore: options -g/--globals-only and -r/--roles-only cannot be used together'
132+
qr/\Qpg_dumpall: options -g\/--globals-only and -r\/--roles-only cannot be used together\E/,
133+
'pg_dumpall: options -g/--globals-only and -r/--roles-only cannot be used together'
94134
);
95135

96-
command_exit_is(
136+
command_fails_like(
97137
['pg_dumpall','-g','-t' ],
98-
1,
99-
'pg_restore: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
138+
qr/\Qpg_dumpall: options -g\/--globals-only and -t\/--tablespaces-only cannot be used together\E/,
139+
'pg_dumpall: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
100140
);
101141

102-
command_exit_is(
142+
command_fails_like(
103143
['pg_dumpall','-r','-t' ],
104-
1,
105-
'pg_restore: options -r/--roles-only and -t/--tablespaces-only cannot be used together'
144+
qr/\Qpg_dumpall: options -r\/--roles-only and -t\/--tablespaces-only cannot be used together\E/,
145+
'pg_dumpall: options -r/--roles-only and -t/--tablespaces-only cannot be used together'
106146
);
107147

108-
command_exit_is(['pg_dumpall','--if-exists' ],
109-
1,'pg_dumpall: option --if-exists requires option -c/--clean');
148+
command_fails_like(
149+
['pg_dumpall','--if-exists' ],
150+
qr/\Qpg_dumpall: option --if-exists requires option -c\/--clean\E/,
151+
'pg_dumpall: option --if-exists requires option -c/--clean');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp