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

Commit114541d

Browse files
committed
Use native methods to open input in TestLib::slurp_file on Windows.
It is hoped that this will avoid some errors that we have seen before,but lately with greater frequency, in buildfarm animals.For now apply only to master. If this proves effective it can bebackpatched.Discussion:https://postgr.es/m/13900.1572839580@sss.pgh.pa.usAuthor: Juan José Santamaría Flecha
1 parentd3aa114 commit114541d

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

‎src/test/perl/TestLib.pm

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ BEGIN
112112

113113
# Must be set early
114114
$windows_os =$Config{osname}eq'MSWin32' ||$Config{osname}eq'msys';
115+
if ($windows_os)
116+
{
117+
require Win32API::File;
118+
Win32API::File->import(qw(createFile OsFHandleOpen CloseHandle));
119+
}
115120
}
116121

117122
=pod
@@ -394,10 +399,24 @@ sub slurp_file
394399
{
395400
my ($filename) =@_;
396401
local$/;
397-
open(my$in,'<',$filename)
398-
ordie"could not read\"$filename\":$!";
399-
my$contents = <$in>;
400-
close$in;
402+
my$contents;
403+
if (!$windows_os)
404+
{
405+
open(my$in,'<',$filename)
406+
ordie"could not read\"$filename\":$!";
407+
$contents = <$in>;
408+
close$in;
409+
}
410+
else
411+
{
412+
my$fHandle = createFile($filename,"r","rwd")
413+
ordie"could not open\"$filename\": $^E";
414+
OsFHandleOpen(my$fh = IO::Handle->new(),$fHandle,'r')
415+
ordie"could not read\"$filename\": $^E\n";
416+
$contents = <$fh>;
417+
CloseHandle($fHandle)
418+
ordie"could not close\"$filename\": $^E\n";
419+
}
401420
$contents =~s/\r//gif$Config{osname}eq'msys';
402421
return$contents;
403422
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp