Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ca266a0

Browse files
committed
Revert "Close stdin where it's not needed in TestLib.pm procedures"
This reverts commits 9af34f3 and 792dba7. The code has been found not to be portable. Discussion: https://postgr.es/m/2658c496-f885-02db-13bb-228423782524@2ndQuadrant.com
1 parent 4513d8b commit ca266a0

File tree

1 file changed

+11
-38
lines changed

1 file changed

+11
-38
lines changed

src/test/perl/TestLib.pm

+11-38
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ TestLib - helper module for writing PostgreSQL's C<prove> tests.
2121
2222
# Miscellanea
2323
print "on Windows" if $TestLib::windows_os;
24-
print "IO::Pty is available" if $TestLib::have_io_pty;
2524
my $path = TestLib::perl2host($backup_dir);
2625
ok(check_mode_recursive($stream_dir, 0700, 0600),
2726
"check stream dir permissions");
@@ -84,12 +83,9 @@ our @EXPORT = qw(
8483
command_checks_all
8584
8685
$windows_os
87-
$have_io_pty
8886
);
8987

90-
our ($windows_os, $tmp_check, $log_path, $test_logfile, $have_io_pty);
91-
92-
my @no_stdin;
88+
our ($windows_os, $tmp_check, $log_path, $test_logfile);
9389

9490
BEGIN
9591
{
@@ -121,9 +117,6 @@ BEGIN
121117
require Win32API::File;
122118
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
123119
}
124-
125-
eval { require IO::Pty; };
126-
$have_io_pty = 1 unless $@;
127120
}
128121

129122
=pod
@@ -138,12 +131,6 @@ Set to true when running under Windows, except on Cygwin.
138131
139132
=back
140133
141-
=item C<$have_io_pty>
142-
143-
Set to true when IO::Pty is available.
144-
145-
=back
146-
147134
=cut
148135

149136
INIT
@@ -191,20 +178,6 @@ INIT
191178
autoflush STDOUT 1;
192179
autoflush STDERR 1;
193180
autoflush $testlog 1;
194-
195-
# Settings to close stdin for certain commands.
196-
# If IO::Pty is present, use a pseudo-terminal, so that libraries like
197-
# openssl which open the tty if they think stdin isn't one for a password
198-
# don't block. Elsewhere just provide an empty string for stdin.
199-
if ($have_io_pty)
200-
{
201-
use charnames ':full';
202-
@no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
203-
}
204-
else
205-
{
206-
@no_stdin = ('<', \"");
207-
}
208181
}
209182

210183
END
@@ -370,7 +343,7 @@ sub run_command
370343
{
371344
my ($cmd) = @_;
372345
my ($stdout, $stderr);
373-
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr, @no_stdin;
346+
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
374347
chomp($stdout);
375348
chomp($stderr);
376349
return ($stdout, $stderr);
@@ -603,7 +576,7 @@ sub check_pg_config
603576
my ($regexp) = @_;
604577
my ($stdout, $stderr);
605578
my $result = IPC::Run::run [ 'pg_config', '--includedir' ], '>',
606-
\$stdout, '2>', \$stderr, @no_stdin
579+
\$stdout, '2>', \$stderr
607580
or die "could not execute pg_config";
608581
chomp($stdout);
609582
$stdout =~ s/\r$//;
@@ -700,7 +673,7 @@ sub program_help_ok
700673
my ($stdout, $stderr);
701674
print("# Running: $cmd --help\n");
702675
my $result = IPC::Run::run [ $cmd, '--help' ], '>', \$stdout, '2>',
703-
\$stderr, @no_stdin;
676+
\$stderr;
704677
ok($result, "$cmd --help exit code 0");
705678
isnt($stdout, '', "$cmd --help goes to stdout");
706679
is($stderr, '', "$cmd --help nothing to stderr");
@@ -722,7 +695,7 @@ sub program_version_ok
722695
my ($stdout, $stderr);
723696
print("# Running: $cmd --version\n");
724697
my $result = IPC::Run::run [ $cmd, '--version' ], '>', \$stdout, '2>',
725-
\$stderr, @no_stdin;
698+
\$stderr;
726699
ok($result, "$cmd --version exit code 0");
727700
isnt($stdout, '', "$cmd --version goes to stdout");
728701
is($stderr, '', "$cmd --version nothing to stderr");
@@ -745,7 +718,8 @@ sub program_options_handling_ok
745718
my ($stdout, $stderr);
746719
print("# Running: $cmd --not-a-valid-option\n");
747720
my $result = IPC::Run::run [ $cmd, '--not-a-valid-option' ], '>',
748-
\$stdout, '2>', \$stderr, @no_stdin;
721+
\$stdout,
722+
'2>', \$stderr;
749723
ok(!$result, "$cmd with invalid option nonzero exit code");
750724
isnt($stderr, '', "$cmd with invalid option prints error message");
751725
return;
@@ -766,7 +740,7 @@ sub command_like
766740
my ($cmd, $expected_stdout, $test_name) = @_;
767741
my ($stdout, $stderr);
768742
print("# Running: " . join(" ", @{$cmd}) . "\n");
769-
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr, @no_stdin;
743+
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
770744
ok($result, "$test_name: exit code 0");
771745
is($stderr, '', "$test_name: no stderr");
772746
like($stdout, $expected_stdout, "$test_name: matches");
@@ -795,8 +769,7 @@ sub command_like_safe
795769
my $stdoutfile = File::Temp->new();
796770
my $stderrfile = File::Temp->new();
797771
print("# Running: " . join(" ", @{$cmd}) . "\n");
798-
my $result = IPC::Run::run $cmd, '>', $stdoutfile, '2>', $stderrfile,
799-
@no_stdin;
772+
my $result = IPC::Run::run $cmd, '>', $stdoutfile, '2>', $stderrfile;
800773
$stdout = slurp_file($stdoutfile);
801774
$stderr = slurp_file($stderrfile);
802775
ok($result, "$test_name: exit code 0");
@@ -820,7 +793,7 @@ sub command_fails_like
820793
my ($cmd, $expected_stderr, $test_name) = @_;
821794
my ($stdout, $stderr);
822795
print("# Running: " . join(" ", @{$cmd}) . "\n");
823-
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr, @no_stdin;
796+
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
824797
ok(!$result, "$test_name: exit code not 0");
825798
like($stderr, $expected_stderr, "$test_name: matches");
826799
return;
@@ -858,7 +831,7 @@ sub command_checks_all
858831
# run command
859832
my ($stdout, $stderr);
860833
print("# Running: " . join(" ", @{$cmd}) . "\n");
861-
IPC::Run::run($cmd, '>', \$stdout, '2>', \$stderr, @no_stdin);
834+
IPC::Run::run($cmd, '>', \$stdout, '2>', \$stderr);
862835

863836
# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
864837
my $ret = $?;

0 commit comments

Comments
 (0)