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

Commitefd7f8e

Browse files
committed
Work around Msys weakness in Testlib.pm's command_like()
When output of IPC::Run::run () is redirected to scalar references, incertain circumstances the Msys perl does not correctly detect that theend of file has been seen, making the test hang indefinitely. One suchcircumstance is when the command is 'pg_ctl start', and such a changewas made in commitf13ea95. The workaround, which only applies onMSys, is to redirect the output to temporary files and then read them inwhen the process has finished.Patch by me, reviewed and tweaked by Tom Lane.
1 parent50d2426 commitefd7f8e

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

‎src/bin/pg_ctl/t/001_start_stop.pl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,17 @@
3232
print$conf"listen_addresses = '127.0.0.1'\n";
3333
}
3434
close$conf;
35-
command_like(['pg_ctl','start','-D',"$tempdir/data",
36-
'-l',"$TestLib::log_path/001_start_stop_server.log" ],
37-
qr/done.*server started/s,'pg_ctl start');
35+
my$ctlcmd = ['pg_ctl','start','-D',"$tempdir/data",
36+
'-l',"$TestLib::log_path/001_start_stop_server.log" ];
37+
if ($Config{osname}ne'msys')
38+
{
39+
command_like($ctlcmd,qr/done.*server started/s,'pg_ctl start');
40+
}
41+
else
42+
{
43+
# use the version of command_like that doesn't hang on Msys here
44+
command_like_safe($ctlcmd,qr/done.*server started/s,'pg_ctl start');
45+
}
3846

3947
# sleep here is because Windows builds can't check postmaster.pid exactly,
4048
# so they may mistake a pre-existing postmaster.pid for one created by the

‎src/test/perl/TestLib.pm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ our @EXPORT = qw(
3737
program_version_ok
3838
program_options_handling_ok
3939
command_like
40+
command_like_safe
4041
command_fails_like
4142
4243
$windows_os
@@ -300,6 +301,24 @@ sub command_like
300301
like($stdout,$expected_stdout,"$test_name: matches");
301302
}
302303

304+
subcommand_like_safe
305+
{
306+
# Doesn't rely on detecting end of file on the file descriptors,
307+
# which can fail, causing the process to hang, notably on Msys
308+
# when used with 'pg_ctl start'
309+
my ($cmd,$expected_stdout,$test_name) =@_;
310+
my ($stdout,$stderr);
311+
my$stdoutfile = File::Temp->new();
312+
my$stderrfile = File::Temp->new();
313+
print("# Running:" .join("", @{$cmd}) ."\n");
314+
my$result = IPC::Run::run$cmd,'>',$stdoutfile,'2>',$stderrfile;
315+
$stdout = slurp_file($stdoutfile);
316+
$stderr = slurp_file($stderrfile);
317+
ok($result,"$test_name: exit code 0");
318+
is($stderr,'',"$test_name: no stderr");
319+
like($stdout,$expected_stdout,"$test_name: matches");
320+
}
321+
303322
subcommand_fails_like
304323
{
305324
my ($cmd,$expected_stderr,$test_name) =@_;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp