Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 289eaf87f8de4d9ebfd661d4e4299c2952435243 Mon Sep 17 00:00:00 2001 |
| 2 | From: Niko Tyni <ntyni@debian.org> |
| 3 | Date: Fri, 10 Apr 2015 10:19:51 +0300 |
| 4 | Subject: Make t/run/locale.t survive missing locales masked by LC_ALL |
| 5 | |
| 6 | If LC_ALL is set to a valid locale but another LC_* setting like LC_CTYPE |
| 7 | isn't, t/run/locale.t would fail because it explicitly unsets LC_ALL, |
| 8 | unmasking the problem underneath. All the other tests survive such |
| 9 | a scenario. |
| 10 | |
| 11 | While this is clearly an error in the build environment, it's easy to make |
| 12 | the test more robust by first clearing all the locale relevant variables. |
| 13 | |
| 14 | Bug: https://rt.perl.org/Ticket/Display.html?id=124310 |
| 15 | Bug-Debian: https://bugs.debian.org/782068 |
| 16 | Patch-Name: debian/locale-robustness.diff |
| 17 | --- |
| 18 | t/run/locale.t | 7 +++---- |
| 19 | 1 file changed, 3 insertions(+), 4 deletions(-) |
| 20 | |
| 21 | diff --git a/t/run/locale.t b/t/run/locale.t |
| 22 | index bd1a034..2105339 100644 |
| 23 | --- a/t/run/locale.t |
| 24 | +++ b/t/run/locale.t |
| 25 | @@ -27,6 +27,9 @@ my @locales = eval { find_locales( [ &LC_ALL, &LC_CTYPE, &LC_NUMERIC ], |
| 26 | ) }; |
| 27 | skip_all("no locales available") unless @locales; |
| 28 | |
| 29 | +# reset the locale environment |
| 30 | +local @ENV{'LANG', (grep /^LC_/, keys %ENV)}; |
| 31 | + |
| 32 | plan tests => &last; |
| 33 | |
| 34 | my $non_C_locale; |
| 35 | @@ -58,9 +61,6 @@ EOF |
| 36 | SKIP: { |
| 37 | skip("Windows stores locale defaults in the registry", 1 ) |
| 38 | if $^O eq 'MSWin32'; |
| 39 | - local $ENV{LC_NUMERIC}; # So not taken as a default |
| 40 | - local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC |
| 41 | - local $ENV{LANG}; # So not taken as a default |
| 42 | fresh_perl_is("for (qw(@locales)) {\n" . <<'EOF', |
| 43 | use POSIX qw(locale_h); |
| 44 | use locale; |
| 45 | @@ -348,7 +348,6 @@ EOF |
| 46 | |
| 47 | { |
| 48 | local $ENV{LC_NUMERIC} = $different; |
| 49 | - local $ENV{LC_ALL}; # so it never overrides LC_NUMERIC |
| 50 | fresh_perl_is(<<"EOF", |
| 51 | use POSIX qw(locale_h); |
| 52 | |