public inbox for [email protected]
help / color / mirror / Atom feedFrom: Daniel Gustafsson <[email protected]>
To: PostgreSQL Developers <[email protected]>
To: Heikki Linnakangas <[email protected]>
Subject: Using Test::More test functions for pg_rewind
Date: Mon, 21 Feb 2022 15:10:20 +0100
Message-ID: <[email protected]> (raw)
check_query() in RewindTest.pm currently has this comment before handrolling
tests for return code and stderr:
# We don't use ok() for the exit code and stderr, because we want this
# check to be just a single test.
The code came with the initial import of pg_rewind, and there is no further
explanation but I guess it was to make test planning easier since each
check_query would count as 1 test. (inspecting old pre-import pg_rewind repos
on Github didn't given any other insights). Does anymore remember the
rationale for this?
Since we moved to done_testing() with 549ec201d we no longer need be concerned
with test counts, so we can replace this with normal is() tests, as per the
attached, making the output in the errorpath consistent with other tests.
Unless I'm missing something important here.
--
Daniel Gustafsson https://vmware.com/
Attachments:
[application/octet-stream] 0001-Use-test-functions-in-pg_rewind-test-module.patch (1.4K, ../[email protected]/2-0001-Use-test-functions-in-pg_rewind-test-module.patch)
download | inline diff:
From a10c2520372c672453e10115249ed9882e0345db Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <[email protected]>
Date: Mon, 21 Feb 2022 14:25:02 +0100
Subject: [PATCH] Use test functions in pg_rewind test module
Commit 61081e75c introduced pg_rewind along with the test suite, which
ensured that subroutines didn't incur more than one planned test. Now
that we no longer explicitly plan test runs (since 549ec201d) we can
use the usual Test::More functions.
---
src/bin/pg_rewind/t/RewindTest.pm | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/src/bin/pg_rewind/t/RewindTest.pm b/src/bin/pg_rewind/t/RewindTest.pm
index 2fedc626cc..5651602858 100644
--- a/src/bin/pg_rewind/t/RewindTest.pm
+++ b/src/bin/pg_rewind/t/RewindTest.pm
@@ -102,21 +102,10 @@ sub check_query
],
'>', \$stdout, '2>', \$stderr;
- # We don't use ok() for the exit code and stderr, because we want this
- # check to be just a single test.
- if (!$result)
- {
- fail("$test_name: psql exit code");
- }
- elsif ($stderr ne '')
- {
- diag $stderr;
- fail("$test_name: psql no stderr");
- }
- else
- {
- is($stdout, $expected_stdout, "$test_name: query result matches");
- }
+ is($result, 1, "$test_name: psql exit code");
+ is($stderr, '', "$test_name: psql no stderr");
+ is($stdout, $expected_stdout, "$test_name: query result matches");
+
return;
}
--
2.24.3 (Apple Git-128)
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Using Test::More test functions for pg_rewind
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox