Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit792dba7

Browse files
committed
Fix closing stdin in TestLib.pm
Commit9af34f3 naively assumed that all non-windows platforms wouldhave pseudoterminals and that perl would have IO::Pty. Such is not thecase. Instead of assumung anything, test for the presence of IO::Pty andonly use code that might depend on it if it's present. The test result isexposed in $TestLib::have_io_pty so that it can be conveniently used inSKIP tests.Discussion:https://postgr.es/m/20191126044110.GB5435@paquier.xyz
1 parent553d2ec commit792dba7

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

‎src/test/perl/TestLib.pm

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ 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;
2425
my $path = TestLib::perl2host($backup_dir);
2526
ok(check_mode_recursive($stream_dir, 0700, 0600),
2627
"check stream dir permissions");
@@ -83,9 +84,10 @@ our @EXPORT = qw(
8384
command_checks_all
8485
8586
$windows_os
87+
$have_io_pty
8688
);
8789

88-
our ($windows_os,$tmp_check,$log_path,$test_logfile);
90+
our ($windows_os,$tmp_check,$log_path,$test_logfile,$have_io_pty);
8991

9092
my@no_stdin;
9193

@@ -119,6 +121,9 @@ BEGIN
119121
require Win32API::File;
120122
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
121123
}
124+
125+
eval {require IO::Pty; };
126+
$have_io_pty = 1unless$@;
122127
}
123128

124129
=pod
@@ -133,6 +138,12 @@ Set to true when running under Windows, except on Cygwin.
133138
134139
=back
135140
141+
=itemC<$have_io_pty>
142+
143+
Set to true when IO::Pty is available.
144+
145+
=back
146+
136147
=cut
137148

138149
INIT
@@ -182,18 +193,17 @@ INIT
182193
autoflush$testlog 1;
183194

184195
# Settings to close stdin for certain commands.
185-
# On non-Windows, use a pseudo-terminal, so that libraries like openssl
186-
# which open the tty if they think stdin isn't one for a password
187-
# don't block. Windows doesn't have ptys, so just provide an empty
188-
# string for stdin.
189-
if ($windows_os)
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)
190200
{
191-
@no_stdin = ('<', \"");
201+
use charnames':full';
202+
@no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
192203
}
193204
else
194205
{
195-
use charnames':full';
196-
@no_stdin = ('<pty<', \"\N{END OF TRANSMISSION}");
206+
@no_stdin = ('<', \"");
197207
}
198208
}
199209

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp