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