@@ -2148,15 +2148,9 @@ If this regular expression is set, matches it with the output generated.
2148
2148
2149
2149
=item log_like => [ qr/required message/ ]
2150
2150
2151
- If given, it must be an array reference containing a list of regular
2152
- expressions that must match against the server log, using
2153
- C<Test::More::like() > .
2154
-
2155
2151
=item log_unlike => [ qr/prohibited message/ ]
2156
2152
2157
- If given, it must be an array reference containing a list of regular
2158
- expressions that must NOT match against the server log. They will be
2159
- passed to C<Test::More::unlike() > .
2153
+ See C<log_check(...) > .
2160
2154
2161
2155
=back
2162
2156
@@ -2177,16 +2171,6 @@ sub connect_ok
2177
2171
$sql = " SELECT \$\$ connected with $connstr \$\$ " ;
2178
2172
}
2179
2173
2180
- my (@log_like , @log_unlike );
2181
- if (defined ($params {log_like }))
2182
- {
2183
- @log_like = @{ $params {log_like } };
2184
- }
2185
- if (defined ($params {log_unlike }))
2186
- {
2187
- @log_unlike = @{ $params {log_unlike } };
2188
- }
2189
-
2190
2174
my $log_location = -s $self -> logfile;
2191
2175
2192
2176
# Never prompt for a password, any callers of this routine should
@@ -2204,19 +2188,7 @@ sub connect_ok
2204
2188
{
2205
2189
like($stdout , $params {expected_stdout }, " $test_name : matches" );
2206
2190
}
2207
- if (@log_like or @log_unlike )
2208
- {
2209
- my $log_contents = TestLib::slurp_file($self -> logfile, $log_location );
2210
-
2211
- while (my $regex = shift @log_like )
2212
- {
2213
- like($log_contents , $regex , " $test_name : log matches" );
2214
- }
2215
- while (my $regex = shift @log_unlike )
2216
- {
2217
- unlike($log_contents , $regex , " $test_name : log does not match" );
2218
- }
2219
- }
2191
+ $self -> log_check($test_name , $log_location , %params );
2220
2192
}
2221
2193
2222
2194
=pod
@@ -2236,7 +2208,7 @@ If this regular expression is set, matches it with the output generated.
2236
2208
2237
2209
=item log_unlike => [ qr/prohibited message/ ]
2238
2210
2239
- See C<connect_ok (...) > , above .
2211
+ See C<log_check (...) > .
2240
2212
2241
2213
=back
2242
2214
@@ -2247,16 +2219,6 @@ sub connect_fails
2247
2219
local $Test::Builder::Level = $Test::Builder::Level + 1;
2248
2220
my ($self , $connstr , $test_name , %params ) = @_ ;
2249
2221
2250
- my (@log_like , @log_unlike );
2251
- if (defined ($params {log_like }))
2252
- {
2253
- @log_like = @{ $params {log_like } };
2254
- }
2255
- if (defined ($params {log_unlike }))
2256
- {
2257
- @log_unlike = @{ $params {log_unlike } };
2258
- }
2259
-
2260
2222
my $log_location = -s $self -> logfile;
2261
2223
2262
2224
# Never prompt for a password, any callers of this routine should
@@ -2274,19 +2236,7 @@ sub connect_fails
2274
2236
like($stderr , $params {expected_stderr }, " $test_name : matches" );
2275
2237
}
2276
2238
2277
- if (@log_like or @log_unlike )
2278
- {
2279
- my $log_contents = TestLib::slurp_file($self -> logfile, $log_location );
2280
-
2281
- while (my $regex = shift @log_like )
2282
- {
2283
- like($log_contents , $regex , " $test_name : log matches" );
2284
- }
2285
- while (my $regex = shift @log_unlike )
2286
- {
2287
- unlike($log_contents , $regex , " $test_name : log does not match" );
2288
- }
2289
- }
2239
+ $self -> log_check($test_name , $log_location , %params );
2290
2240
}
2291
2241
2292
2242
=pod
@@ -2459,6 +2409,67 @@ sub issues_sql_like
2459
2409
2460
2410
=pod
2461
2411
2412
+ =item $node->log_check($offset, $test_name, %parameters)
2413
+
2414
+ Check contents of server logs.
2415
+
2416
+ =over
2417
+
2418
+ =item $test_name
2419
+
2420
+ Name of test for error messages.
2421
+
2422
+ =item $offset
2423
+
2424
+ Offset of the log file.
2425
+
2426
+ =item log_like => [ qr/required message/ ]
2427
+
2428
+ If given, it must be an array reference containing a list of regular
2429
+ expressions that must match against the server log, using
2430
+ C<Test::More::like() > .
2431
+
2432
+ =item log_unlike => [ qr/prohibited message/ ]
2433
+
2434
+ If given, it must be an array reference containing a list of regular
2435
+ expressions that must NOT match against the server log. They will be
2436
+ passed to C<Test::More::unlike() > .
2437
+
2438
+ =back
2439
+
2440
+ =cut
2441
+
2442
+ sub log_check
2443
+ {
2444
+ my ($self , $test_name , $offset , %params ) = @_ ;
2445
+
2446
+ my (@log_like , @log_unlike );
2447
+ if (defined ($params {log_like }))
2448
+ {
2449
+ @log_like = @{ $params {log_like } };
2450
+ }
2451
+ if (defined ($params {log_unlike }))
2452
+ {
2453
+ @log_unlike = @{ $params {log_unlike } };
2454
+ }
2455
+
2456
+ if (@log_like or @log_unlike )
2457
+ {
2458
+ my $log_contents = TestLib::slurp_file($self -> logfile, $offset );
2459
+
2460
+ while (my $regex = shift @log_like )
2461
+ {
2462
+ like($log_contents , $regex , " $test_name : log matches" );
2463
+ }
2464
+ while (my $regex = shift @log_unlike )
2465
+ {
2466
+ unlike($log_contents , $regex , " $test_name : log does not match" );
2467
+ }
2468
+ }
2469
+ }
2470
+
2471
+ =pod
2472
+
2462
2473
=item $node->run_log(...)
2463
2474
2464
2475
Runs a shell command like TestLib::run_log, but with connection parameters set
0 commit comments