Skip to content

Commit 0d91c52

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 4476bcb commit 0d91c52

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
@@ -434,6 +434,7 @@ sub run_command
434434
my ($cmd) = @_;
435435
my ($stdout, $stderr);
436436
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
437+
foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
437438
chomp($stdout);
438439
chomp($stderr);
439440
return ($stdout, $stderr);
@@ -878,6 +879,7 @@ sub command_like
878879
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
879880
ok($result, "$test_name: exit code 0");
880881
is($stderr, '', "$test_name: no stderr");
882+
$stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
881883
like($stdout, $expected_stdout, "$test_name: matches");
882884
return;
883885
}
@@ -930,6 +932,7 @@ sub command_fails_like
930932
print("# Running: " . join(" ", @{$cmd}) . "\n");
931933
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
932934
ok(!$result, "$test_name: exit code not 0");
935+
$stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
933936
like($stderr, $expected_stderr, "$test_name: matches");
934937
return;
935938
}
@@ -974,6 +977,8 @@ sub command_checks_all
974977
if $ret & 127;
975978
$ret = $ret >> 8;
976979

980+
foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
981+
977982
# check status
978983
ok($ret == $expected_ret,
979984
"$test_name status (got $ret vs expected $expected_ret)");

0 commit comments

Comments
 (0)