Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 17b87b3

Browse files
committed
Tighten up Windows CRLF conversion in our TAP test scripts.
Back-patch commits 91bdf499b and ffb4cee43, 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 601d419 commit 17b87b3

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
@@ -112,7 +112,7 @@ sub check_query
112112
}
113113
else
114114
{
115-
$stdout =~ s/\r//g if $Config{osname} eq 'msys';
115+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
116116
is($stdout, $expected_stdout, "$test_name: query result matches");
117117
}
118118
return;

src/test/perl/PostgresNode.pm

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,6 @@ sub safe_psql
13241324
print "\n#### End standard error\n";
13251325
}
13261326

1327-
$stdout =~ s/\r//g if $TestLib::windows_os;
13281327
return $stdout;
13291328
}
13301329

@@ -1513,16 +1512,20 @@ sub psql
15131512
}
15141513
};
15151514

1515+
# Note: on Windows, IPC::Run seems to convert \r\n to \n in program output
1516+
# if we're using native Perl, but not if we're using MSys Perl. So do it
1517+
# by hand in the latter case, here and elsewhere.
1518+
15161519
if (defined $$stdout)
15171520
{
1521+
$$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
15181522
chomp $$stdout;
1519-
$$stdout =~ s/\r//g if $TestLib::windows_os;
15201523
}
15211524

15221525
if (defined $$stderr)
15231526
{
1527+
$$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
15241528
chomp $$stderr;
1525-
$$stderr =~ s/\r//g if $TestLib::windows_os;
15261529
}
15271530

15281531
# See http://perldoc.perl.org/perlvar.html#%24CHILD_ERROR
@@ -1652,8 +1655,8 @@ sub poll_query_until
16521655
{
16531656
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
16541657

1658+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
16551659
chomp($stdout);
1656-
$stdout =~ s/\r//g if $TestLib::windows_os;
16571660

16581661
if ($stdout eq $expected)
16591662
{
@@ -1668,8 +1671,8 @@ sub poll_query_until
16681671

16691672
# The query result didn't change in 180 seconds. Give up. Print the
16701673
# output from the last attempt, hopefully that's useful for debugging.
1674+
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
16711675
chomp($stderr);
1672-
$stderr =~ s/\r//g if $TestLib::windows_os;
16731676
diag qq(poll_query_until timed out executing this query:
16741677
$query
16751678
expecting this output:
@@ -2113,8 +2116,8 @@ sub pg_recvlogical_upto
21132116
}
21142117
};
21152118

2116-
$stdout =~ s/\r//g if $TestLib::windows_os;
2117-
$stderr =~ s/\r//g if $TestLib::windows_os;
2119+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
2120+
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
21182121

21192122
if (wantarray)
21202123
{

src/test/perl/TestLib.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ sub slurp_file
430430
CloseHandle($fHandle)
431431
or die "could not close \"$filename\": $^E\n";
432432
}
433-
$contents =~ s/\r//g if $Config{osname} eq 'msys';
433+
$contents =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
434434
return $contents;
435435
}
436436

0 commit comments

Comments
 (0)