Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd834ebc

Browse files
committed
Add more $Test::Builder::Level in the TAP tests
Incrementing the level of the call stack reported is useful fordebugging purposes as it allows to control which part of the test isexactly failing, especially if a test is structured with subroutinesthat call routines from Test::More.This adds more incrementations of $Test::Builder::Level where debugginggets improved (for example it does not make sense for some paths likepg_rewind where long subroutines are used).A note is added to src/test/perl/README about that, based on asuggestion from Andrew Dunstan and a wording coming from both of us.Usage of Test::Builder::Level has spread in 12, so a backpatch down tothis version is done.Reviewed-by: Andrew Dunstan, Peter Eisentraut, Daniel GustafssonDiscussion:https://postgr.es/m/YV1CCFwgM1RV1LeS@paquier.xyzBackpatch-through: 12
1 parent62e821a commitd834ebc

File tree

12 files changed

+43
-1
lines changed

12 files changed

+43
-1
lines changed

‎contrib/amcheck/t/001_verify_heapam.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ sub corrupt_first_page
143143

144144
subdetects_heap_corruption
145145
{
146+
local$Test::Builder::Level =$Test::Builder::Level + 1;
147+
146148
my ($function,$testname) =@_;
147149

148150
detects_corruption(
@@ -158,6 +160,8 @@ sub detects_heap_corruption
158160

159161
subdetects_corruption
160162
{
163+
local$Test::Builder::Level =$Test::Builder::Level + 1;
164+
161165
my ($function,$testname,@re) =@_;
162166

163167
my$result =$node->safe_psql('postgres',qq(SELECT * FROM$function));
@@ -166,6 +170,8 @@ sub detects_corruption
166170

167171
subdetects_no_corruption
168172
{
173+
local$Test::Builder::Level =$Test::Builder::Level + 1;
174+
169175
my ($function,$testname) =@_;
170176

171177
my$result =$node->safe_psql('postgres',qq(SELECT * FROM$function));
@@ -181,6 +187,8 @@ sub detects_no_corruption
181187
# and should be unique.
182188
subcheck_all_options_uncorrupted
183189
{
190+
local$Test::Builder::Level =$Test::Builder::Level + 1;
191+
184192
my ($relname,$prefix) =@_;
185193

186194
formy$stop (qw(true false))

‎contrib/test_decoding/t/001_repl_stats.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# Check that replication slot stats are expected.
2020
subtest_slot_stats
2121
{
22+
local$Test::Builder::Level =$Test::Builder::Level + 1;
23+
2224
my ($node,$expected,$msg) =@_;
2325

2426
my$result =$node->safe_psql(

‎src/bin/pg_archivecleanup/t/010_pg_archivecleanup.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ sub create_files
7272

7373
subrun_check
7474
{
75+
local$Test::Builder::Level =$Test::Builder::Level + 1;
76+
7577
my ($suffix,$test_name) =@_;
7678

7779
create_files();

‎src/bin/pg_verifybackup/t/005_bad_manifest.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176

177177
subtest_parse_error
178178
{
179+
local$Test::Builder::Level =$Test::Builder::Level + 1;
180+
179181
my ($test_name,$manifest_contents) =@_;
180182

181183
test_bad_manifest($test_name,
@@ -186,6 +188,8 @@ sub test_parse_error
186188

187189
subtest_fatal_error
188190
{
191+
local$Test::Builder::Level =$Test::Builder::Level + 1;
192+
189193
my ($test_name,$manifest_contents) =@_;
190194

191195
test_bad_manifest($test_name,qr/fatal:$test_name/,$manifest_contents);
@@ -194,6 +198,8 @@ sub test_fatal_error
194198

195199
subtest_bad_manifest
196200
{
201+
local$Test::Builder::Level =$Test::Builder::Level + 1;
202+
197203
my ($test_name,$regexp,$manifest_contents) =@_;
198204

199205
open(my$fh,'>',"$tempdir/backup_manifest") ||die"open:$!";

‎src/bin/psql/t/010_tab_completion.pl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ sub check_completion
127127
# (won't work if we are inside a string literal!)
128128
subclear_query
129129
{
130+
local$Test::Builder::Level =$Test::Builder::Level + 1;
131+
130132
check_completion("\\r\n",qr/postgres=#/,"\\r works");
131133
return;
132134
}
@@ -136,6 +138,8 @@ sub clear_query
136138
# than clear_query because we lose evidence in the history file)
137139
subclear_line
138140
{
141+
local$Test::Builder::Level =$Test::Builder::Level + 1;
142+
139143
check_completion("\025\n",qr/postgres=#/,"control-U works");
140144
return;
141145
}

‎src/test/kerberos/t/001_auth.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ sub test_access
221221
# As above, but test for an arbitrary query result.
222222
subtest_query
223223
{
224+
local$Test::Builder::Level =$Test::Builder::Level + 1;
225+
224226
my ($node,$role,$query,$expected,$gssencmode,$test_name) =@_;
225227

226228
# need to connect over TCP/IP for Kerberos

‎src/test/perl/README

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@ Test::More::like entails use of the qr// operator. Avoid Perl 5.8.8 bug
6161
#39185 by not using the "$" regular expression metacharacter in qr// when also
6262
using the "/m" modifier. Instead of "$", use "\n" or "(?=\n|\z)".
6363

64-
Read the Test::More documentation for more on how to write tests:
64+
Test::Builder::Level controls how far up in the call stack a test will look
65+
at when reporting a failure. This should be incremented by any subroutine
66+
which directly or indirectly calls test routines from Test::More, such as
67+
ok() or is():
68+
69+
local $Test::Builder::Level = $Test::Builder::Level + 1;
70+
71+
Read the documentation for more on how to write tests:
6572

6673
perldoc Test::More
74+
perldoc Test::Builder
6775

6876
For available PostgreSQL-specific test methods and some example tests read the
6977
perldoc for the test modules, e.g.:

‎src/test/recovery/t/001_stream_rep.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
# Expect to connect to $target_node (undef for failure) with given $status.
7676
subtest_target_session_attrs
7777
{
78+
local$Test::Builder::Level =$Test::Builder::Level + 1;
79+
7880
my$node1 =shift;
7981
my$node2 =shift;
8082
my$target_node =shift;

‎src/test/recovery/t/003_recovery_targets.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# count to reach $num_rows, yet not later than the recovery target.
1515
subtest_recovery_standby
1616
{
17+
local$Test::Builder::Level =$Test::Builder::Level + 1;
18+
1719
my$test_name =shift;
1820
my$node_name =shift;
1921
my$node_primary =shift;

‎src/test/recovery/t/007_sync_rep.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
# the configuration file is reloaded before the test.
1818
subtest_sync_state
1919
{
20+
local$Test::Builder::Level =$Test::Builder::Level + 1;
21+
2022
my ($self,$expected,$msg,$setting) =@_;
2123

2224
if (defined($setting))

‎src/test/recovery/t/009_twophase.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
subconfigure_and_reload
1616
{
17+
local$Test::Builder::Level =$Test::Builder::Level + 1;
18+
1719
my ($node,$parameter) =@_;
1820
my$name =$node->name;
1921

‎src/test/recovery/t/018_wal_optimize.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
subcheck_orphan_relfilenodes
2020
{
21+
local$Test::Builder::Level =$Test::Builder::Level + 1;
22+
2123
my ($node,$test_name) =@_;
2224

2325
my$db_oid =$node->safe_psql('postgres',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp