Lists: | pgsql-hackers |
---|
From: | Ildar Musin <i(dot)musin(at)postgrespro(dot)ru> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Confusing TAP tests readme file |
Date: | 2016-07-25 10:42:33 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi all,
I was checking out TAP tests documentation. And I found confusing this
part of src/test/perl/README file:
my $ret = $node->psql('postgres', 'SELECT 1');
is($ret, '1', 'SELECT 1 returns 1');
The returning value of psql() function is the exit code of the psql.
Hence this test will never pass since psql returns 0 if query was
successfully executed. Probably it was meant to be the safe_psql()
function instead which returns stdout:
my $ret = $node->safe_psql('postgres', 'SELECT 1');
is($ret, '1', 'SELECT 1 returns 1');
or else:
my ($ret, $stdout, $stderr) =
$node->psql('postgres', 'SELECT 1');
is($stdout, '1', 'SELECT 1 returns 1');
The attached patch fixes this.
Regards,
Ildar Musin
--
Ildar Musin
i(dot)musin(at)postgrespro(dot)ru
Attachment | Content-Type | Size |
---|---|---|
tap_doc.patch | text/x-patch | 429 bytes |
From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Ildar Musin <i(dot)musin(at)postgrespro(dot)ru> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Confusing TAP tests readme file |
Date: | 2016-07-25 12:53:39 |
Message-ID: | CAB7nPqQsxKvk0O3shANFEza+y3Po2AeyaXCi39eEMheVRQq-PA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Jul 25, 2016 at 7:42 PM, Ildar Musin <i(dot)musin(at)postgrespro(dot)ru> wrote:
> I was checking out TAP tests documentation. And I found confusing this part
> of src/test/perl/README file:
>
> my $ret = $node->psql('postgres', 'SELECT 1');
> is($ret, '1', 'SELECT 1 returns 1');
Good catch.
> The returning value of psql() function is the exit code of the psql. Hence
> this test will never pass since psql returns 0 if query was successfully
> executed. Probably it was meant to be the safe_psql() function instead which
> returns stdout:
>
> my $ret = $node->safe_psql('postgres', 'SELECT 1');
> is($ret, '1', 'SELECT 1 returns 1');
>
> or else:
>
> my ($ret, $stdout, $stderr) =
> $node->psql('postgres', 'SELECT 1');
> is($stdout, '1', 'SELECT 1 returns 1');
>
> The attached patch fixes this.
Just using psql_safe looks fine to me.
--
Michael
From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | Ildar Musin <i(dot)musin(at)postgrespro(dot)ru>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Confusing TAP tests readme file |
Date: | 2016-07-26 12:18:30 |
Message-ID: | CAHGQGwEAZfshdxrpX-cSnRL3bXcHpj+paG7gJz9TLGc2as5XSA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Mon, Jul 25, 2016 at 9:53 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> On Mon, Jul 25, 2016 at 7:42 PM, Ildar Musin <i(dot)musin(at)postgrespro(dot)ru> wrote:
>> I was checking out TAP tests documentation. And I found confusing this part
>> of src/test/perl/README file:
>>
>> my $ret = $node->psql('postgres', 'SELECT 1');
>> is($ret, '1', 'SELECT 1 returns 1');
>
> Good catch.
>
>> The returning value of psql() function is the exit code of the psql. Hence
>> this test will never pass since psql returns 0 if query was successfully
>> executed. Probably it was meant to be the safe_psql() function instead which
>> returns stdout:
>>
>> my $ret = $node->safe_psql('postgres', 'SELECT 1');
>> is($ret, '1', 'SELECT 1 returns 1');
>>
>> or else:
>>
>> my ($ret, $stdout, $stderr) =
>> $node->psql('postgres', 'SELECT 1');
>> is($stdout, '1', 'SELECT 1 returns 1');
>>
>> The attached patch fixes this.
>
> Just using psql_safe looks fine to me.
Pushed. Thanks!
Regards,
--
Fujii Masao