Skip to content

Commit 583e15a

Browse files
committed
Fix places in TestLib.pm in need of adaptation to the output of Msys perl
Contrary to the output of native perl, Msys perl generates outputs with CRLFs characters. There are already places in the TAP code where CRLFs (\r\n) are automatically converted to LF (\n) on Msys, but we missed a couple of places when running commands and using their output for comparison, that would lead to failures. This problem has been found thanks to the test added in 5adb067 using TestLib::command_checks_all(), but after a closer look more code paths were missing a filter. This is backpatched all the way down to prevent any surprises if a new test is introduced in stable branches. Reviewed-by: Andrew Dunstan, Álvaro Herrera Discussion: https://postgr.es/m/1252480.1631829409@sss.pgh.pa.us Backpatch-through: 9.6
1 parent 5f0a073 commit 583e15a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/test/perl/TestLib.pm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ sub run_command
377377
my ($cmd) = @_;
378378
my ($stdout, $stderr);
379379
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
380+
foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
380381
chomp($stdout);
381382
chomp($stderr);
382383
return ($stdout, $stderr);
@@ -787,6 +788,7 @@ sub command_like
787788
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
788789
ok($result, "$test_name: exit code 0");
789790
is($stderr, '', "$test_name: no stderr");
791+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
790792
like($stdout, $expected_stdout, "$test_name: matches");
791793
return;
792794
}
@@ -839,6 +841,7 @@ sub command_fails_like
839841
print("# Running: " . join(" ", @{$cmd}) . "\n");
840842
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
841843
ok(!$result, "$test_name: exit code not 0");
844+
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
842845
like($stderr, $expected_stderr, "$test_name: matches");
843846
return;
844847
}
@@ -883,6 +886,8 @@ sub command_checks_all
883886
if $ret & 127;
884887
$ret = $ret >> 8;
885888

889+
foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
890+
886891
# check status
887892
ok($ret == $expected_ret,
888893
"$test_name status (got $ret vs expected $expected_ret)");

0 commit comments

Comments
 (0)