@@ -2186,15 +2186,9 @@ If this regular expression is set, matches it with the output generated.
2186
2186
2187
2187
=item log_like => [ qr/required message/ ]
2188
2188
2189
- If given, it must be an array reference containing a list of regular
2190
- expressions that must match against the server log, using
2191
- C<Test::More::like() > .
2192
-
2193
2189
=item log_unlike => [ qr/prohibited message/ ]
2194
2190
2195
- If given, it must be an array reference containing a list of regular
2196
- expressions that must NOT match against the server log. They will be
2197
- passed to C<Test::More::unlike() > .
2191
+ See C<log_check(...) > .
2198
2192
2199
2193
=back
2200
2194
@@ -2215,16 +2209,6 @@ sub connect_ok
2215
2209
$sql = " SELECT \$\$ connected with $connstr \$\$ " ;
2216
2210
}
2217
2211
2218
- my (@log_like , @log_unlike );
2219
- if (defined ($params {log_like }))
2220
- {
2221
- @log_like = @{ $params {log_like } };
2222
- }
2223
- if (defined ($params {log_unlike }))
2224
- {
2225
- @log_unlike = @{ $params {log_unlike } };
2226
- }
2227
-
2228
2212
my $log_location = -s $self -> logfile;
2229
2213
2230
2214
# Never prompt for a password, any callers of this routine should
@@ -2245,20 +2229,7 @@ sub connect_ok
2245
2229
2246
2230
is($stderr , " " , " $test_name : no stderr" );
2247
2231
2248
- if (@log_like or @log_unlike )
2249
- {
2250
- my $log_contents =
2251
- PostgreSQL::Test::Utils::slurp_file($self -> logfile, $log_location );
2252
-
2253
- while (my $regex = shift @log_like )
2254
- {
2255
- like($log_contents , $regex , " $test_name : log matches" );
2256
- }
2257
- while (my $regex = shift @log_unlike )
2258
- {
2259
- unlike($log_contents , $regex , " $test_name : log does not match" );
2260
- }
2261
- }
2232
+ $self -> log_check($test_name , $log_location , %params );
2262
2233
}
2263
2234
2264
2235
=pod
@@ -2278,7 +2249,7 @@ If this regular expression is set, matches it with the output generated.
2278
2249
2279
2250
=item log_unlike => [ qr/prohibited message/ ]
2280
2251
2281
- See C<connect_ok (...) > , above .
2252
+ See C<log_check (...) > .
2282
2253
2283
2254
=back
2284
2255
@@ -2289,16 +2260,6 @@ sub connect_fails
2289
2260
local $Test::Builder::Level = $Test::Builder::Level + 1;
2290
2261
my ($self , $connstr , $test_name , %params ) = @_ ;
2291
2262
2292
- my (@log_like , @log_unlike );
2293
- if (defined ($params {log_like }))
2294
- {
2295
- @log_like = @{ $params {log_like } };
2296
- }
2297
- if (defined ($params {log_unlike }))
2298
- {
2299
- @log_unlike = @{ $params {log_unlike } };
2300
- }
2301
-
2302
2263
my $log_location = -s $self -> logfile;
2303
2264
2304
2265
# Never prompt for a password, any callers of this routine should
@@ -2316,20 +2277,7 @@ sub connect_fails
2316
2277
like($stderr , $params {expected_stderr }, " $test_name : matches" );
2317
2278
}
2318
2279
2319
- if (@log_like or @log_unlike )
2320
- {
2321
- my $log_contents =
2322
- PostgreSQL::Test::Utils::slurp_file($self -> logfile, $log_location );
2323
-
2324
- while (my $regex = shift @log_like )
2325
- {
2326
- like($log_contents , $regex , " $test_name : log matches" );
2327
- }
2328
- while (my $regex = shift @log_unlike )
2329
- {
2330
- unlike($log_contents , $regex , " $test_name : log does not match" );
2331
- }
2332
- }
2280
+ $self -> log_check($test_name , $log_location , %params );
2333
2281
}
2334
2282
2335
2283
=pod
@@ -2535,6 +2483,67 @@ sub log_content
2535
2483
return PostgreSQL::Test::Utils::slurp_file($self -> logfile);
2536
2484
}
2537
2485
2486
+ =pod
2487
+
2488
+ =item $node->log_check($offset, $test_name, %parameters)
2489
+
2490
+ Check contents of server logs.
2491
+
2492
+ =over
2493
+
2494
+ =item $test_name
2495
+
2496
+ Name of test for error messages.
2497
+
2498
+ =item $offset
2499
+
2500
+ Offset of the log file.
2501
+
2502
+ =item log_like => [ qr/required message/ ]
2503
+
2504
+ If given, it must be an array reference containing a list of regular
2505
+ expressions that must match against the server log, using
2506
+ C<Test::More::like() > .
2507
+
2508
+ =item log_unlike => [ qr/prohibited message/ ]
2509
+
2510
+ If given, it must be an array reference containing a list of regular
2511
+ expressions that must NOT match against the server log. They will be
2512
+ passed to C<Test::More::unlike() > .
2513
+
2514
+ =back
2515
+
2516
+ =cut
2517
+
2518
+ sub log_check
2519
+ {
2520
+ my ($self , $test_name , $offset , %params ) = @_ ;
2521
+
2522
+ my (@log_like , @log_unlike );
2523
+ if (defined ($params {log_like }))
2524
+ {
2525
+ @log_like = @{ $params {log_like } };
2526
+ }
2527
+ if (defined ($params {log_unlike }))
2528
+ {
2529
+ @log_unlike = @{ $params {log_unlike } };
2530
+ }
2531
+
2532
+ if (@log_like or @log_unlike )
2533
+ {
2534
+ my $log_contents =
2535
+ PostgreSQL::Test::Utils::slurp_file($self -> logfile, $offset );
2536
+
2537
+ while (my $regex = shift @log_like )
2538
+ {
2539
+ like($log_contents , $regex , " $test_name : log matches" );
2540
+ }
2541
+ while (my $regex = shift @log_unlike )
2542
+ {
2543
+ unlike($log_contents , $regex , " $test_name : log does not match" );
2544
+ }
2545
+ }
2546
+ }
2538
2547
2539
2548
=pod
2540
2549
0 commit comments