aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-09-22 08:43:00 +0900
committerMichael Paquier <michael@paquier.xyz>2021-09-22 08:43:00 +0900
commit90251ff199858844fa450ba9614092c06c67fc4f (patch)
treef3f9846e173c63ff781ccc1287ed71bfb8dcb362 /src
parent2ad5f963e1306aa6f4cf96076a230e96529d2237 (diff)
downloadpostgresql-90251ff199858844fa450ba9614092c06c67fc4f.tar.gz
postgresql-90251ff199858844fa450ba9614092c06c67fc4f.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/test/perl/TestLib.pm5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
index 108f393774e..8c533453b41 100644
--- a/src/test/perl/TestLib.pm
+++ b/src/test/perl/TestLib.pm
@@ -414,6 +414,7 @@ sub run_command
my ($cmd) = @_;
my ($stdout, $stderr);
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
+ foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
chomp($stdout);
chomp($stderr);
return ($stdout, $stderr);
@@ -858,6 +859,7 @@ sub command_like
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
ok($result, "$test_name: exit code 0");
is($stderr, '', "$test_name: no stderr");
+ $stdout =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
like($stdout, $expected_stdout, "$test_name: matches");
return;
}
@@ -910,6 +912,7 @@ sub command_fails_like
print("# Running: " . join(" ", @{$cmd}) . "\n");
my $result = IPC::Run::run $cmd, '>', \$stdout, '2>', \$stderr;
ok(!$result, "$test_name: exit code not 0");
+ $stderr =~ s/\r\n/\n/g if $Config{osname} eq 'msys';
like($stderr, $expected_stderr, "$test_name: matches");
return;
}
@@ -954,6 +957,8 @@ sub command_checks_all
if $ret & 127;
$ret = $ret >> 8;
+ foreach ($stderr, $stdout) { s/\r\n/\n/g if $Config{osname} eq 'msys'; }
+
# check status
ok($ret == $expected_ret,
"$test_name status (got $ret vs expected $expected_ret)");