Skip to content

run/locale.t: Skip tests if no appropriate locale #23273

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

Merged
merged 3 commits into from
May 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions t/run/locale.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use warnings;
BEGIN {
eval { require POSIX; POSIX->import("locale_h") };
if ($@) {
skip_all("could not load the POSIX module"); # running minitest?
skip_all("could not load the POSIX module"); # running minitest?
}
}
use Config;
Expand Down Expand Up @@ -612,7 +612,8 @@ EOF

SKIP:
{
skip "didn't find a suitable UTF-8 locale", 1 unless $utf8_ref;
skip "didn't find a suitable UTF-8 locale", 1
unless $utf8_ref && $utf8_ref->@*;
my $locale = $utf8_ref->[0];

fresh_perl_is(<<"EOF", "ok\n", {}, "Handles above Unicode in a UTF8 locale");
Expand All @@ -632,7 +633,8 @@ EOF

SKIP:
{
skip "didn't find a suitable UTF-8 locale", 1 unless $utf8_ref;
skip "didn't find a suitable UTF-8 locale", 1
unless $utf8_ref && $utf8_ref->@*;
my $is64bit = length sprintf("%x", ~0) > 8;
skip "32-bit ASCII platforms can't physically have extended UTF-8", 1
if $::IS_ASCII && ! $is64bit;
Expand All @@ -655,10 +657,9 @@ EOF
}

SKIP: { # GH #20085
my @utf8_locales = find_utf8_ctype_locales();
skip "didn't find a UTF-8 locale", 1 unless @utf8_locales;

local $ENV{LC_CTYPE} = $utf8_locales[0];
skip "didn't find a suitable UTF-8 locale", 1
unless $utf8_ref && $utf8_ref->@*;
local $ENV{LC_CTYPE} = $utf8_ref->[0];
local $ENV{LC_ALL} = undef;
fresh_perl_is(<<~'EOF', "ok\n", {}, "check that setlocale overrides startup");
use POSIX;
Expand All @@ -684,7 +685,7 @@ SKIP: { # GH #20054
skip "Even illegal locale names are accepted", 1
if $Config{d_setlocale_accepts_any_locale_name}
&& $Config{d_setlocale_accepts_any_locale_name} eq 'define';

my @lc_all_locales = find_locales('LC_ALL');
my $locale = $lc_all_locales[0];
skip "LC_ALL not enabled on this platform", 1 unless $locale;
Expand Down
Loading