mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
Revert "Close stdin where it's not needed in TestLib.pm procedures"
This reverts commits 9af34f3c6b and 792dba73c8. The code has been found not to be portable. Discussion: https://postgr.es/m/2658c496-f885-02db-13bb-228423782524@2ndQuadrant.com
This commit is contained in:
parent
4513d8b07b
commit
ca266a069a
@ -21,7 +21,6 @@ TestLib - helper module for writing PostgreSQL's C<prove> tests.
|
|||||||
|
|
||||||
# Miscellanea
|
# Miscellanea
|
||||||
print "on Windows" if $TestLib::windows_os;
|
print "on Windows" if $TestLib::windows_os;
|
||||||
print "IO::Pty is available" if $TestLib::have_io_pty;
|
|
||||||
my $path = TestLib::perl2host($backup_dir);
|
my $path = TestLib::perl2host($backup_dir);
|
||||||
ok(check_mode_recursive($stream_dir, 0700, 0600),
|
ok(check_mode_recursive($stream_dir, 0700, 0600),
|
||||||
"check stream dir permissions");
|
"check stream dir permissions");
|
||||||
@ -84,12 +83,9 @@ our @EXPORT = qw(
|
|||||||
command_checks_all
|
command_checks_all
|
||||||
|
|
||||||
$windows_os
|
$windows_os
|
||||||
$have_io_pty
|
|
||||||
);
|
);
|
||||||
|
|
||||||
our ($windows_os, $tmp_check, $log_path, $test_logfile, $have_io_pty);
|
our ($windows_os, $tmp_check, $log_path, $test_logfile);
|
||||||
|
|
||||||
my @no_stdin;
|
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
{
|
{
|
||||||
@ -121,9 +117,6 @@ BEGIN
|
|||||||
require Win32API::File;
|
require Win32API::File;
|
||||||
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
|
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
eval { require IO::Pty; };
|
|
||||||
$have_io_pty = 1 unless $@;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
@ -138,12 +131,6 @@ Set to true when running under Windows, except on Cygwin.
|
|||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=item C<$have_io_pty>
|
|
||||||
|
|
||||||
Set to true when IO::Pty is available.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
INIT
|
INIT
|
||||||
@ -191,20 +178,6 @@ INIT
|
|||||||
autoflush STDOUT 1;
|
autoflush STDOUT 1;
|
||||||
autoflush STDERR 1;
|
autoflush STDERR 1;
|
||||||
autoflush $testlog 1;
|
autoflush $testlog 1;
|
||||||
|
|
||||||
# Settings to close stdin for certain commands.
|
|
||||||
# If IO::Pty is present, use a pseudo-terminal, so that libraries like
|
|
||||||
# openssl which open the tty if they think stdin isn't one for a password
|
|
||||||
# don't block. Elsewhere just provide an empty string for stdin.
|
|
||||||
if ($have_io_pty)
|
|
||||||
{
|
|
||||||
use charnames ':full';
|
|
||||||
@no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
@no_stdin = ('<', \"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
END
|
END
|
||||||
@ -370,7 +343,7 @@ sub run_command
|
|||||||
{
|
{
|
||||||
my ($cmd) = @_;
|
my ($cmd) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr, @no_stdin;
|
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
|
||||||
chomp($stdout);
|
chomp($stdout);
|
||||||
chomp($stderr);
|
chomp($stderr);
|
||||||
return ($stdout, $stderr);
|
return ($stdout, $stderr);
|
||||||
@ -603,7 +576,7 @@ sub check_pg_config
|
|||||||
my ($regexp) = @_;
|
my ($regexp) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
my $result = IPC::Run::run [ 'pg_config', '--includedir' ], '>',
|
my $result = IPC::Run::run [ 'pg_config', '--includedir' ], '>',
|
||||||
\$stdout, '2>', \$stderr, @no_stdin
|
\$stdout, '2>', \$stderr
|
||||||
or die "could not execute pg_config";
|
or die "could not execute pg_config";
|
||||||
chomp($stdout);
|
chomp($stdout);
|
||||||
$stdout =~ s/\r$//;
|
$stdout =~ s/\r$//;
|
||||||
@ -700,7 +673,7 @@ sub program_help_ok
|
|||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: $cmd --help\n");
|
print("# Running: $cmd --help\n");
|
||||||
my $result = IPC::Run::run [ $cmd, '--help' ], '>', \$stdout, '2>',
|
my $result = IPC::Run::run [ $cmd, '--help' ], '>', \$stdout, '2>',
|
||||||
\$stderr, @no_stdin;
|
\$stderr;
|
||||||
ok($result, "$cmd --help exit code 0");
|
ok($result, "$cmd --help exit code 0");
|
||||||
isnt($stdout, '', "$cmd --help goes to stdout");
|
isnt($stdout, '', "$cmd --help goes to stdout");
|
||||||
is($stderr, '', "$cmd --help nothing to stderr");
|
is($stderr, '', "$cmd --help nothing to stderr");
|
||||||
@ -722,7 +695,7 @@ sub program_version_ok
|
|||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: $cmd --version\n");
|
print("# Running: $cmd --version\n");
|
||||||
my $result = IPC::Run::run [ $cmd, '--version' ], '>', \$stdout, '2>',
|
my $result = IPC::Run::run [ $cmd, '--version' ], '>', \$stdout, '2>',
|
||||||
\$stderr, @no_stdin;
|
\$stderr;
|
||||||
ok($result, "$cmd --version exit code 0");
|
ok($result, "$cmd --version exit code 0");
|
||||||
isnt($stdout, '', "$cmd --version goes to stdout");
|
isnt($stdout, '', "$cmd --version goes to stdout");
|
||||||
is($stderr, '', "$cmd --version nothing to stderr");
|
is($stderr, '', "$cmd --version nothing to stderr");
|
||||||
@ -745,7 +718,8 @@ sub program_options_handling_ok
|
|||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: $cmd --not-a-valid-option\n");
|
print("# Running: $cmd --not-a-valid-option\n");
|
||||||
my $result = IPC::Run::run [ $cmd, '--not-a-valid-option' ], '>',
|
my $result = IPC::Run::run [ $cmd, '--not-a-valid-option' ], '>',
|
||||||
\$stdout, '2>', \$stderr, @no_stdin;
|
\$stdout,
|
||||||
|
'2>', \$stderr;
|
||||||
ok(!$result, "$cmd with invalid option nonzero exit code");
|
ok(!$result, "$cmd with invalid option nonzero exit code");
|
||||||
isnt($stderr, '', "$cmd with invalid option prints error message");
|
isnt($stderr, '', "$cmd with invalid option prints error message");
|
||||||
return;
|
return;
|
||||||
@ -766,7 +740,7 @@ sub command_like
|
|||||||
my ($cmd, $expected_stdout, $test_name) = @_;
|
my ($cmd, $expected_stdout, $test_name) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||||
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr, @no_stdin;
|
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
|
||||||
ok($result, "$test_name: exit code 0");
|
ok($result, "$test_name: exit code 0");
|
||||||
is($stderr, '', "$test_name: no stderr");
|
is($stderr, '', "$test_name: no stderr");
|
||||||
like($stdout, $expected_stdout, "$test_name: matches");
|
like($stdout, $expected_stdout, "$test_name: matches");
|
||||||
@ -795,8 +769,7 @@ sub command_like_safe
|
|||||||
my $stdoutfile = File::Temp->new();
|
my $stdoutfile = File::Temp->new();
|
||||||
my $stderrfile = File::Temp->new();
|
my $stderrfile = File::Temp->new();
|
||||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||||
my $result = IPC::Run::run $cmd, '>', $stdoutfile, '2>', $stderrfile,
|
my $result = IPC::Run::run $cmd, '>', $stdoutfile, '2>', $stderrfile;
|
||||||
@no_stdin;
|
|
||||||
$stdout = slurp_file($stdoutfile);
|
$stdout = slurp_file($stdoutfile);
|
||||||
$stderr = slurp_file($stderrfile);
|
$stderr = slurp_file($stderrfile);
|
||||||
ok($result, "$test_name: exit code 0");
|
ok($result, "$test_name: exit code 0");
|
||||||
@ -820,7 +793,7 @@ sub command_fails_like
|
|||||||
my ($cmd, $expected_stderr, $test_name) = @_;
|
my ($cmd, $expected_stderr, $test_name) = @_;
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||||
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr, @no_stdin;
|
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
|
||||||
ok(!$result, "$test_name: exit code not 0");
|
ok(!$result, "$test_name: exit code not 0");
|
||||||
like($stderr, $expected_stderr, "$test_name: matches");
|
like($stderr, $expected_stderr, "$test_name: matches");
|
||||||
return;
|
return;
|
||||||
@ -858,7 +831,7 @@ sub command_checks_all
|
|||||||
# run command
|
# run command
|
||||||
my ($stdout, $stderr);
|
my ($stdout, $stderr);
|
||||||
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
print("# Running: " . join(" ", @{$cmd}) . "\n");
|
||||||
IPC::Run::run($cmd, '>', \$stdout, '2>', \$stderr, @no_stdin);
|
IPC::Run::run($cmd, '>', \$stdout, '2>', \$stderr);
|
||||||
|
|
||||||
# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
|
# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
|
||||||
my $ret = $?;
|
my $ret = $?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user