Thread: Tests for psql \g and \o
Hi, Here's a patch adding regression tests for \g and \o, and TAP tests for \g | program, It's a follow up to the discussion at [1]. Since this discussion already has a slot in the CF [2] with a committed patch, let's start a new separate thread. [1] https://www.postgresql.org/message-id/4333844c-2244-4d6e-a49a-1d483fbe304f@manitou-mail.org [2] https://commitfest.postgresql.org/40/3923/ Best regards, -- Daniel Vérité https://postgresql.verite.pro/ Twitter: @DanielVerite
Attachment
On Tue, Nov 01, 2022 at 12:42:47PM +0100, Daniel Verite wrote: > It's a follow up to the discussion at [1]. Since this discussion > already has a slot in the CF [2] with a committed patch, let's start a > new separate thread. +psql_like($node, "SELECT 'one' \\g | cat >$g_file", qr//, "one command \\g"); +my $c1 = slurp_file($g_file); +like($c1, qr/one/); Windows may not have an equivalent for "cat", no? Note that psql's 001_basic.pl has no restriction in place for Windows. Perhaps you could use the same trick as basebackup_to_shell, where GZIP is used to write some arbitrary data.. Anyway, this has some quoting issues especially if the file's path has whitespaces? This is located in File::Temp::tempdir, still it does not sound like a good thing to rely on this assumption on portability grounds. -- Michael
Attachment
Michael Paquier wrote: > +psql_like($node, "SELECT 'one' \\g | cat >$g_file", qr//, "one command > \\g"); > +my $c1 = slurp_file($g_file); > +like($c1, qr/one/); > > Windows may not have an equivalent for "cat", no? Note that psql's > 001_basic.pl has no restriction in place for Windows. Perhaps you > could use the same trick as basebackup_to_shell, where GZIP is used to > write some arbitrary data.. Anyway, this has some quoting issues > especially if the file's path has whitespaces? This is located in > File::Temp::tempdir, still it does not sound like a good thing to rely > on this assumption on portability grounds. PFA a new patch addressing these issues. Best regards, -- Daniel Vérité https://postgresql.verite.pro/ Twitter: @DanielVerite
Attachment
On Wed, Nov 23, 2022 at 09:18:57PM +0100, Daniel Verite wrote: > PFA a new patch addressing these issues. Thanks, the tests part of the main regression test suite look good to me, so I have applied them after fixing a few typos and tweaking the style of the test. Regarding the tests with pipes, I had cold feet with the dependencies on cat for non-WIN32 or findstr for WIN32. cat is used in the kerberos and ldap tests, though I am wondering whether we shouldn't take an approach similar to other tests where the command may not exist, and where we should check if there is something in the environment.. -- Michael
Attachment
Michael Paquier wrote: > Thanks, the tests part of the main regression test suite look good to > me, so I have applied them after fixing a few typos and tweaking the > style of the test. Thanks! > Regarding the tests with pipes, I had cold feet with the > dependencies on cat for non-WIN32 or findstr for WIN32. OK. If the issue is that these programs might be missing, I guess we could check that beforehand with IPC::Run and skip the corresponding psql tests if they're not available or not working as expected. Best regards, -- Daniel Vérité https://postgresql.verite.pro/ Twitter: @DanielVerite
On Wed, Nov 30, 2022 at 02:50:16PM +0900, Michael Paquier wrote: > On Wed, Nov 23, 2022 at 09:18:57PM +0100, Daniel Verite wrote: > > PFA a new patch addressing these issues. > > Thanks, the tests part of the main regression test suite look good to > me, so I have applied them after fixing a few typos and tweaking the > style of the test. Regarding the tests with pipes, I had cold feet > with the dependencies on cat for non-WIN32 or findstr for WIN32. I think you could do that with a perl 0-liner. $ echo foo |perl -pe '' foo -- Justin
On Wed, Nov 30, 2022 at 12:33:59PM -0600, Justin Pryzby wrote: > I think you could do that with a perl 0-liner. Right. And this could do something similar to 025_stuck_on_old_timeline.pl in terms of finding the binary for perl. -- Michael