Skip to content

Commit a3cfb10

Browse files
committed
Tighten up Windows CRLF conversion in our TAP test scripts.
Back-patch commits 91bdf49 and ffb4cee, so that all branches agree on when and how to do Windows CRLF conversion. This should close the referenced thread. Thanks to Andrew Dunstan for discussion/review. Discussion: https://postgr.es/m/412ae8da-76bb-640f-039a-f3513499e53d@gmx.net
1 parent 2564e2d commit a3cfb10

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/bin/pg_rewind/t/RewindTest.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ sub check_query
111111
}
112112
else
113113
{
114-
$stdout =~ s/\r//g if $Config{osname} eq 'msys';
114+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
115115
is($stdout, $expected_stdout, "$test_name: query result matches");
116116
}
117117
return;

src/test/perl/PostgresNode.pm

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,6 @@ sub safe_psql
12961296
print "\n#### End standard error\n";
12971297
}
12981298

1299-
$stdout =~ s/\r//g if $TestLib::windows_os;
13001299
return $stdout;
13011300
}
13021301

@@ -1472,16 +1471,20 @@ sub psql
14721471
}
14731472
};
14741473

1474+
# Note: on Windows, IPC::Run seems to convert \r\n to \n in program output
1475+
# if we're using native Perl, but not if we're using MSys Perl. So do it
1476+
# by hand in the latter case, here and elsewhere.
1477+
14751478
if (defined $$stdout)
14761479
{
1480+
$$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
14771481
chomp $$stdout;
1478-
$$stdout =~ s/\r//g if $TestLib::windows_os;
14791482
}
14801483

14811484
if (defined $$stderr)
14821485
{
1486+
$$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
14831487
chomp $$stderr;
1484-
$$stderr =~ s/\r//g if $TestLib::windows_os;
14851488
}
14861489

14871490
# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
@@ -1544,8 +1547,8 @@ sub poll_query_until
15441547
{
15451548
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
15461549

1550+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
15471551
chomp($stdout);
1548-
$stdout =~ s/\r//g if $TestLib::windows_os;
15491552

15501553
if ($stdout eq $expected)
15511554
{
@@ -1560,8 +1563,8 @@ sub poll_query_until
15601563

15611564
# The query result didn't change in 180 seconds. Give up. Print the
15621565
# output from the last attempt, hopefully that's useful for debugging.
1566+
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
15631567
chomp($stderr);
1564-
$stderr =~ s/\r//g if $TestLib::windows_os;
15651568
diag qq(poll_query_until timed out executing this query:
15661569
$query
15671570
expecting this output:
@@ -2005,8 +2008,8 @@ sub pg_recvlogical_upto
20052008
}
20062009
};
20072010

2008-
$stdout =~ s/\r//g if $TestLib::windows_os;
2009-
$stderr =~ s/\r//g if $TestLib::windows_os;
2011+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
2012+
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
20102013

20112014
if (wantarray)
20122015
{

src/test/perl/TestLib.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ sub slurp_file
260260
or die "could not read \"$filename\": $!";
261261
my $contents = <$in>;
262262
close $in;
263-
$contents =~ s/\r//g if $Config{osname} eq 'msys';
263+
$contents =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
264264
return $contents;
265265
}
266266

0 commit comments

Comments
 (0)