diff options
author | James E Keenan <jkeenan@cpan.org> | 2022-01-30 14:18:07 +0000 |
---|---|---|
committer | ℕicolas ℝ <nicolas@atoomic.org> | 2022-01-30 07:57:19 -0700 |
commit | 4ccd1515c853f1aacf08724b43b8c63a88e407c4 (patch) | |
tree | 8721e1d871a4b118df0f5c0064fa69201eab1502 /cpan | |
parent | ebfc9d5d0d50ffc852e4ae35a78e6a922ada8700 (diff) | |
download | perl-4ccd1515c853f1aacf08724b43b8c63a88e407c4.tar.gz |
Synch in CPAN-2.33-TRIAL
For: https://github.com/Perl/perl5/issues/19358.
Used tarball from:
http://ftp.cpan.org/pub/CPAN/authors/id/A/AN/ANDK/CPAN-2.33-TRIAL.tar.gz
Diffstat (limited to 'cpan')
-rw-r--r-- | cpan/CPAN/lib/App/Cpan.pm | 148 | ||||
-rw-r--r-- | cpan/CPAN/lib/CPAN.pm | 2 | ||||
-rw-r--r-- | cpan/CPAN/lib/CPAN/Distribution.pm | 15 | ||||
-rw-r--r-- | cpan/CPAN/lib/CPAN/FTP.pm | 25 | ||||
-rw-r--r-- | cpan/CPAN/lib/CPAN/FirstTime.pm | 21 | ||||
-rw-r--r-- | cpan/CPAN/scripts/cpan | 4 | ||||
-rw-r--r-- | cpan/CPAN/t/32pushyhttps.t | 129 |
7 files changed, 253 insertions, 91 deletions
diff --git a/cpan/CPAN/lib/App/Cpan.pm b/cpan/CPAN/lib/App/Cpan.pm index efd04331c8..6358e82a03 100644 --- a/cpan/CPAN/lib/App/Cpan.pm +++ b/cpan/CPAN/lib/App/Cpan.pm @@ -6,7 +6,7 @@ use vars qw($VERSION); use if $] < 5.008 => 'IO::Scalar'; -$VERSION = '1.676'; +$VERSION = '1.678'; =head1 NAME @@ -244,9 +244,9 @@ The build tools, L<ExtUtils::MakeMaker> and L<Module::Build> use some, while others matter to the levels above them. Some of these are specified by the Perl Toolchain Gang: -Lancaster Concensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md> +Lancaster Consensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md> -Oslo Concensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md> +Oslo Consensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md> =over 4 @@ -347,10 +347,10 @@ sub GOOD_EXIT () { 0 } # key => [ sub ref, takes args?, exit value, description ] # options that do their thing first, then exit - h => [ \&_print_help, NO_ARGS, GOOD_EXIT, 'Printing help' ], - v => [ \&_print_version, NO_ARGS, GOOD_EXIT, 'Printing version' ], - V => [ \&_print_details, NO_ARGS, GOOD_EXIT, 'Printing detailed version' ], - X => [ \&_list_all_namespaces, NO_ARGS, GOOD_EXIT, 'Listing all namespaces' ], + h => [ \&_print_help, NO_ARGS, GOOD_EXIT, 'Printing help' ], + v => [ \&_print_version, NO_ARGS, GOOD_EXIT, 'Printing version' ], + V => [ \&_print_details, NO_ARGS, GOOD_EXIT, 'Printing detailed version' ], + X => [ \&_list_all_namespaces, NO_ARGS, GOOD_EXIT, 'Listing all namespaces' ], # options that affect other options j => [ \&_load_config, ARGS, GOOD_EXIT, 'Use specified config file' ], @@ -359,7 +359,7 @@ sub GOOD_EXIT () { 0 } I => [ \&_load_local_lib, NO_ARGS, GOOD_EXIT, 'Loading local::lib' ], M => [ \&_use_these_mirrors, ARGS, GOOD_EXIT, 'Setting per session mirrors' ], P => [ \&_find_good_mirrors, NO_ARGS, GOOD_EXIT, 'Finding good mirrors' ], - w => [ \&_turn_on_warnings, NO_ARGS, GOOD_EXIT, 'Turning on warnings' ], + w => [ \&_turn_on_warnings, NO_ARGS, GOOD_EXIT, 'Turning on warnings' ], # options that do their one thing g => [ \&_download, ARGS, GOOD_EXIT, 'Download the latest distro' ], @@ -377,13 +377,13 @@ sub GOOD_EXIT () { 0 } r => [ \&_recompile, NO_ARGS, GOOD_EXIT, 'Recompiling' ], u => [ \&_upgrade, NO_ARGS, GOOD_EXIT, 'Running `make test`' ], - 's' => [ \&_shell, NO_ARGS, GOOD_EXIT, 'Running `make test`' ], + 's' => [ \&_shell, NO_ARGS, GOOD_EXIT, 'Drop into the CPAN.pm shell' ], - 'x' => [ \&_guess_namespace, ARGS, GOOD_EXIT, 'Guessing namespaces' ], + 'x' => [ \&_guess_namespace, ARGS, GOOD_EXIT, 'Guessing namespaces' ], c => [ \&_default, ARGS, GOOD_EXIT, 'Running `make clean`' ], f => [ \&_default, ARGS, GOOD_EXIT, 'Installing with force' ], i => [ \&_default, ARGS, GOOD_EXIT, 'Running `make install`' ], - 'm' => [ \&_default, ARGS, GOOD_EXIT, 'Running `make`' ], + 'm' => [ \&_default, ARGS, GOOD_EXIT, 'Running `make`' ], t => [ \&_default, ARGS, GOOD_EXIT, 'Running `make test`' ], T => [ \&_default, ARGS, GOOD_EXIT, 'Installing with notest' ], ); @@ -483,7 +483,7 @@ sub _setup_environment { $ENV{PERL_MM_USE_DEFAULT} = 1 unless defined $ENV{PERL_MM_USE_DEFAULT}; } -=item run() +=item run( ARGS ) Just do it. @@ -496,8 +496,8 @@ my $logger; sub run { - my $class = shift; - + my( $class, @args ) = @_; + local @ARGV = @args; my $return_value = HEY_IT_WORKED; # assume that things will work $logger = $class->_init_logger; @@ -555,11 +555,11 @@ unless (defined $LL{$LEVEL}){ } sub new { bless \ my $x, $_[0] } sub AUTOLOAD { - my $autoload = our $AUTOLOAD; - $autoload =~ s/.*://; - return if $LL{uc $autoload} < $LL{$LEVEL}; - $CPAN::Frontend->mywarn(">($autoload): $_\n") - for split /[\r\n]+/, $_[1]; + my $autoload = our $AUTOLOAD; + $autoload =~ s/.*://; + return if $LL{uc $autoload} < $LL{$LEVEL}; + $CPAN::Frontend->mywarn(">($autoload): $_\n") + for split /[\r\n]+/, $_[1]; } sub DESTROY { 1 } } @@ -567,24 +567,24 @@ sub DESTROY { 1 } # load a module without searching the default entry for the current # directory sub _safe_load_module { - my $name = shift; + my $name = shift; - local @INC = @INC; - pop @INC if $INC[-1] eq '.'; + local @INC = @INC; + pop @INC if $INC[-1] eq '.'; - eval "require $name; 1"; + eval "require $name; 1"; } sub _init_logger { my $log4perl_loaded = _safe_load_module("Log::Log4perl"); - unless( $log4perl_loaded ) - { - print STDOUT "Loading internal logger. Log::Log4perl recommended for better logging\n"; - $logger = Local::Null::Logger->new; - return $logger; - } + unless( $log4perl_loaded ) + { + print STDOUT "Loading internal logger. Log::Log4perl recommended for better logging\n"; + $logger = Local::Null::Logger->new; + return $logger; + } Log::Log4perl::init( \ <<"HERE" ); log4perl.rootLogger=$LEVEL, A1 @@ -730,21 +730,21 @@ sub _get_cpanpm_last_line my @lines = <$fh>; - # This is a bit ugly. Once we examine a line, we have to - # examine the line before it and go through all of the same - # regexes. I could do something fancy, but this works. - REGEXES: { + # This is a bit ugly. Once we examine a line, we have to + # examine the line before it and go through all of the same + # regexes. I could do something fancy, but this works. + REGEXES: { foreach my $regex ( @skip_lines ) { if( $lines[-1] =~ m/$regex/ ) - { - pop @lines; - redo REGEXES; # we have to go through all of them for every line! - } + { + pop @lines; + redo REGEXES; # we have to go through all of them for every line! + } } } - $logger->debug( "Last interesting line of CPAN.pm output is:\n\t$lines[-1]" ); + $logger->debug( "Last interesting line of CPAN.pm output is:\n\t$lines[-1]" ); $lines[-1]; } @@ -833,15 +833,15 @@ sub _print_details # -V { require CPAN::Mirrors; - if ( $CPAN::Config->{connect_to_internet_ok} ) { - $CPAN::Frontend->myprint(qq{Trying to fetch a mirror list from the Internet\n}); - eval { CPAN::FTP->localize('MIRRORED.BY',File::Spec->catfile($CPAN::Config->{keep_source_where},'MIRRORED.BY'),3,1) } - or $CPAN::Frontend->mywarn(<<'HERE'); + if ( $CPAN::Config->{connect_to_internet_ok} ) { + $CPAN::Frontend->myprint(qq{Trying to fetch a mirror list from the Internet\n}); + eval { CPAN::FTP->localize('MIRRORED.BY',File::Spec->catfile($CPAN::Config->{keep_source_where},'MIRRORED.BY'),3,1) } + or $CPAN::Frontend->mywarn(<<'HERE'); We failed to get a copy of the mirror list from the Internet. You will need to provide CPAN mirror URLs yourself. HERE - $CPAN::Frontend->myprint("\n"); - } + $CPAN::Frontend->myprint("\n"); + } my $mirrors = CPAN::Mirrors->new( _mirror_file() ); my @continents = $mirrors->find_best_continents; @@ -912,21 +912,21 @@ Stolen from File::Path::Expand sub _expand_filename { - my( $path ) = @_; - no warnings 'uninitialized'; - $logger->debug( "Expanding path $path\n" ); - $path =~ s{\A~([^/]+)?}{ + my( $path ) = @_; + no warnings 'uninitialized'; + $logger->debug( "Expanding path $path\n" ); + $path =~ s{\A~([^/]+)?}{ _home_of( $1 || $> ) || "~$1" - }e; - return $path; + }e; + return $path; } sub _home_of { require User::pwent; - my( $user ) = @_; - my $ent = User::pwent::getpw($user) or return; - return $ent->dir; + my( $user ) = @_; + my $ent = User::pwent::getpw($user) or return; + return $ent->dir; } sub _get_default_inc @@ -1033,19 +1033,19 @@ sub _get_ping_report return -e $url->file; } - my( $port ) = $url->port; + my( $port ) = $url->port; - return unless $port; + return unless $port; - if ( $ping->can('port_number') ) { - $ping->port_number($port); - } - else { - $ping->{'port_num'} = $port; - } + if ( $ping->can('port_number') ) { + $ping->port_number($port); + } + else { + $ping->{'port_num'} = $port; + } - $ping->hires(1) if $ping->can( 'hires' ); - my( $alive, $rtt ) = eval{ $ping->ping( $url->host ) }; + $ping->hires(1) if $ping->can( 'hires' ); + my( $alive, $rtt ) = eval{ $ping->ping( $url->host ) }; $alive ? $rtt : undef; } @@ -1284,16 +1284,16 @@ sub _get_changes_file croak "Reading Changes files requires LWP::Simple and URI\n" unless _safe_load_module("LWP::Simple") && _safe_load_module("URI"); - my $url = shift; + my $url = shift; - my $content = LWP::Simple::get( $url ); - $logger->info( "Got $url ..." ) if defined $content; + my $content = LWP::Simple::get( $url ); + $logger->info( "Got $url ..." ) if defined $content; #print $content; my( $change_link ) = $content =~ m|<a href="(.*?)">Changes</a>|gi; my $changes_url = URI->new_abs( $change_link, $url ); - $logger->debug( "Change link is: $changes_url" ); + $logger->debug( "Change link is: $changes_url" ); my $changes = LWP::Simple::get( $changes_url ); @@ -1373,8 +1373,8 @@ sub _show_out_of_date foreach my $module ( @$modules ) { - next unless $module = _expand_module($module); - next unless $module->inst_file; + next unless $module = _expand_module($module); + next unless $module->inst_file; next if $module->uptodate; printf "%-40s %.4f %.4f\n", $module->id, @@ -1479,7 +1479,7 @@ sub _eval_version # split package line to hide from PAUSE my $eval = qq{ package - ExtUtils::MakeMaker::_version; + ExtUtils::MakeMaker::_version; local $sigil$var; \$$var=undef; do { @@ -1519,8 +1519,8 @@ sub _expand_module my( $module ) = @_; my $expanded = CPAN::Shell->expandany( $module ); - return $expanded if $expanded; - $expanded = CPAN::Shell->expand( "Module", $module ); + return $expanded if $expanded; + $expanded = CPAN::Shell->expand( "Module", $module ); unless( defined $expanded ) { $logger->error( "Could not expand [$module]. Check the module name." ); my $threshold = ( @@ -1689,7 +1689,7 @@ but the canonical source is now in the above repo. Japheth Cleaver added the bits to allow a forced install (C<-f>). -Jim Brandt suggest and provided the initial implementation for the +Jim Brandt suggested and provided the initial implementation for the up-to-date and Changes features. Adam Kennedy pointed out that C<exit()> causes problems on Windows @@ -1705,7 +1705,7 @@ brian d foy, C<< <bdfoy@cpan.org> >> =head1 COPYRIGHT -Copyright (c) 2001-2018, brian d foy, All Rights Reserved. +Copyright (c) 2001-2021, brian d foy, All Rights Reserved. You may redistribute this under the same terms as Perl itself. diff --git a/cpan/CPAN/lib/CPAN.pm b/cpan/CPAN/lib/CPAN.pm index d1deccc4e2..19dcad2442 100644 --- a/cpan/CPAN/lib/CPAN.pm +++ b/cpan/CPAN/lib/CPAN.pm @@ -2,7 +2,7 @@ # vim: ts=4 sts=4 sw=4: use strict; package CPAN; -$CPAN::VERSION = '2.29'; +$CPAN::VERSION = '2.33'; $CPAN::VERSION =~ s/_//; # we need to run chdir all over and we would get at wrong libraries diff --git a/cpan/CPAN/lib/CPAN/Distribution.pm b/cpan/CPAN/lib/CPAN/Distribution.pm index cf39833d8a..d346a6bf29 100644 --- a/cpan/CPAN/lib/CPAN/Distribution.pm +++ b/cpan/CPAN/lib/CPAN/Distribution.pm @@ -9,7 +9,7 @@ use File::Path (); use POSIX ":sys_wait_h"; @CPAN::Distribution::ISA = qw(CPAN::InfoObj); use vars qw($VERSION); -$VERSION = "2.29"; +$VERSION = "2.33"; my $run_allow_installing_within_test = 1; # boolean; either in test or in install, there is no third option @@ -1445,8 +1445,14 @@ sub verifyCHECKSUM { local($") = "/"; if (my $size = -s $lc_want) { $self->debug("lc_want[$lc_want]size[$size]") if $CPAN::DEBUG; - if ($self->CHECKSUM_check_file($lc_want,1)) { - return $self->{CHECKSUM_STATUS} = "OK"; + my @stat = stat $lc_want; + my $epoch_starting_support_of_cpan_path = 1637471530; + if ($stat[9] >= $epoch_starting_support_of_cpan_path) { + if ($self->CHECKSUM_check_file($lc_want, 1)) { + return $self->{CHECKSUM_STATUS} = "OK"; + } + } else { + unlink $lc_want; } } $lc_file = CPAN::FTP->localize("authors/id/@local", @@ -1545,9 +1551,10 @@ sub CHECKSUM_check_file { } my $tempfile = File::Spec->catfile($tempdir, "CHECKSUMS.$$"); unlink $tempfile; # ignore missing file + my $devnull = File::Spec->devnull; my $gpg = $CPAN::Config->{gpg} or $CPAN::Frontend->mydie("Your configuration suggests that you do not have 'gpg' installed. This is needed to verify checksums with the config variable 'check_sigs' on. Please configure it with 'o conf init gpg'"); - my $system = "gpg --verify --batch --no-tty --output $tempfile $chk_file 2> /dev/null"; + my $system = qq{"$gpg" --verify --batch --no-tty --output "$tempfile" "$chk_file" 2> "$devnull"}; 0 == system $system or $CPAN::Frontend->mydie("gpg run was failing, cannot continue: $system"); open $fh, $tempfile or $CPAN::Frontend->mydie("Could not open $tempfile: $!"); local $/; diff --git a/cpan/CPAN/lib/CPAN/FTP.pm b/cpan/CPAN/lib/CPAN/FTP.pm index 8193309c27..652f5be774 100644 --- a/cpan/CPAN/lib/CPAN/FTP.pm +++ b/cpan/CPAN/lib/CPAN/FTP.pm @@ -15,7 +15,7 @@ use vars qw($connect_to_internet_ok $Ua $Thesite $ThesiteURL $Themethod); use vars qw( $VERSION ); -$VERSION = "5.5014"; +$VERSION = "5.5016"; sub _plus_append_open { my($fh, $file) = @_; @@ -372,7 +372,10 @@ sub localize_2021 { my @missing_modules = grep { ! $CPAN::META->has_usable($_) } qw(HTTP::Tiny Net::SSLeay IO::Socket::SSL); my $miss = join ", ", map { "'$_'" } @missing_modules; my $modules = @missing_modules == 1 ? "module" : "modules"; - $CPAN::Frontend->mywarn("Missing or unusable $modules $miss, and found neither curl nor wget installed. Need to fall back to http.\n"); + $CPAN::Frontend->mywarn("Missing or unusable $modules $miss, and found neither curl nor wget installed.\n"); + if ($CPAN::META->has_usable('HTTP::Tiny')) { + $CPAN::Frontend->mywarn("Need to fall back to http.\n") + } for my $prx (qw(http_proxy no_proxy)) { $ENV{$prx} = $CPAN::Config->{$prx} if $CPAN::Config->{$prx}; } @@ -399,8 +402,19 @@ sub localize_2021 { sub hostdl_2021 { my($self, $base, $file, $aslocal) = @_; # the $aslocal is $aslocal_tempfile in the caller (old convention) my $proxy_vars = $self->_proxy_vars($base); + my($proto) = $base =~ /^(https?)/; my $url = "$base$file"; - if ($CPAN::META->has_usable('HTTP::Tiny')) { + # hostdl_2021 may be called with either http or https urls + if ( + $CPAN::META->has_usable('HTTP::Tiny') + && + ( + $proto eq "http" + || + ( $CPAN::META->has_usable('Net::SSLeay') + && $CPAN::META->has_usable('IO::Socket::SSL') ) + ) + ){ # mostly c&p from below require CPAN::HTTP::Client; my $chc = CPAN::HTTP::Client->new( @@ -446,13 +460,14 @@ sub hostdl_2021 { my($devnull) = $CPAN::Config->{devnull} || ""; DLPRG: for my $dlprg (qw(curl wget)) { my $dlprg_configured = $CPAN::Config->{$dlprg}; - next unless defined $dlprg_configured; + next unless defined $dlprg_configured && length $dlprg_configured; my $funkyftp = CPAN::HandleConfig->safe_quote($dlprg_configured); if ($dlprg eq "wget") { $src_switch = " -O \"$aslocal\""; $stdout_redir = ""; } elsif ($dlprg eq 'curl') { - $src_switch = ' -L -f -s -S --netrc-optional'; + $src_switch = ' -L -f -s -S --netrc-optional'; + $stdout_redir = " > \"$aslocal\""; if ($proxy_vars->{http_proxy}) { $src_switch .= qq{ -U "$proxy_vars->{proxy_user}:$proxy_vars->{proxy_pass}" -x "$proxy_vars->{http_proxy}"}; } diff --git a/cpan/CPAN/lib/CPAN/FirstTime.pm b/cpan/CPAN/lib/CPAN/FirstTime.pm index 9534c4d55b..8934f4a2c3 100644 --- a/cpan/CPAN/lib/CPAN/FirstTime.pm +++ b/cpan/CPAN/lib/CPAN/FirstTime.pm @@ -11,7 +11,7 @@ use File::Spec (); use CPAN::Mirrors (); use CPAN::Version (); use vars qw($VERSION $auto_config); -$VERSION = "5.5316"; +$VERSION = "5.5317"; =head1 NAME @@ -126,7 +126,7 @@ To considerably speed up the initial CPAN shell startup, it is possible to use Storable to create a cache of metadata. If Storable is not available, the normal index mechanism will be used. -Note: this mechanism is not used when use_sqlite is on and SQLLite is +Note: this mechanism is not used when use_sqlite is on and SQLite is running. Cache metadata (yes/no)? @@ -1381,9 +1381,15 @@ sub init { if ( $CPAN::Config->{install_help} eq 'local::lib' ) { if ( ! @{ $CPAN::Config->{urllist} } ) { $CPAN::Frontend->myprint( - "Skipping local::lib bootstrap because 'urllist' is not configured.\n" + "\nALERT: Skipping local::lib bootstrap because 'urllist' is not configured.\n" ); } + elsif (! $CPAN::Config->{make} ) { + $CPAN::Frontend->mywarn( + "\nALERT: Skipping local::lib bootstrap because 'make' is not configured.\n" + ); + _beg_for_make(); # repetitive, but we don't want users to miss it + } else { $CPAN::Frontend->myprint("\nAttempting to bootstrap local::lib...\n"); $CPAN::Frontend->myprint("\nWriting $configpm for bootstrap...\n"); @@ -1664,12 +1670,17 @@ Windows users may want to follow this procedure when back in the CPAN shell: perl alien_nmake.pl This will install nmake on your system which can be used as a 'make' -substitute. You can then revisit this dialog with +substitute. + +HERE + } + + $CPAN::Frontend->mywarn(<<"HERE"); +You can then retry the 'make' configuration step with o conf init make HERE - } } sub init_cpan_home { diff --git a/cpan/CPAN/scripts/cpan b/cpan/CPAN/scripts/cpan index 4e900b0054..d4f742e288 100644 --- a/cpan/CPAN/scripts/cpan +++ b/cpan/CPAN/scripts/cpan @@ -251,9 +251,9 @@ The build tools, L<ExtUtils::MakeMaker> and L<Module::Build> use some, while others matter to the levels above them. Some of these are specified by the Perl Toolchain Gang: -Lancaster Concensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md> +Lancaster Consensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md> -Oslo Concensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md> +Oslo Consensus: L<https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/oslo-consensus.md> =over 4 diff --git a/cpan/CPAN/t/32pushyhttps.t b/cpan/CPAN/t/32pushyhttps.t new file mode 100644 index 0000000000..2e7ec1f77d --- /dev/null +++ b/cpan/CPAN/t/32pushyhttps.t @@ -0,0 +1,129 @@ +use strict; +use warnings; +use Test::More; + +unless ($ENV{AUTHOR_TEST}) { + my $msg = 'running MinimumVersion test only run when AUTHOR_TEST set'; + plan( skip_all => $msg ); +} + +unshift @INC, './lib', './t'; +require local_utils; +local_utils::cleanup_dot_cpan(); +local_utils::prepare_dot_cpan(); +local_utils::read_myconfig(); +require CPAN::MyConfig; +require CPAN; +CPAN::HandleConfig->load; + +for (qw(HTTP::Tiny Net::SSLeay IO::Socket::SSL)) { + my $has_it = eval "require $_; 1"; + ok $has_it, "found $_" or plan( skip_all => "$_ not available" ); +} + +{ + package CPAN::Shell::tacet; + my $output; + sub init { + $output = ""; + } + sub myprint { + shift; + $output .= shift; + } + sub mydie { + shift; + die shift; + } + *mywarn = *mywarn = \&myprint; + sub output { + $output; + } +} + +sub collect_output { + CPAN::Shell::tacet->init(); + my $command = shift @_; + CPAN::Shell->$command(@_); + return CPAN::Shell::tacet->output(); +} + +$CPAN::Frontend = $CPAN::Frontend = "CPAN::Shell::tacet"; + +require File::Which; +my %HAVE; +for (qw(curl wget)) { + if (my $which = File::Which::which($_)) { + pass $which; + my $o = collect_output ( o => conf => $_ => $which ); + like $o, qr(Please use), "'Please use' on $_" or diag ">>>>$o<<<<"; + $HAVE{$_} = $which; + } else { + plan( skip_all => "$_ not found" ); + } +} + +like collect_output ( o => conf => pushy_https => 1 ), qr(Please use), "'Please use' on pushy_https"; +like collect_output ( o => conf => tar_verbosity => "none" ), qr(Please use), "'Please use' on tar_verbosity"; + +# | HTTP::Tiny | Net::SSLeay+IO::Socket::SSL | curl | wget | proto | +# |------------+-----------------------------+------+------+-------| +# | 1 | 1 | 1 | 1 | https | (1) +# | 1 | 1 | 0 | 0 | https | (2) +# | 1 | 0 | 0 | 0 | http | (3) +# | 0 | 0 | 0 | 0 | - | (4) +# | 0 | 0 | 1 | 0 | https | (5) +# | 0 | 0 | 0 | 1 | https | (6) + +my $getmodule = "CPAN::Test::Dummy::Perl5::Make"; +my $getdistro_qr = qr(CPAN-Test-Dummy-Perl5-Make); + +# 1 +like collect_output ( force => get => $getmodule ), + qr((?s)Fetching with HTTP::Tiny.*https://.+/$getdistro_qr), "saw (1) https with all parties ON"; +ok unlink(CPAN::Shell->expand("Module", $getmodule)->distribution->{localfile}), "unlink tarball"; + +# 2 +like collect_output ( o => conf => curl => "" ), qr(Please use), "'Please use' on curl OFF"; +like collect_output ( o => conf => wget => "" ), qr(Please use), "'Please use' on wget OFF"; +like collect_output ( force => get => $getmodule ), + qr((?s)Fetching with HTTP::Tiny.*https://.+/$getdistro_qr), "saw (2) https with HTTP::Tiny+SSL ON"; +ok unlink(CPAN::Shell->expand("Module", $getmodule)->distribution->{localfile}), "unlink tarball"; + +# 3 +ok delete $CPAN::HAS_USABLE->{"Net::SSLeay"}, "delete Net::SSLeay from %HAS_USABLE"; +ok delete $INC{"Net/SSLeay.pm"}, "delete Net::SSLeay from %INC"; +like collect_output ( o => conf => dontload_list => "Net::SSLeay" ), + qr(Please use), "'Please use' on Net::SSLeay OFF"; +like collect_output ( force => get => $getmodule ), + qr((?si)fall back to http.*fetching with HTTP::Tiny.*http://.+/$getdistro_qr), + "saw (3) http:// with HTTP::Tiny without SSL"; +ok unlink(CPAN::Shell->expand("Module", $getmodule)->distribution->{localfile}), "unlink tarball"; + +# 4 +ok delete $CPAN::HAS_USABLE->{"HTTP::Tiny"}, "delete HTTP::Tiny from %HAS_USABLE"; +ok delete $INC{"HTTP/Tiny.pm"}, "delete HTTP::Tiny from %INC"; +like collect_output ( o => conf => dontload_list => push => "HTTP::Tiny" ), + qr(Please use), "'Please use' on HTTP::Tiny OFF"; +eval { collect_output ( force => get => $getmodule ) }; +my $output = CPAN::Shell::tacet->output; +like $@, qr(Giving up), "saw error 'Giving up'"; +like $output, qr(Missing or unusable module), "saw (4) 'unusable module'"; + +# 5 +like collect_output ( o => conf => curl => $HAVE{curl} ), qr(Please use), "'Please use' on curl ON"; +ok $CPAN::Config->{curl}, "set curl to $CPAN::Config->{curl}"; +like collect_output ( force => get => $getmodule ), + qr((?s)Trying with.*curl.*to get.*https://.+/$getdistro_qr), "saw (5) https with curl ON"; +ok unlink(CPAN::Shell->expand("Module", $getmodule)->distribution->{localfile}), "unlink tarball"; + +# 6 +like collect_output ( o => conf => curl => "" ), qr(Please use), "'Please use' on curl OFF"; +ok !$CPAN::Config->{curl}, "set curl to '$CPAN::Config->{curl}'"; +like collect_output ( o => conf => wget => $HAVE{wget} ), qr(Please use), "'Please use' on wget ON"; +ok $CPAN::Config->{wget}, "set wget to $CPAN::Config->{wget}"; +like collect_output ( force => get => $getmodule ), + qr((?s)Trying with.*wget.*to get.*https://.+/$getdistro_qr), "saw (6) https with wget ON"; +ok unlink(CPAN::Shell->expand("Module", $getmodule)->distribution->{localfile}), "unlink tarball"; + +done_testing; |