31.4. TAP Tests#
Various tests, particularly the client program tests undersrc/bin
, use the Perl TAP tools and are run using the Perl testing programprove
. You can pass command-line options toprove
by setting themake
variablePROVE_FLAGS
, for example:
make -C src/bin check PROVE_FLAGS='--timer'
See the manual page ofprove
for more information.
Themake
variablePROVE_TESTS
can be used to define a whitespace-separated list of paths relative to theMakefile
invokingprove
to run the specified subset of tests instead of the defaultt/*.pl
. For example:
make check PROVE_TESTS='t/001_test1.pl t/003_test3.pl'
The TAP tests require the Perl moduleIPC::Run
. This module is available fromCPAN or an operating system package. They also requirePostgreSQL to be configured with the option--enable-tap-tests
.
Generically speaking, the TAP tests will test the executables in a previously-installed installation tree if you saymake installcheck
, or will build a new local installation tree from current sources if you saymake check
. In either case they will initialize a local instance (data directory) and transiently run a server in it. Some of these tests run more than one server. Thus, these tests can be fairly resource-intensive.
It's important to realize that the TAP tests will start test server(s) even when you saymake installcheck
; this is unlike the traditional non-TAP testing infrastructure, which expects to use an already-running test server in that case. Some PostgreSQL subdirectories contain both traditional-style and TAP-style tests, meaning thatmake installcheck
will produce a mix of results from temporary servers and the already-running test server.
31.4.1. Environment Variables#
Data directories are named according to the test filename, and will be retained if a test fails. If the environment variablePG_TEST_NOCLEAN
is set, data directories will be retained regardless of test status. For example, retaining the data directory regardless of test results when running thepg_dump tests:
PG_TEST_NOCLEAN=1 make -C src/bin/pg_dump check
This environment variable also prevents the test's temporary directories from being removed.
Many operations in the test suites use a 180-second timeout, which on slow hosts may lead to load-induced timeouts. Setting the environment variablePG_TEST_TIMEOUT_DEFAULT
to a higher number will change the default to avoid this.