diff options
author | Tomasz Konojacki <me@xenu.pl> | 2018-01-10 04:49:08 +0100 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-01-10 10:28:54 -0700 |
commit | 9969000e1134387c0ed173e5d1b3f3b760a1d00c (patch) | |
tree | 225f091e84d200a99c561500654d7adf65184d63 /t/loc_tools.pl | |
parent | 90a59ee553fbce0cfcef9ae57ed0705fe279de0a (diff) | |
download | perl-9969000e1134387c0ed173e5d1b3f3b760a1d00c.tar.gz |
loc_tools.pl: properly load fallback locales
It turns out that some tests using loc_tools.pl are being executed
from a different working directory than './t', which causes
do("./lib/locale/<locale>") to fail.
This fixes lib/warnings.t on Windows.
Discussion:
https://www.nntp.perl.org/group/perl.perl5.porters/2018/01/msg248652.html
Diffstat (limited to 't/loc_tools.pl')
-rw-r--r-- | t/loc_tools.pl | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/t/loc_tools.pl b/t/loc_tools.pl index d9dbfcde0e..fbe7242b1e 100644 --- a/t/loc_tools.pl +++ b/t/loc_tools.pl @@ -363,8 +363,8 @@ sub find_locales ($;$) { # Locales whose name differs if the utf8 bit is on are stored in these # two files with appropriate encodings. my $data_file = ($^H & 0x08 || (${^OPEN} || "") =~ /:utf8/) - ? "./lib/locale/utf8" - : "./lib/locale/latin1"; + ? _source_location() . "/lib/locale/utf8" + : _source_location() . "/lib/locale/latin1"; if (-e $data_file) { @Data = do $data_file; } @@ -487,6 +487,20 @@ sub find_utf8_ctype_locale (;$) { # Return the name of a locale that core Perl return; } +# returns full path to the directory containing the current source +# file, inspired by mauke's Dir::Self +sub _source_location { + require File::Spec; + + my $caller_filename = (caller)[1]; + + return File::Spec->rel2abs( + File::Spec->catpath( + (File::Spec->splitpath($caller_filename))[0, 1] + ) + ); +} + 1 # Format of data is: locale_name, language_codes, country_codes, encodings |