Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions
Date
Msg-id aPHW8zMIcp59Jpuz@paquier.xyz
Whole thread Raw
In response to Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
On Thu, Oct 16, 2025 at 04:26:48PM +0900, Michael Paquier wrote:
> -ok($node_s->safe_psql($db1, "SELECT COUNT(*) = 2 FROM pg_publication"),
> -    'two pre-existing publications on subscriber');
> +is($node_s->safe_psql($db1, "SELECT COUNT(*) = 2 FROM pg_publication"),
> +   't',
> +   'two pre-existing publications on subscriber');

Note here: we can just compare the result with '2'.

> -ok($node_replica->safe_psql('postgres', $canary_query) == 0,
> -    'canary is missing');
> +is($node_replica->safe_psql('postgres', $canary_query), 0,
> +   'canary is missing');
> [...]
> -ok($node_replica->safe_psql('postgres', $canary_query) == 1,
> +is($node_replica->safe_psql('postgres', $canary_query), 1,
>      'canary is present');

Fixed and backpatched these two at the end as they could mask bugs, on
the branches where they matter.

Not sure that the bits in 010_pg_basebackup were an improvement.  In
004_test_parser_perf, the result is indeed empty, but it's a matter of
the result returned by IPC::run::run.

-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'

There was already a lot of content already.  So I have left this one
out for the moment and applied a good chunk of the rest with some
indentation.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Steven Niu
Date:
Subject: Re: Question for coverage report
Next
From: Chanukya SDS
Date:
Subject: pg_running_stats - mergeable running statistics (Welford/Chan) extension for postgresql