@@ -2222,15 +2222,9 @@ If this regular expression is set, matches it with the output generated.
2222
2222
2223
2223
=item log_like => [ qr/required message/ ]
2224
2224
2225
- If given, it must be an array reference containing a list of regular
2226
- expressions that must match against the server log, using
2227
- C<Test::More::like() > .
2228
-
2229
2225
=item log_unlike => [ qr/prohibited message/ ]
2230
2226
2231
- If given, it must be an array reference containing a list of regular
2232
- expressions that must NOT match against the server log. They will be
2233
- passed toC<Test::More::unlike() > .
2227
+ SeeC<log_check(...) > .
2234
2228
2235
2229
=back
2236
2230
@@ -2251,16 +2245,6 @@ sub connect_ok
2251
2245
$sql =" SELECT\$\$ connected with$connstr \$\$ " ;
2252
2246
}
2253
2247
2254
- my (@log_like ,@log_unlike );
2255
- if (defined ($params {log_like }))
2256
- {
2257
- @log_like = @{$params {log_like } };
2258
- }
2259
- if (defined ($params {log_unlike }))
2260
- {
2261
- @log_unlike = @{$params {log_unlike } };
2262
- }
2263
-
2264
2248
my $log_location =-s $self -> logfile;
2265
2249
2266
2250
# Never prompt for a password, any callers of this routine should
@@ -2281,20 +2265,7 @@ sub connect_ok
2281
2265
2282
2266
is($stderr ," " ," $test_name : no stderr" );
2283
2267
2284
- if (@log_like or @log_unlike )
2285
- {
2286
- my $log_contents =
2287
- PostgreSQL::Test::Utils::slurp_file($self -> logfile,$log_location );
2288
-
2289
- while (my $regex =shift @log_like )
2290
- {
2291
- like($log_contents ,$regex ," $test_name : log matches" );
2292
- }
2293
- while (my $regex =shift @log_unlike )
2294
- {
2295
- unlike($log_contents ,$regex ," $test_name : log does not match" );
2296
- }
2297
- }
2268
+ $self -> log_check($test_name ,$log_location ,%params );
2298
2269
}
2299
2270
2300
2271
=pod
@@ -2314,7 +2285,7 @@ If this regular expression is set, matches it with the output generated.
2314
2285
2315
2286
=item log_unlike => [ qr/prohibited message/ ]
2316
2287
2317
- SeeC<connect_ok (...) > , above .
2288
+ SeeC<log_check (...) > .
2318
2289
2319
2290
=back
2320
2291
@@ -2325,16 +2296,6 @@ sub connect_fails
2325
2296
local $Test::Builder::Level =$Test::Builder::Level + 1;
2326
2297
my ($self ,$connstr ,$test_name ,%params ) =@_ ;
2327
2298
2328
- my (@log_like ,@log_unlike );
2329
- if (defined ($params {log_like }))
2330
- {
2331
- @log_like = @{$params {log_like } };
2332
- }
2333
- if (defined ($params {log_unlike }))
2334
- {
2335
- @log_unlike = @{$params {log_unlike } };
2336
- }
2337
-
2338
2299
my $log_location =-s $self -> logfile;
2339
2300
2340
2301
# Never prompt for a password, any callers of this routine should
@@ -2352,20 +2313,7 @@ sub connect_fails
2352
2313
like($stderr ,$params {expected_stderr }," $test_name : matches" );
2353
2314
}
2354
2315
2355
- if (@log_like or @log_unlike )
2356
- {
2357
- my $log_contents =
2358
- PostgreSQL::Test::Utils::slurp_file($self -> logfile,$log_location );
2359
-
2360
- while (my $regex =shift @log_like )
2361
- {
2362
- like($log_contents ,$regex ," $test_name : log matches" );
2363
- }
2364
- while (my $regex =shift @log_unlike )
2365
- {
2366
- unlike($log_contents ,$regex ," $test_name : log does not match" );
2367
- }
2368
- }
2316
+ $self -> log_check($test_name ,$log_location ,%params );
2369
2317
}
2370
2318
2371
2319
=pod
@@ -2559,6 +2507,68 @@ sub issues_sql_like
2559
2507
2560
2508
=pod
2561
2509
2510
+ =item $node->log_check($offset, $test_name, %parameters)
2511
+
2512
+ Check contents of server logs.
2513
+
2514
+ =over
2515
+
2516
+ =item $test_name
2517
+
2518
+ Name of test for error messages.
2519
+
2520
+ =item $offset
2521
+
2522
+ Offset of the log file.
2523
+
2524
+ =item log_like => [ qr/required message/ ]
2525
+
2526
+ If given, it must be an array reference containing a list of regular
2527
+ expressions that must match against the server log, using
2528
+ C<Test::More::like() > .
2529
+
2530
+ =item log_unlike => [ qr/prohibited message/ ]
2531
+
2532
+ If given, it must be an array reference containing a list of regular
2533
+ expressions that must NOT match against the server log. They will be
2534
+ passed toC<Test::More::unlike() > .
2535
+
2536
+ =back
2537
+
2538
+ =cut
2539
+
2540
+ sub log_check
2541
+ {
2542
+ my ($self ,$test_name ,$offset ,%params ) =@_ ;
2543
+
2544
+ my (@log_like ,@log_unlike );
2545
+ if (defined ($params {log_like }))
2546
+ {
2547
+ @log_like = @{$params {log_like } };
2548
+ }
2549
+ if (defined ($params {log_unlike }))
2550
+ {
2551
+ @log_unlike = @{$params {log_unlike } };
2552
+ }
2553
+
2554
+ if (@log_like or @log_unlike )
2555
+ {
2556
+ my $log_contents =
2557
+ PostgreSQL::Test::Utils::slurp_file($self -> logfile,$offset );
2558
+
2559
+ while (my $regex =shift @log_like )
2560
+ {
2561
+ like($log_contents ,$regex ," $test_name : log matches" );
2562
+ }
2563
+ while (my $regex =shift @log_unlike )
2564
+ {
2565
+ unlike($log_contents ,$regex ," $test_name : log does not match" );
2566
+ }
2567
+ }
2568
+ }
2569
+
2570
+ =pod
2571
+
2562
2572
=item $node->run_log(...)
2563
2573
2564
2574
Runs a shell command like PostgreSQL::Test::Utils::run_log, but with connection parameters set