| 1 | package Test::Smoke::App::ConfigSmoke::MakeOptions; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | |||
| 5 | our $VERSION = '0.002'; | ||
| 6 | |||
| 7 | use Exporter 'import'; | ||
| 8 | our @EXPORT = qw/ config_make_options /; | ||
| 9 | |||
| 10 | use Test::Smoke::App::Options; | ||
| 11 | use Test::Smoke::Util::FindHelpers qw/ whereis /; | ||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | Test::Smoke::App::ConfigSmoke::MakeOptions - Mixin for L<Test::Smoke::App::ConfigSmoke> | ||
| 16 | |||
| 17 | =head1 DESCRIPTION | ||
| 18 | |||
| 19 | These methods will be added to the L<Test::Smoke::App::ConfigSmoke> class. | ||
| 20 | |||
| 21 | =head2 config_make_options | ||
| 22 | |||
| 23 | Configure options C<makeopt>, C<testmake>, C<harnessonly>, C<hasharness3> and C<harness3opts>. | ||
| 24 | |||
| 25 | Also C<force_c_locale>, C<locale>, C<defaultenv> | ||
| 26 | |||
| 27 | Also C<skip_tests> | ||
| 28 | |||
| 29 | =cut | ||
| 30 | |||
| 31 | sub config_make_options { | ||
| 32 | my $self = shift; | ||
| 33 | |||
| 34 | print "\n-- make all / make test section --\n"; | ||
| 35 | $self->current_values->{hasharness3} = 1; | ||
| 36 | |||
| 37 | my @options = qw/ makeopt testmake harnessonly /; | ||
| 38 | for my $opt (@options) { | ||
| 39 | my $option = Test::Smoke::App::Options->$opt; | ||
| 40 | $self->handle_option($option); | ||
| 41 | } | ||
| 42 | if ($self->current_values->{harnessonly} || $^O eq 'MSWin32') { | ||
| 43 | $self->handle_option(Test::Smoke::App::Options->harness3opts); | ||
| 44 | } | ||
| 45 | $self->handle_option(Test::Smoke::App::Options->force_c_locale); | ||
| 46 | if ( $^O ne 'MSWin32' ) { | ||
| 47 | $self->handle_option(Test::Smoke::App::Options->defaultenv); | ||
| 48 | if (! $self->current_values->{defaultenv}) { | ||
| 49 | $self->handle_option(Test::Smoke::App::Options->perlio_only); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | else { | ||
| 53 | $self->current_values->{defaultenv} = 1; | ||
| 54 | } | ||
| 55 | if (! $self->current_values->{defaultenv} ) { | ||
| 56 | my @locales = _utf8_locales(); | ||
| 57 | if (@locales) { | ||
| 58 | my $list = join(" |", @locales); | ||
| 59 | { # It's still a format... | ||
| 60 | no warnings 'uninitialized'; | ||
| 61 | local ($:, $^A) = ("|"); | ||
| 62 | formline('^' . ('<' x 66) . "~~\n" , $list); | ||
| 63 | print "\nI found these UTF-8 locales:\n$^A"; | ||
| 64 | } | ||
| 65 | |||
| 66 | $self->handle_option(Test::Smoke::App::Options->locale); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | my $skip_tests = $self->handle_option(Test::Smoke::App::Options->skip_tests); | ||
| 71 | if ($skip_tests and !-f $skip_tests) { | ||
| 72 | if (open(my $fh, '>', $skip_tests)) { | ||
| 73 | print {$fh} "# One test name per line\n"; | ||
| 74 | close($fh); | ||
| 75 | print " >> Created '$skip_tests'\n"; | ||
| 76 | } | ||
| 77 | else { | ||
| 78 | print "!!!!!\nProblem: Cannot create($skip_tests): $!\n!!!!!\n"; | ||
| 79 | print "Please, fix this yourself.\n"; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | sub _utf8_locales { | ||
| 85 | # I only know one way... and one for Darwin (perhaps FreeBSD) | ||
| 86 | if ( $^O =~ /darwin|bsd/i ) { | ||
| 87 | opendir(my $dh, '/usr/share/locale') or return; | ||
| 88 | my @list = grep { m/utf-?8$/i } readdir($dh); | ||
| 89 | closedir($dh); | ||
| 90 | return @list; | ||
| 91 | } | ||
| 92 | my $locale = whereis( 'locale' ); | ||
| 93 | return unless $locale; | ||
| 94 | return grep { m/utf-?8$/i } split(m/\n/, qx/$locale -a/); | ||
| 95 | } | ||
| 96 | |||
| 97 | 1; | ||
| 98 | |||
| 99 | =head1 COPYRIGHT | ||
| 100 | |||
| 101 | (c) 2020, All rights reserved. | ||
| 102 | |||
| 103 | * Abe Timmerman <abeltje@cpan.org> | ||
| 104 | |||
| 105 | This library is free software; you can redistribute it and/or modify | ||
| 106 | it under the same terms as Perl itself. | ||
| 107 | |||
| 108 | See: | ||
| 109 | |||
| 110 | =over 4 | ||
| 111 | |||
| 112 | =item * L<http://www.perl.com/perl/misc/Artistic.html> | ||
| 113 | |||
| 114 | =item * L<http://www.gnu.org/copyleft/gpl.html> | ||
| 115 | |||
| 116 | =back | ||
| 117 | |||
| 118 | This program is distributed in the hope that it will be useful, | ||
| 119 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 120 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 121 | |||
| 122 | =cut |