Skip to content

Commit 90251ff

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 2ad5f96 commit 90251ff

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
@@ -414,6 +414,7 @@ sub run_command
414414
my ($cmd) = @_;
415415
my ($stdout, $stderr);
416416
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
417+
foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
417418
chomp($stdout);
418419
chomp($stderr);
419420
return ($stdout, $stderr);
@@ -858,6 +859,7 @@ sub command_like
858859
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
859860
ok($result, "$test_name: exit code 0");
860861
is($stderr, '', "$test_name: no stderr");
862+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
861863
like($stdout, $expected_stdout, "$test_name: matches");
862864
return;
863865
}
@@ -910,6 +912,7 @@ sub command_fails_like
910912
print("# Running: " . join(" ", @{$cmd}) . "\n");
911913
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
912914
ok(!$result, "$test_name: exit code not 0");
915+
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
913916
like($stderr, $expected_stderr, "$test_name: matches");
914917
return;
915918
}
@@ -954,6 +957,8 @@ sub command_checks_all
954957
if $ret & 127;
955958
$ret = $ret >> 8;
956959

960+
foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
961+
957962
# check status
958963
ok($ret == $expected_ret,
959964
"$test_name status (got $ret vs expected $expected_ret)");

0 commit comments

Comments
 (0)