]> granicus.if.org Git - postgresql/commit
Refactor Perl test code
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 2 Dec 2015 21:46:16 +0000 (18:46 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 2 Dec 2015 21:46:16 +0000 (18:46 -0300)
commit1caef31d9e550408d0cbc5788a422dcb69736df5
tree451c4745e315c8dba59415a83eb2c4963fded212
parentc7485a82c3e29103757db75bb9ff8dac597387dc
Refactor Perl test code

The original code was a bit clunky; make it more amenable for further
reuse by creating a new Perl package PostgresNode, which is an
object-oriented representation of a single server, with some support
routines such as init, start, stop, psql.  This serves as a better basis
on which to build further test code, and enables writing tests that use
more than one server without too much complication.

This commit modifies a lot of the existing test files, mostly to remove
explicit calls to system commands (pg_ctl) replacing them with method
calls of a PostgresNode object.  The result is quite a bit more
straightforward.

Also move some initialization code to BEGIN and INIT blocks instead of
having it straight in as top-level code.

This commit also introduces package RecursiveCopy so that we can copy
whole directories without having to depend on packages that may not be
present on vanilla Perl 5.8 installations.

I also ran perltidy on the modified files, which changes some code sites
that are not otherwise touched by this patch.  I tried to avoid this,
but it ended up being more trouble than it's worth.

Authors: Michael Paquier, Álvaro Herrera
Review: Noah Misch
27 files changed:
src/bin/initdb/t/001_initdb.pl
src/bin/pg_basebackup/t/010_pg_basebackup.pl
src/bin/pg_controldata/t/001_pg_controldata.pl
src/bin/pg_ctl/t/001_start_stop.pl
src/bin/pg_ctl/t/002_status.pl
src/bin/pg_rewind/RewindTest.pm
src/bin/pg_rewind/t/003_extrafiles.pl
src/bin/pg_rewind/t/004_pg_xlog_symlink.pl
src/bin/scripts/t/010_clusterdb.pl
src/bin/scripts/t/011_clusterdb_all.pl
src/bin/scripts/t/020_createdb.pl
src/bin/scripts/t/030_createlang.pl
src/bin/scripts/t/040_createuser.pl
src/bin/scripts/t/050_dropdb.pl
src/bin/scripts/t/060_droplang.pl
src/bin/scripts/t/070_dropuser.pl
src/bin/scripts/t/080_pg_isready.pl
src/bin/scripts/t/090_reindexdb.pl
src/bin/scripts/t/091_reindexdb_all.pl
src/bin/scripts/t/100_vacuumdb.pl
src/bin/scripts/t/101_vacuumdb_all.pl
src/bin/scripts/t/102_vacuumdb_stages.pl
src/test/perl/PostgresNode.pm [new file with mode: 0644]
src/test/perl/RecursiveCopy.pm [new file with mode: 0644]
src/test/perl/TestLib.pm
src/test/ssl/ServerSetup.pm
src/test/ssl/t/001_ssltests.pl