Skip to content

Commit 6bd356c

Browse files
committed
Add TAP tests for pg_dump
This TAP test suite will create a new cluster, populate it based on the 'create_sql' values in the '%tests' hash, run all of the runs defined in the '%pgdump_runs' hash, and then for each test in the '%tests' hash, compare each run's output the the regular expression defined for the test under the 'like' and 'unlike' functions, as appropriate. While this test suite covers a fair bit of ground (67% of pg_dump.c and quite a bit of the other files in src/bin/pg_dump), there is still quite a bit which remains to be added to provide better code coverage. Still, this is quite a bit better than we had, and has found a few bugs already (note that the CREATE TRANSFORM test is commented out, as it is currently failing). Idea for using the TAP system from Tom, though all of the code is mine.
1 parent e1b120a commit 6bd356c

File tree

13 files changed

+3497
-1
lines changed

13 files changed

+3497
-1
lines changed

src/bin/pg_dump/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ install: all installdirs
4242
installdirs:
4343
$(MKDIR_P) '$(DESTDIR)$(bindir)'
4444

45+
check:
46+
$(prove_check)
47+
4548
uninstall:
4649
rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
4750

src/bin/pg_dump/pg_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
15641564
* those changes preserved.
15651565
*/
15661566
if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
1567-
extinfo->dobj.dump = DUMP_COMPONENT_ACL;
1567+
extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_ACL;
15681568
else
15691569
extinfo->dobj.dump = extinfo->dobj.dump_contains =
15701570
dopt->include_everything ? DUMP_COMPONENT_ALL :

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use strict;
2+
use warnings;
3+
4+
use Config;
5+
use PostgresNode;
6+
use TestLib;
7+
use Test::More tests => 15;
8+
9+
my $tempdir = TestLib::tempdir;
10+
my $tempdir_short = TestLib::tempdir_short;
11+
12+
#########################################
13+
# Basic checks
14+
15+
program_help_ok('pg_dump');
16+
program_version_ok('pg_dump');
17+
program_options_handling_ok('pg_dump');
18+
19+
#########################################
20+
# Test various invalid options and disallowed combinations
21+
# Doesn't require a PG instance to be set up, so do this first.
22+
23+
command_exit_is([ 'pg_dump', 'qqq', 'abc' ],
24+
1, 'pg_dump: too many command-line arguments (first is "asd")');
25+
26+
command_exit_is([ 'pg_dump', '-s', '-a' ],
27+
1, 'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together');
28+
29+
command_exit_is([ 'pg_dump', '-c', '-a' ],
30+
1, 'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
31+
32+
command_exit_is([ 'pg_dump', '--inserts', '-o' ],
33+
1, 'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together');
34+
35+
command_exit_is([ 'pg_dump', '--if-exists' ],
36+
1, 'pg_dump: option --if-exists requires option -c/--clean');
37+
38+
command_exit_is([ 'pg_dump', '-j' ],
39+
1, 'pg_dump: option requires an argument -- \'j\'');
40+
41+
command_exit_is([ 'pg_dump', '-j3' ],
42+
1, 'pg_dump: parallel backup only supported by the directory format');

0 commit comments

Comments
 (0)