⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 report.pm

📁 source of perl for linux application,
💻 PM
📖 第 1 页 / 共 2 页
字号:
package CPANPLUS::Internals::Report;use strict;use CPANPLUS::Error;use CPANPLUS::Internals::Constants;use CPANPLUS::Internals::Constants::Report;use Data::Dumper;use Params::Check               qw[check];use Module::Load::Conditional   qw[can_load];use Locale::Maketext::Simple    Class => 'CPANPLUS', Style => 'gettext';$Params::Check::VERBOSE = 1;### for the version ###require CPANPLUS::Internals;=head1 NAMECPANPLUS::Internals::Report=head1 SYNOPSIS  ### enable test reporting  $cb->configure_object->set_conf( cpantest => 1 );      ### set custom mx host, shouldn't normally be needed  $cb->configure_object->set_conf( cpantest_mx => 'smtp.example.com' );=head1 DESCRIPTIONThis module provides all the functionality to send test reports toC<http://testers.cpan.org> using the C<Test::Reporter> module.All methods will be called automatically if you have C<CPANPLUS>configured to enable test reporting (see the C<SYNOPSIS>).=head1 METHODS=head2 $bool = $cb->_have_query_report_modulesThis function checks if all the required modules are here for queryingreports. It returns true and loads them if they are, or returns falseotherwise.=head2 $bool = $cb->_have_send_report_modulesThis function checks if all the required modules are here for sendingreports. It returns true and loads them if they are, or returns falseotherwise.=cut### XXX remove this list and move it into selfupdate, somehow..### this is dual administration{   my $query_list = {        'File::Fetch'   => '0.13_02',        'YAML::Tiny'    => '0.0',        'File::Temp'    => '0.0',    };    my $send_list = {        %$query_list,        'Test::Reporter' => '1.34',    };    sub _have_query_report_modules {        my $self = shift;        my $conf = $self->configure_object;        my %hash = @_;        my $tmpl = {            verbose => { default => $conf->get_conf('verbose') },        };        my $args = check( $tmpl, \%hash ) or return;        return can_load( modules => $query_list, verbose => $args->{verbose} )                ? 1                : 0;    }    sub _have_send_report_modules {        my $self = shift;        my $conf = $self->configure_object;        my %hash = @_;        my $tmpl = {            verbose => { default => $conf->get_conf('verbose') },        };        my $args = check( $tmpl, \%hash ) or return;        return can_load( modules => $send_list, verbose => $args->{verbose} )                ? 1                : 0;    }}=head2 @list = $cb->_query_report( module => $modobj, [all_versions => BOOL, verbose => BOOL] )This function queries the CPAN testers database atI<http://testers.cpan.org/> for test results of specified module objects,module names or distributions.The optional argument C<all_versions> controls whether all versions ofa given distribution should be grabbed.  It defaults to false(fetching only reports for the current version).Returns the a list with the following data structures (for CPANPLUSversion 0.042) on success, or false on failure:          {            'grade' => 'PASS',            'dist' => 'CPANPLUS-0.042',            'platform' => 'i686-pld-linux-thread-multi'          },          {            'grade' => 'PASS',            'dist' => 'CPANPLUS-0.042',            'platform' => 'i686-linux-thread-multi'          },          {            'grade' => 'FAIL',            'dist' => 'CPANPLUS-0.042',            'platform' => 'cygwin-multi-64int',            'details' => 'http://nntp.x.perl.org/group/perl.cpan.testers/99371'          },          {            'grade' => 'FAIL',            'dist' => 'CPANPLUS-0.042',            'platform' => 'i586-linux',            'details' => 'http://nntp.x.perl.org/group/perl.cpan.testers/99396'          },The status of the test can be one of the following:UNKNOWN, PASS, FAIL or NA (not applicable).=cutsub _query_report {    my $self = shift;    my $conf = $self->configure_object;    my %hash = @_;    my($mod, $verbose, $all);    my $tmpl = {        module          => { required => 1, allow => IS_MODOBJ,                                store => \$mod },        verbose         => { default => $conf->get_conf('verbose'),                                store => \$verbose },        all_versions    => { default => 0, store => \$all },    };    check( $tmpl, \%hash ) or return;    ### check if we have the modules we need for querying    return unless $self->_have_query_report_modules( verbose => 1 );    ### XXX no longer use LWP here. However, that means we don't    ### automagically set proxies anymore!!!    # my $ua = LWP::UserAgent->new;    # $ua->agent( CPANPLUS_UA->() );    #    ### set proxies if we have them ###    # $ua->env_proxy();    my $url = TESTERS_URL->($mod->package_name);    my $ff  = File::Fetch->new( uri => $url );    msg( loc("Fetching: '%1'", $url), $verbose );    my $res = do {        my $tempdir = File::Temp::tempdir();        my $where   = $ff->fetch( to => $tempdir );                unless( $where ) {            error( loc( "Fetching report for '%1' failed: %2",                        $url, $ff->error ) );            return;        }        my $fh = OPEN_FILE->( $where );                do { local $/; <$fh> };    };    my ($aref) = eval { YAML::Tiny::Load( $res ) };    if( $@ ) {        error(loc("Error reading result: %1", $@));        return;    };    my $dist = $mod->package_name .'-'. $mod->package_version;    my @rv;    for my $href ( @$aref ) {        next unless $all or defined $href->{'distversion'} &&                             $href->{'distversion'} eq $dist;        push @rv, { platform    => $href->{'platform'},                    grade       => $href->{'action'},                    dist        => $href->{'distversion'},                    ( $href->{'action'} eq 'FAIL'                        ? (details => TESTERS_DETAILS_URL->($mod->package_name))                        : ()                    ) };    }    return @rv if @rv;    return;}=pod=head2 $bool = $cb->_send_report( module => $modobj, buffer => $make_output, failed => BOOL, [save => BOOL, address => $email_to, dontcc => BOOL, verbose => BOOL, force => BOOL]);This function sends a testers report to C<cpan-testers@perl.org> for aparticular distribution.It returns true on success, and false on failure.It takes the following options:=over 4=item moduleThe module object of this particular distribution=item bufferThe output buffer from the 'make/make test' process=item failedBoolean indicating if the 'make/make test' went wrong=item saveBoolean indicating if the report should be saved locally instead ofmailed out. If provided, this function will return the location thereport was saved to, rather than a simple boolean 'TRUE'.Defaults to false.=item addressThe email address to mail the report for. You should never need tooverride this, but it might be useful for debugging purposes.Defaults to C<cpan-testers@perl.org>.=item dontccBoolean indicating whether or not we should Cc: the author. If false,previous error reports are inspected and checked if the author shouldbe mailed. If set to true, these tests are skipped and the author isdefinitely not Cc:'d.You should probably not change this setting.Defaults to false.=item verboseBoolean indicating on whether or not to be verbose.Defaults to your configuration settings=item forceBoolean indicating whether to force the sending, even if the maxamount of reports for fails have already been reached, or if youmay already have sent it before.Defaults to your configuration settings=back=cutsub _send_report {    my $self = shift;    my $conf = $self->configure_object;    my %hash = @_;    ### do you even /have/ test::reporter? ###    unless( $self->_have_send_report_modules(verbose => 1) ) {        error( loc( "You don't have '%1' (or modules required by '%2') ".                    "installed, you cannot report test results.",                    'Test::Reporter', 'Test::Reporter' ) );        return;    }    ### check arguments ###    my ($buffer, $failed, $mod, $verbose, $force, $address, $save, $dontcc,        $tests_skipped );    my $tmpl = {            module  => { required => 1, store => \$mod, allow => IS_MODOBJ },            buffer  => { required => 1, store => \$buffer },            failed  => { required => 1, store => \$failed },            address => { default  => CPAN_TESTERS_EMAIL, store => \$address },            save    => { default  => 0, store => \$save },            dontcc  => { default  => 0, store => \$dontcc },            verbose => { default  => $conf->get_conf('verbose'),                            store => \$verbose },            force   => { default  => $conf->get_conf('force'),                            store => \$force },            tests_skipped                       => { default => 0, store => \$tests_skipped },    };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -