1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-21 05:21:08 +03:00

Add more $Test::Builder::Level in the TAP tests

Incrementing the level of the call stack reported is useful for
debugging purposes as it allows to control which part of the test is
exactly failing, especially if a test is structured with subroutines
that call routines from Test::More.

This adds more incrementations of $Test::Builder::Level where debugging
gets improved (for example it does not make sense for some paths like
pg_rewind where long subroutines are used).

A note is added to src/test/perl/README about that, based on a
suggestion from Andrew Dunstan and a wording coming from both of us.

Usage of Test::Builder::Level has spread in 12, so a backpatch down to
this version is done.

Reviewed-by: Andrew Dunstan, Peter Eisentraut, Daniel Gustafsson
Discussion: https://postgr.es/m/YV1CCFwgM1RV1LeS@paquier.xyz
Backpatch-through: 12
This commit is contained in:
Michael Paquier
2021-10-12 11:15:44 +09:00
parent e3e29cec10
commit f9c4cb6868
13 changed files with 45 additions and 1 deletions

View File

@@ -61,9 +61,17 @@ Test::More::like entails use of the qr// operator. Avoid Perl 5.8.8 bug
#39185 by not using the "$" regular expression metacharacter in qr// when also
using the "/m" modifier. Instead of "$", use "\n" or "(?=\n|\z)".
Read the Test::More documentation for more on how to write tests:
Test::Builder::Level controls how far up in the call stack a test will look
at when reporting a failure. This should be incremented by any subroutine
which directly or indirectly calls test routines from Test::More, such as
ok() or is():
local $Test::Builder::Level = $Test::Builder::Level + 1;
Read the documentation for more on how to write tests:
perldoc Test::More
perldoc Test::Builder
For available PostgreSQL-specific test methods and some example tests read the
perldoc for the test modules, e.g.: