summaryrefslogtreecommitdiff
path: root/t/loc_tools.pl
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-10-21 04:46:51 -0600
committerKarl Williamson <khw@cpan.org>2020-10-23 07:07:27 -0600
commitb0441c5bc62aa2ba1980c5ae151db48af58bcfcf (patch)
tree7ffc9f208c3850686a7d5525db38d6c7f65fcee1 /t/loc_tools.pl
parent65ff256a878d82cdb1d89d1c272a696485588dcc (diff)
downloadperl-b0441c5bc62aa2ba1980c5ae151db48af58bcfcf.tar.gz
t/loc_tools.pl: Consider thread 0 always locale-safe
Test files call this code to see if locales are enabled. Prior to this commit, it returned that they were disabled on builds where there are possible races between threads. This was to silence some rarely occurring smoke failures. But that had the result that such builds didn't get locales tested at all, even if there was just a single thread operating. This commit changes it so that when called from other than the main thread on such a system, it returns disabled, but enabled for the main thread.
Diffstat (limited to 't/loc_tools.pl')
-rw-r--r--t/loc_tools.pl9
1 files changed, 7 insertions, 2 deletions
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index 1f8a8df750..d751e3de97 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -215,8 +215,13 @@ sub locales_enabled(;$) {
# normally would be available
return 0 if ! defined &DynaLoader::boot_DynaLoader;
- # Don't test locales where they aren't safe.
- return 0 unless ${^SAFE_LOCALES};
+ # Don't test locales where they aren't safe. On systems with unsafe
+ # threads, for the purposes of testing, we consider the main thread safe,
+ # and all other threads unsafe.
+ if (! ${^SAFE_LOCALES}) {
+ require threads;
+ return 0 if threads->tid() != 0;
+ }
# If no setlocale, we need the POSIX 2008 alternatives
if (! $Config{d_setlocale}) {