-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use locale pragma instead of POSIX::set_locale()
The Pragma is more likely to do the right thing, as confirmed by new tests, which fail with the use of the French locale when using `set_locale` and now succeed with `use locale`.
- Loading branch information
Showing
19 changed files
with
90 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,27 +14,39 @@ jobs: | |
include: | ||
- { icon: 🐧, os: ubuntu, name: Linux } | ||
- { icon: 🍎, os: macos, name: macOS } | ||
- { icon: 🪟, os: windows, name: Windows } | ||
# - { icon: 🪟, os: windows, name: Windows } | ||
name: ${{ matrix.icon }} ${{ matrix.name }} | ||
runs-on: ${{ matrix.os }}-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Setup Perl | ||
id: perl | ||
uses: shogo82148/actions-setup-perl@v1 | ||
with: { perl-version: latest } | ||
- run: perl -V | ||
- if: runner.os == 'Linux' | ||
name: Install Apt Packages | ||
run: sudo apt-get install -qq gettext language-pack-fr language-pack-en aspell-en | ||
- if: runner.os == 'macOS' | ||
name: Install Brew Packages | ||
run: brew install gettext aspell | ||
- if: runner.os == 'Windows' | ||
name: Install Chocolatey Packages | ||
run: choco install poedit | ||
- name: Cache CPAN Modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: local | ||
key: perl-${{ steps.perl.outputs.perl-hash }} | ||
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends ExtUtils::MakeMaker List::MoreUtils::XS | ||
# Remove Locale::TextDomain if https://github.com/gflohr/libintl-perl/issues/7 fixed and released. | ||
- if: ${{ matrix.os == 'windows' }} | ||
run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 Locale::[email protected] | ||
- if: runner.os == 'Windows' | ||
run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 | ||
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile dist/cpanfile | ||
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage | ||
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage Dist::Zilla::LocaleTextDomain | ||
- name: Compile Languages | ||
run: | | ||
dzil authordeps | xargs cpm install --verbose --show-build-log-on-failure --no-test | ||
dzil msg-compile | ||
- name: prove | ||
env: { PERL5LIB: "${{ github.workspace }}/local/lib/perl5" } | ||
run: prove -lrj4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,30 +11,42 @@ jobs: | |
Perl: | ||
strategy: | ||
matrix: | ||
os: [[🐧, ubuntu], [🍎, macos], [🪟, windows]] | ||
os: [[🐧, ubuntu], [🍎, macos]] #, [🪟, windows]] | ||
perl: [ '5.38', '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12' ] | ||
exclude: | ||
- { os: [🪟, windows], perl: '5.12' } # https://github.com/shogo82148/actions-setup-perl/issues/876 | ||
- { os: [🪟, windows], perl: '5.14' } # https://github.com/shogo82148/actions-setup-perl/issues/881 | ||
name: 🧅 Perl ${{ matrix.perl }} on ${{ matrix.os[0] }} ${{ matrix.os[1] }} | ||
runs-on: ${{ matrix.os[1] }}-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Setup Perl | ||
id: perl | ||
uses: shogo82148/actions-setup-perl@v1 | ||
with: { perl-version: "${{ matrix.perl }}" } | ||
- run: perl -V | ||
- if: runner.os == 'Linux' | ||
name: Install Apt Packages | ||
run: sudo apt-get install -qq gettext language-pack-fr language-pack-en aspell-en | ||
- if: runner.os == 'macOS' | ||
name: Install Brew Packages | ||
run: brew install gettext aspell | ||
- if: runner.os == 'Windows' | ||
name: Install Chocolatey Packages | ||
run: choco install poedit | ||
- name: Cache CPAN Modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: local | ||
key: perl-${{ steps.perl.outputs.perl-hash }} | ||
# Remove Locale::TextDomain if https://github.com/gflohr/libintl-perl/issues/7 fixed and released. | ||
- if: ${{ matrix.os[1] == 'windows' }} | ||
run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 Locale::[email protected] | ||
- if: runner.os == 'Windows' | ||
run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Encode Win32::Console::ANSI Win32API::Net Win32::Locale Win32::ShellQuote DateTime::TimeZone::Local::Win32 | ||
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends --cpanfile dist/cpanfile | ||
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage | ||
- run: cpm install --verbose --show-build-log-on-failure --no-test --with-recommends Test::Spelling Test::Pod Test::Pod::Coverage Dist::Zilla::LocaleTextDomain | ||
- name: Compile Languages | ||
run: | | ||
dzil authordeps | xargs cpm install --verbose --show-build-log-on-failure --no-test | ||
dzil msg-compile | ||
- name: prove | ||
env: { PERL5LIB: "${{ github.workspace }}/local/lib/perl5" } | ||
run: prove -lrj4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,6 @@ | ||
#!perl -w -CAS | ||
|
||
# VERSION | ||
use POSIX qw(setlocale); | ||
BEGIN { | ||
if ($^O eq 'MSWin32') { | ||
require Win32::Locale; | ||
setlocale POSIX::LC_ALL, Win32::Locale::get_locale(); | ||
} else { | ||
setlocale POSIX::LC_ALL, ''; | ||
} | ||
} | ||
use locale; | ||
use App::Sqitch; | ||
|
||
exit App::Sqitch->go; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More tests => 3; | ||
use File::Spec; | ||
use Capture::Tiny qw(:all); | ||
|
||
# Run `dzil msg-compile` first! | ||
# LANG=de_DE.UTF-8 perl -Ilib -CAS -I. bin/sqitch help | ||
my @cli = (qw(-Ilib -CAS -I.), File::Spec->catfile(qw(bin sqitch))); | ||
|
||
# Each locale must be installed on the local system. Adding a new lang? Also add | ||
# the relevant language-pack-XX package to os.yml and perl.yml. | ||
for my $tc ( | ||
{ lang => '', err => q{"nonesuch" is not a valid command} }, | ||
{ lang => 'en_US', err => q{"nonesuch" is not a valid command} }, | ||
{ lang => 'fr_FR', err => q{"nonesuch" n'est pas une commande valide} }, | ||
) { | ||
subtest $tc->{lang} || 'default' => sub { | ||
local $ENV{LC_ALL} = "$tc->{lang}.UTF-8" if $tc->{lang}; | ||
|
||
# Test successful run. | ||
my ($stdout, $stderr, $exit) = capture { system $^X, @cli, 'help' }; | ||
is $exit >> 8, 0, 'Should have exited normally'; | ||
like $stdout, qr/\AUsage\b/, 'Should have usage statement in STDOUT'; | ||
is $stderr, '', 'Should have no STDERR'; | ||
|
||
# Test localized error. | ||
($stdout, $stderr, $exit) = capture { system $^X, @cli, 'nonesuch' }; | ||
is $exit >> 8, 2, 'Should have exit val 2'; | ||
is $stdout, '', 'Should have no STDOUT'; | ||
like $stderr, qr/\A\Q$tc->{err}/, | ||
'Should have localized error message in STDERR'; | ||
}; | ||
} |