Hi all,
I've noticed that many TAP tests in the codebase make sub-optimal use of the "ok()" function. Specifically, ok() is often used for expressions involving comparison operators or regex matches, which is not ideal because other Test::More functions provide much clearer diagnostic messages when tests fail.
For example, instead of writing:
ok($var =~ /foo/, "found foo")
it’s better to write:
like($var, /foo/, "found foo")
I experimented by modifying a TAP test in
src/bin/pg_dump to deliberately fail using
ok(). The failure output was quite minimal and didn’t give much detail:
Then I changed the same test to use like() instead of ok(), which produced much more informative diagnostics:
Based on this, I’ve replaced all such uses of ok() with the more appropriate is(), isnt(), like(), unlike(), and cmp_ok() functions, depending on the test case.
Please find the attached patch implementing these improvements...
Thanks for considering the change.
EnterpriseDB.