| From: | Sadhuprasad Patro <b(dot)sadhu(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions |
| Date: | 2025-11-04 06:50:03 |
| Message-ID: | CAFF0-CGiu-+QN7+TS-2AxOZTEeN_1=b5i7pdtndRbqc1KVuPzw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Oct 31, 2025 at 6:19 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> On Thu, Oct 30, 2025 at 05:00:27PM +0530, Sadhuprasad Patro wrote:
> > On Fri, Oct 17, 2025 at 11:11 AM Michael Paquier <michael(at)paquier(dot)xyz>
> > wrote:
> >> -ok($node->log_contains(qr/no SSL error reported/) == 0,
> >> +is($node->log_contains(qr/no SSL error reported/), 0
> >>
> >> The CI was failing with the change in the SSL tests, as of:
> >> [05:03:12.647] # at
> >> /tmp/cirrus-ci-build/src/test/ssl/t/001_ssltests.pl line 127.
> >> [05:03:12.647] # got: ''
> >> [05:03:12.647] # expected: '0'
>
> Sadhuprasad, there was still a bit more we could do. Related to this
> issue with the SSL test, what do you think about the introduction of a
> log_contains_like() in Cluster.pm where we would directly call like()
> in the subroutine? This way, we would be able to report in the output
> the contents of the server logs we are trying to match (or not match)
> with a pattern, making debugging easier. What do you think?
> --
> Michael
>
Hi Michael,
I think we can do this as you suggested...
I can define something like below in perl script and try to use:
*sub log_contains_like { my ($self, $pattern, $msg, $do_test) = @_;
my $log = $self->get_log(); $msg //= "Log output matches pattern"; #
Run as test by default if (!defined $do_test || $do_test) { my
$ok = like($log, $pattern, $msg); # If the test failed, show a
concise log snippet unless ($ok) { my @lines = split
/\n/, $log; my $snippet;*
* $snippet = $log; diag("Log snippet
(last " . scalar(@lines > 20 ? 20 : @lines) . " lines):");*
* diag($snippet); } } else { # Return
boolean for manual usage return ($log =~ /$pattern/); }}*
Is this looks fine to you?
Will share a new patch soon with this content...
Thank you
SadhuPrasad,
EnterpriseDB.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2025-11-04 07:03:53 | Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions |
| Previous Message | Tristan Partin | 2025-11-04 06:25:05 | Re: meson's in-tree libpq header search order vs -Dextra_include_dirs |