This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix edge case test failure in ext/POSIX/t/mb.t
authorDominic Hargreaves <dom@earth.li>
Fri, 7 Jun 2019 09:04:26 +0000 (10:04 +0100)
committerJames E Keenan <jkeenan@cpan.org>
Fri, 7 Jun 2019 11:53:07 +0000 (07:53 -0400)
This new test fails in an environment where LANG is set to one thing and
LC_ALL is set to another, and where LANG is set to a locale which is
not installed in the environment in question.

Such a test environment is arguably broken, but appears in common
chroot setups such as Debian's sbuild tool where LANG is inherited from
the parent environment, and LC_ALL is used to override it.

Committer: removed one non-printing character from patch

For: RT # 134182

ext/POSIX/t/mb.t

index 053693e..c10ea1a 100644 (file)
@@ -34,9 +34,13 @@ SKIP: {
     my $utf8_locale = find_utf8_ctype_locale();
     skip("no utf8 locale available", 3) unless $utf8_locale;
 
+    # Here we need to influence LC_CTYPE, but it's not enough to just
+    # set this because LC_ALL could override it. It's also not enough
+    # to delete LC_ALL because it could be used to override other
+    # variables such as LANG in the underlying test environment.
+    # Continue to set LC_CTYPE just in case...
     local $ENV{LC_CTYPE} = $utf8_locale;
-    local $ENV{LC_ALL};
-    delete $ENV{LC_ALL};
+    local $ENV{LC_ALL} = $utf8_locale;
 
     fresh_perl_like(
         'use POSIX; print &POSIX::MB_CUR_MAX',