Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Make t/run/locale.t survive missing locales masked by LC_ALL #14652

Closed
p5pRT opened this issue Apr 15, 2015 · 9 comments
Closed

[PATCH] Make t/run/locale.t survive missing locales masked by LC_ALL #14652

p5pRT opened this issue Apr 15, 2015 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 15, 2015

Migrated from rt.perl.org#124310 (status was 'resolved')

Searchable as RT124310$

@p5pRT
Copy link
Author

p5pRT commented Apr 15, 2015

From @ntyni

If LC_ALL is set to a valid locale but another LC_* setting like LC_CTYPE
isn't, t/run/locale.t fails because it explicitly unsets LC_ALL, unmasking
the problem underneath. All the other tests survive such a scenario.

While this is clearly an error in the build environment, it's easy to make
the test more robust by first clearing all the locale relevant variables.

Patch attached.
--
Niko Tyni ntyni@​debian.org

@p5pRT
Copy link
Author

p5pRT commented Apr 15, 2015

From @ntyni

0001-Make-t-run-locale.t-survive-missing-locales-masked-b.patch
From 28b883383a481e6bda67ce7e75339475fdb709ce Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Wed, 15 Apr 2015 18:41:57 +0300
Subject: [PATCH] Make t/run/locale.t survive missing locales masked by LC_ALL

If LC_ALL is set to a valid locale but another LC_* setting like LC_CTYPE
isn't, t/run/locale.t would fail because it explicitly unsets LC_ALL,
unmasking the problem underneath. All the other tests survive such
a scenario.

While this is clearly an error in the build environment, it's easy to make
the test more robust by first clearing all the locale relevant variables.

Bug-Debian: https://bugs.debian.org/782068
---
 t/run/locale.t | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/t/run/locale.t b/t/run/locale.t
index 528cf8a..d63efc3 100644
--- a/t/run/locale.t
+++ b/t/run/locale.t
@@ -27,6 +27,9 @@ my @locales = eval { find_locales( [ &LC_ALL, &LC_CTYPE, &LC_NUMERIC ],
                                  ) };
 skip_all("no locales available") unless @locales;
 
+# reset the locale environment
+local @ENV{'LANG', (grep /^LC_/, keys %ENV)};
+
 plan tests => &last;
 
 my $non_C_locale;
@@ -58,9 +61,6 @@ EOF
 SKIP: {
     skip("Windows stores locale defaults in the registry", 1 )
                                                             if $^O eq 'MSWin32';
-    local $ENV{LC_NUMERIC}; # So not taken as a default
-    local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC
-    local $ENV{LANG};   # So not taken as a default
     fresh_perl_is("for (qw(@locales)) {\n" . <<'EOF',
         use POSIX qw(locale_h);
         use locale;
@@ -120,7 +120,6 @@ SKIP: {
     note("using the '$different' locale for LC_NUMERIC tests");
     {
 	local $ENV{LC_NUMERIC} = $different;
-	local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC
 
 	fresh_perl_is(<<'EOF', "4.2", {},
 format STDOUT =
@@ -260,7 +259,6 @@ EOF
 
     {
 	local $ENV{LC_NUMERIC} = $different;
-	local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC
 	fresh_perl_is(<<'EOF', "$difference "x4, {},
             use locale;
 	    use POSIX qw(locale_h);
@@ -272,8 +270,6 @@ EOF
 
     {
 	local $ENV{LC_NUMERIC} = $different;
-	local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC
-	local $ENV{LANG};   # so on Windows gets sys default locale
 	fresh_perl_is(<<'EOF', "$difference "x4, {},
             use locale;
 	    use POSIX qw(locale_h);
@@ -348,7 +344,6 @@ EOF
 
     {
 	local $ENV{LC_NUMERIC} = $different;
-	local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC
 	fresh_perl_is(<<"EOF",
 	    use POSIX qw(locale_h);
 
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Apr 17, 2015

From @jkeenan

On Wed Apr 15 10​:41​:25 2015, ntyni@​debian.org wrote​:

If LC_ALL is set to a valid locale but another LC_* setting like LC_CTYPE
isn't, t/run/locale.t fails because it explicitly unsets LC_ALL, unmasking
the problem underneath. All the other tests survive such a scenario.

While this is clearly an error in the build environment, it's easy to make
the test more robust by first clearing all the locale relevant variables.

Patch attached.

I have created a smoke-testing branch, smoke-me/jkeenan/124310-locale, and applied the patch to the branch.

I'm not an expert on locales. I hope that some of our contributors who have dealt with locale problems in the past can evaluate the patch, review the correspondence in the Debian bug report (link attached) and make recommendations.

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Apr 17, 2015

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2015

From @tonycoz

On Wed Apr 15 10​:41​:25 2015, ntyni@​debian.org wrote​:

If LC_ALL is set to a valid locale but another LC_* setting like LC_CTYPE
isn't, t/run/locale.t fails because it explicitly unsets LC_ALL, unmasking
the problem underneath. All the other tests survive such a scenario.

While this is clearly an error in the build environment, it's easy to make
the test more robust by first clearing all the locale relevant variables.

Patch attached.

Thanks, applied as c53481e.

Tony

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2015

@tonycoz - Status changed from 'open' to 'resolved'

@p5pRT
Copy link
Author

p5pRT commented Jun 4, 2015

@tonycoz - Status changed from 'resolved' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

From @khwilliamson

Thank you for submitting this report. You have helped make Perl better.
 
With the release of Perl 5.24.0 on May 9, 2016, this and 149 other issues have been resolved.

Perl 5.24.0 may be downloaded via https://metacpan.org/release/RJBS/perl-5.24.0

@p5pRT
Copy link
Author

p5pRT commented May 13, 2016

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant