diff --git a/.github/workflows/os.yml b/.github/workflows/os.yml index 6293bb68e..3ac51eee2 100644 --- a/.github/workflows/os.yml +++ b/.github/workflows/os.yml @@ -14,7 +14,7 @@ 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: diff --git a/Changes b/Changes index a3fa86e31..a0a5e75c6 100644 --- a/Changes +++ b/Changes @@ -22,6 +22,9 @@ Revision history for Perl extension App::Sqitch (#795)! - Fixed Oracle and Firebird test failures due to incorrect use of `chmod`. Thanks to Slaven ReziΔ‡ for the report and the fix (#807)! + - Updated the locale configuration to fix issues in more recent versions + of Perl, and added tests to ensure that the sqitch CLI executes and + properly emits localized messages. 1.4.0 2023-08-01T23:37:30Z - Fixed Snowflake warehouse and role setup to properly quote identifiers diff --git a/bin/sqitch b/bin/sqitch index e14a01115..89c77f22d 100755 --- a/bin/sqitch +++ b/bin/sqitch @@ -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; diff --git a/t/cli.t b/t/cli.t new file mode 100644 index 000000000..cf4572a17 --- /dev/null +++ b/t/cli.t @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; +use 5.010; +use Test::More tests => 3; +use File::Spec; +use Capture::Tiny qw(:all); + +# LANGUAGE=de_DE.UTF-8 perl -Ilib -CAS -I. bin/sqitch help +my @cli = (qw(-Ilib -CAS -I.), File::Spec->catfile(qw(bin sqitch))); + +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{LANGUAGE} = $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 $stdout, '', 'Should have no STDOUT'; + like $stderr, qr/\A\Q$tc->{err}/, + 'Should have localized error message in STDERR'; + }; +} diff --git a/t/sqitch b/t/sqitch index 350e7fc0a..cf9171dca 100755 --- a/t/sqitch +++ b/t/sqitch @@ -1,14 +1,6 @@ #!/usr/bin/env perl -CAS -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 FindBin; use lib "$FindBin::Bin/../lib"; use App::Sqitch;