Commit 6bd356c3 authored by Stephen Frost's avatar Stephen Frost

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.
parent e1b120a8
...@@ -42,6 +42,9 @@ install: all installdirs ...@@ -42,6 +42,9 @@ install: all installdirs
installdirs: installdirs:
$(MKDIR_P) '$(DESTDIR)$(bindir)' $(MKDIR_P) '$(DESTDIR)$(bindir)'
check:
$(prove_check)
uninstall: uninstall:
rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X)) rm -f $(addprefix '$(DESTDIR)$(bindir)'/, pg_dump$(X) pg_restore$(X) pg_dumpall$(X))
......
...@@ -1564,7 +1564,7 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt) ...@@ -1564,7 +1564,7 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
* those changes preserved. * those changes preserved.
*/ */
if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId) if (dopt->binary_upgrade && extinfo->dobj.catId.oid < (Oid) FirstNormalObjectId)
extinfo->dobj.dump = DUMP_COMPONENT_ACL; extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_ACL;
else else
extinfo->dobj.dump = extinfo->dobj.dump_contains = extinfo->dobj.dump = extinfo->dobj.dump_contains =
dopt->include_everything ? DUMP_COMPONENT_ALL : dopt->include_everything ? DUMP_COMPONENT_ALL :
......
use strict;
use warnings;
use Config;
use PostgresNode;
use TestLib;
use Test::More tests => 15;
my $tempdir = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;
#########################################
# Basic checks
program_help_ok('pg_dump');
program_version_ok('pg_dump');
program_options_handling_ok('pg_dump');
#########################################
# Test various invalid options and disallowed combinations
# Doesn't require a PG instance to be set up, so do this first.
command_exit_is([ 'pg_dump', 'qqq', 'abc' ],
1, 'pg_dump: too many command-line arguments (first is "asd")');
command_exit_is([ 'pg_dump', '-s', '-a' ],
1, 'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together');
command_exit_is([ 'pg_dump', '-c', '-a' ],
1, 'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
command_exit_is([ 'pg_dump', '--inserts', '-o' ],
1, 'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together');
command_exit_is([ 'pg_dump', '--if-exists' ],
1, 'pg_dump: option --if-exists requires option -c/--clean');
command_exit_is([ 'pg_dump', '-j' ],
1, 'pg_dump: option requires an argument -- \'j\'');
command_exit_is([ 'pg_dump', '-j3' ],
1, 'pg_dump: parallel backup only supported by the directory format');
This diff is collapsed.
...@@ -12,6 +12,7 @@ SUBDIRS = \ ...@@ -12,6 +12,7 @@ SUBDIRS = \
test_ddl_deparse \ test_ddl_deparse \
test_extensions \ test_extensions \
test_parser \ test_parser \
test_pg_dump \
test_rls_hooks \ test_rls_hooks \
test_shm_mq \ test_shm_mq \
worker_spi worker_spi
......
# Generated subdirectories
/log/
/results/
/tmp_check/
# src/test/modules/test_rls_hooks/Makefile
MODULE_big = test_pg_dump
PGFILEDESC = "test_pg_dump - Test pg_dump with an extension"
EXTENSION = test_pg_dump
DATA = test_pg_dump--1.0.sql
REGRESS = test_pg_dump
check: prove-check
prove-check:
$(prove_check)
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = src/test/modules/test_pg_dump
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif
test_pg_dump is an extension explicitly to test pg_dump when
extensions are present in the system.
SELECT 1;
?column?
----------
1
(1 row)
This diff is collapsed.
/* src/test/modules/test_pg_dump/test_pg_dump--1.0.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION test_pg_dump" to load this file. \quit
CREATE TABLE regress_pg_dump_table (
col1 int,
col2 int
);
GRANT SELECT ON regress_pg_dump_table TO dump_test;
GRANT SELECT(col1) ON regress_pg_dump_table TO public;
GRANT SELECT(col2) ON regress_pg_dump_table TO dump_test;
REVOKE SELECT(col2) ON regress_pg_dump_table FROM dump_test;
comment = 'Test pg_dump with an extension'
default_version = '1.0'
relocatable = true
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment