home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / Report.pm < prev    next >
Encoding:
Perl POD Document  |  2002-06-12  |  20.9 KB  |  782 lines

  1. package CPAN::Report;
  2. use Exporter ();
  3. use strict;
  4. use CPAN;
  5. use vars qw(@ISA @EXPORT);
  6. @ISA = qw(Exporter);
  7. @EXPORT = qw(
  8.          autobundle bundle expand force get cvs_import
  9.          install make readme recompile shell test clean cpantest
  10.         );
  11. use Config;
  12. use Getopt::Long;
  13. use MIME::Lite;
  14. use IO::File;
  15. use IO::Tee;
  16. use Cwd;
  17. use vars qw($VERSION);
  18. $VERSION = '0.91';
  19. my $cwd = cwd;
  20. ######################################################
  21. # Configuration section
  22. #####################################################
  23.  
  24. use vars qw($CPAN_testers $From $SMTP_HOST);
  25.  
  26. # The following is where the report is sent
  27. #$CPAN_testers   = 'cpan-testers@perl.org';
  28.  
  29. # The following is your SMTP host, if you use SMTP
  30. #$SMTP_HOST = '';
  31.  
  32. # The following is to set your return address
  33. #$From = 'Whoever <me@wherever>';
  34.  
  35. ######
  36.  
  37.  
  38. $SMTP_HOST = 'smtp.mb.sympatico.ca';
  39.  
  40. $CPAN_testers = 'cpan-testers@perl.org';
  41.  
  42. $From = 'randy@theoryx5.uwinnipeg.ca';
  43. ######
  44. ######################################################
  45. # End of Configuration section
  46. #####################################################
  47.  
  48.  
  49. use vars qw($LAST_MOD $LOG $Report %Grades);
  50.  
  51. $LOG           = $ENV{CPANLOG} ||
  52.   ($ENV{TMPDIR} ? "$ENV{TMPDIR}/LOG.RPT" : 
  53.    "$cwd/LOG.RPT");
  54. $Report         = $ENV{CPANTEST} ||
  55.   ($ENV{TMPDIR} ? "$ENV{TMPDIR}/CPANTEST.RPT" :
  56.    "$cwd/CPANTEST.RPT");
  57.  
  58. %Grades = (     # Legal grades:
  59.     'pass'      => "all tests pass",
  60.     'fail'      => "some tests fail",
  61.     'na'        => "package will not work on this platform",
  62.     'unknown'   => "package did not include tests",
  63. );
  64.  
  65. sub new {
  66.   my $class = shift;
  67.  
  68.   my $self = {
  69.           Grade  => undef,
  70.           Package => undef,
  71.           No_comment => 0, 
  72.           Automatic  => 0,
  73.           CC => [],
  74.           Include => 0,
  75.           headers => {
  76.               To => $CPAN_testers,
  77.               From => $From || undef,
  78.               Subject => undef,
  79.               Cc => undef,
  80.               'X-reported-via' => "CPAN::Report version $VERSION",
  81.              },
  82.          };
  83.     bless $self, $class;
  84. }
  85.  
  86. sub CPAN::Shell::cpantest {
  87.   my $self = shift;
  88.   $self = ref($self) ? $self : CPAN::Report->new();
  89.   unless ($self->{headers}->{From}) {
  90.     $CPAN::Frontend->mywarn(qq{
  91. Please configure \$From in CPAN::Report for your return address.
  92. });
  93.     return;
  94.   }
  95.   my ($Grade, $Module, $Author_email);
  96.   local @ARGV = @_;
  97.   GetOptions(
  98.          'g=s',  \$Grade,
  99.          'm=s',  \$Module,
  100.          'nc',   \$self->{No_comment},
  101.          'auto', \$self->{Automatic},
  102.          'cc' ,  \$Author_email,
  103.          'i',    \$self->{Include}
  104.         ) or do {
  105.           usage();
  106.           return;
  107.         };
  108.   unless ($Grade) {
  109.     usage();
  110.     return;
  111.   }
  112.   unless ($Grades{$Grade}) {
  113.     usage("grade `$Grade' is invalid");
  114.     return;
  115.   }
  116.   $self->{Grade} = $Grade;
  117.   if ($self->{Automatic} and !$Module) {
  118.     usage("-m is required with -auto");
  119.     return;
  120.   }
  121.   $Module = prompt('Module', $LAST_MOD ? $LAST_MOD : '') unless ($Module);
  122.   unless (defined $Module) {
  123.     $CPAN::Frontend->mywarn(qq{
  124. Please specify the module to report on.
  125. });
  126.     return;
  127.   }
  128.   $LAST_MOD = $Module;
  129.   my $mod = CPAN::Shell->expand('Module',$Module);
  130.   unless ($mod) {
  131.     $CPAN::Frontend->mywarn(qq{
  132. No information on module "$Module" is available
  133. });
  134.     return;
  135.   }
  136.   my $cpan_file = $mod->cpan_file;
  137.   if ($cpan_file eq 'N/A' or  $cpan_file =~ /^Contact Author/) {
  138.     $CPAN::Frontend->mywarn(qq{
  139. The distribution file for "$Module" is not on CPAN
  140. });
  141.     return;
  142.   }
  143.   ($self->{Package} = $cpan_file) =~ s!.*/(.*)\.(tar.gz|tgz|zip)$!$1!;
  144.  
  145.   for (@ARGV) {
  146.     my $author = expand_author($_);
  147.     next unless $author;
  148.     push @{$self->{CC}},  $author;
  149.   }
  150.  
  151.   $self->{No_comment} = 1 if $self->{Automatic};
  152.   if ($Author_email) {
  153.     my $dist = $CPAN::META->instance('CPAN::Distribution',$cpan_file);
  154.     my $email = $CPAN::META->instance('CPAN::Author',
  155.                       $dist->cpan_userid
  156.                      )->email;
  157.     if ($email) {
  158.       push @{$self->{CC}}, $email;
  159.     }
  160.     else {
  161.       $CPAN::Frontend->mywarn(qq{
  162. No email address for the author of $Module is known.
  163. });
  164.     }
  165.   }
  166.   
  167.   unless ($self->prepare_Report()) {
  168.     $CPAN::Frontend->mywarn(qq{
  169. Could not prepare the report.
  170. });
  171.     return;
  172.   }
  173.  
  174.   unless ($self->send_Report()) {
  175.     $CPAN::Frontend->mywarn(qq{
  176. The report was *not* sent.
  177. });
  178.   }
  179. }
  180.  
  181. sub CPAN::Distribution::make {
  182.     my($self) = @_;
  183.     $CPAN::Frontend->myprint(sprintf "Running make for %s\n", $self->id);
  184.     # Emergency brake if they said install Pippi and get newest perl
  185.     if ($self->isa_perl) {
  186.       if (
  187.       $self->called_for ne $self->id &&
  188.           ! $self->{force_update}
  189.      ) {
  190.         # if we die here, we break bundles
  191.     $CPAN::Frontend->mywarn(sprintf qq{
  192. The most recent version "%s" of the module "%s"
  193. comes with the current version of perl (%s).
  194. I\'ll build that only if you ask for something like
  195.     force install %s
  196. or
  197.     install %s
  198. },
  199.                    $CPAN::META->instance(
  200.                              'CPAN::Module',
  201.                              $self->called_for
  202.                             )->cpan_version,
  203.                    $self->called_for,
  204.                    $self->isa_perl,
  205.                    $self->called_for,
  206.                    $self->id);
  207.         sleep 5; return;
  208.       }
  209.     }
  210.     $self->get;
  211.   EXCUSE: {
  212.     my @e;
  213.     $self->{archived} eq "NO" and push @e,
  214.     "Is neither a tar nor a zip archive.";
  215.  
  216.     $self->{unwrapped} eq "NO" and push @e,
  217.     "had problems unarchiving. Please build manually";
  218.  
  219.     exists $self->{writemakefile} &&
  220.         $self->{writemakefile} =~ m/ ^ NO\s* ( .* ) /sx and push @e,
  221.         $1 || "Had some problem writing Makefile";
  222.  
  223.     defined $self->{'make'} and push @e,
  224.             "Has already been processed within this session";
  225.  
  226.         exists $self->{later} and length($self->{later}) and
  227.             push @e, $self->{later};
  228.  
  229.     $CPAN::Frontend->myprint(join "", map {"  $_\n"} @e) and return if @e;
  230.     }
  231.     $CPAN::Frontend->myprint("\n  CPAN.pm: Going to build ".$self->id."\n\n");
  232.     my $builddir = $self->dir;
  233.     chdir $builddir or Carp::croak("Couldn't chdir $builddir: $!");
  234.     $self->debug("Changed directory to $builddir") if $CPAN::DEBUG;
  235.  
  236.     if ($^O eq 'MacOS') {
  237.         ExtUtils::MM_MacOS::make($self);
  238.         return;
  239.     }
  240.  
  241.     my $system;
  242.     if ($self->{'configure'}) {
  243.       $system = $self->{'configure'};
  244.     } else {
  245.     my($perl) = $self->perl or die "Couldn\'t find executable perl\n";
  246.     my $switch = "";
  247. # This needs a handler that can be turned on or off:
  248. #    $switch = "-MExtUtils::MakeMaker ".
  249. #        "-Mops=:default,:filesys_read,:filesys_open,require,chdir"
  250. #        if $] > 5.00310;
  251.     $system = "$perl $switch Makefile.PL $CPAN::Config->{makepl_arg}";
  252.     }
  253.     unless (exists $self->{writemakefile}) {
  254.     local($SIG{ALRM}) = sub { die "inactivity_timeout reached\n" };
  255.     my($ret,$pid);
  256.     $@ = "";
  257.     if ($CPAN::Config->{inactivity_timeout}) {
  258.         eval {
  259.         alarm $CPAN::Config->{inactivity_timeout};
  260.         local $SIG{CHLD}; # = sub { wait };
  261.         if (defined($pid = fork)) {
  262.             if ($pid) { #parent
  263.             # wait;
  264.             waitpid $pid, 0;
  265.             } else {    #child
  266.               # note, this exec isn't necessary if
  267.               # inactivity_timeout is 0. On the Mac I'd
  268.               # suggest, we set it always to 0.
  269.               exec $system;
  270.             }
  271.         } else {
  272.             $CPAN::Frontend->myprint("Cannot fork: $!");
  273.             return;
  274.         }
  275.         };
  276.         alarm 0;
  277.         if ($@){
  278.         kill 9, $pid;
  279.         waitpid $pid, 0;
  280.         $CPAN::Frontend->myprint($@);
  281.         $self->{writemakefile} = "NO $@";
  282.         $@ = "";
  283.         return;
  284.         }
  285.     } else {
  286.       $ret = system($system);
  287.       if ($ret != 0) {
  288.         $self->{writemakefile} = "NO Makefile.PL returned status $ret";
  289.         return;
  290.       }
  291.     }
  292.     if (-f "Makefile") {
  293.       $self->{writemakefile} = "YES";
  294.           delete $self->{make_clean}; # if cleaned before, enable next
  295.     } else {
  296.       $self->{writemakefile} =
  297.           qq{NO Makefile.PL refused to write a Makefile.};
  298.       # It's probably worth to record the reason, so let's retry
  299.       # local $/;
  300.       # my $fh = IO::File->new("$system |"); # STDERR? STDIN?
  301.       # $self->{writemakefile} .= <$fh>;
  302.     }
  303.     }
  304.     if ($CPAN::Signal){
  305.       delete $self->{force_update};
  306.       return;
  307.     }
  308.     if (my @prereq = $self->unsat_prereq){
  309.       return 1 if $self->follow_prereqs(@prereq); # signal success to the queuerunner
  310.     }
  311.     $CPAN::Report::LAST_MOD = $self->called_for;
  312.      $system = join " ", $CPAN::Config->{'make'}, $CPAN::Config->{make_arg};
  313.     my($stderr) = $^O =~ /Win/i ? "" : " 2>&1 ";
  314. #################################################################
  315. # Added Sep 18, 2001
  316. # invoke "$system" via a pipe, as in CPAN::Distribution::install,
  317. # so that it can be captured by CPAN::Report in a log file
  318.     my($pipe) = FileHandle->new("$system $stderr |");
  319.     my $tee = new IO::Tee(\*STDOUT, new IO::File(">$LOG"));
  320.     select($tee);
  321.     while (<$pipe>){
  322.     $CPAN::Frontend->myprint($_);
  323.     }
  324.     $pipe->close;
  325.     if ($?==0) {
  326. #    if (system($system) == 0) {
  327. # end addition
  328. #################################################################
  329.      $CPAN::Frontend->myprint("  $system -- OK\n");
  330.      $self->{'make'} = "YES";
  331.     } else {
  332.      $self->{writemakefile} ||= "YES";
  333.      $self->{'make'} = "NO";
  334.      $CPAN::Frontend->myprint("  $system -- NOT OK\n");
  335.     }
  336.     select(STDOUT);
  337. }
  338.  
  339. sub CPAN::Distribution::test {
  340.     my($self) = @_;
  341.     $self->make;
  342.     if ($CPAN::Signal){
  343.       delete $self->{force_update};
  344.       return;
  345.     }
  346.     $CPAN::Frontend->myprint("Running make test\n");
  347.     if (my @prereq = $self->unsat_prereq){
  348.       return 1 if $self->follow_prereqs(@prereq); # signal success to the queuerunner
  349.     }
  350.   EXCUSE: {
  351.     my @e;
  352.     exists $self->{make} or exists $self->{later} or push @e,
  353.     "Make had some problems, maybe interrupted? Won't test";
  354.  
  355.     exists $self->{'make'} and
  356.         $self->{'make'} eq 'NO' and
  357.         push @e, "Can't test without successful make";
  358.  
  359.     exists $self->{build_dir} or push @e, "Has no own directory";
  360.         $self->{badtestcnt} ||= 0;
  361.         $self->{badtestcnt} > 0 and
  362.             push @e, "Won't repeat unsuccessful test during this command";
  363.  
  364.         exists $self->{later} and length($self->{later}) and
  365.             push @e, $self->{later};
  366.  
  367.     $CPAN::Frontend->myprint(join "", map {"  $_\n"} @e) and return if @e;
  368.     }
  369.     chdir $self->{'build_dir'} or
  370.     Carp::croak("Couldn't chdir to $self->{'build_dir'}");
  371.     $self->debug("Changed directory to $self->{'build_dir'}")
  372.     if $CPAN::DEBUG;
  373.  
  374.     if ($^O eq 'MacOS') {
  375.         ExtUtils::MM_MacOS::make_test($self);
  376.         return;
  377.     }
  378.  
  379.     $CPAN::Report::LAST_MOD = $self->called_for;
  380.     my $system = join " ", $CPAN::Config->{'make'}, "test";
  381.     my($stderr) = $^O =~ /Win/i ? "" : " 2>&1 ";
  382. #################################################################
  383. # Added Sep 18, 2001
  384. # invoke "$system" via a pipe, as in CPAN::Distribution::install,
  385. # so that it can be captured by CPAN::Test in a log file
  386.     my($pipe) = FileHandle->new("$system $stderr |");
  387.     my $tee = new IO::Tee(\*STDOUT, new IO::File(">$LOG"));
  388.     select($tee);
  389.     while (<$pipe>){
  390.     $CPAN::Frontend->myprint($_);
  391.     }
  392.     $pipe->close;
  393. #    if (system($system) == 0) {
  394. # end addition
  395. #################################################################
  396.     if ($?==0) {
  397.      $CPAN::Frontend->myprint("  $system -- OK\n");
  398.      $self->{make_test} = "YES";
  399.     } else {
  400.      $self->{make_test} = "NO";
  401.          $self->{badtestcnt}++;
  402.      $CPAN::Frontend->myprint("  $system -- NOT OK\n");
  403.     }
  404.     select(STDOUT);
  405. }
  406.  
  407. #-> sub CPAN::Distribution::install ;
  408. sub CPAN::Distribution::install {
  409.     my($self) = @_;
  410.     $self->test;
  411.     if ($CPAN::Signal){
  412.       delete $self->{force_update};
  413.       return;
  414.     }
  415.     $CPAN::Frontend->myprint("Running make install\n");
  416.   EXCUSE: {
  417.     my @e;
  418.     exists $self->{build_dir} or push @e, "Has no own directory";
  419.  
  420.     exists $self->{make} or exists $self->{later} or push @e,
  421.     "Make had some problems, maybe interrupted? Won't install";
  422.  
  423.     exists $self->{'make'} and
  424.         $self->{'make'} eq 'NO' and
  425.         push @e, "make had returned bad status, install seems impossible";
  426.  
  427.     push @e, "make test had returned bad status, ".
  428.         "won't install without force"
  429.         if exists $self->{'make_test'} and
  430.         $self->{'make_test'} eq 'NO' and
  431.         ! $self->{'force_update'};
  432.  
  433.     exists $self->{'install'} and push @e,
  434.     $self->{'install'} eq "YES" ?
  435.         "Already done" : "Already tried without success";
  436.  
  437.         exists $self->{later} and length($self->{later}) and
  438.             push @e, $self->{later};
  439.  
  440.     $CPAN::Frontend->myprint(join "", map {"  $_\n"} @e) and return if @e;
  441.     }
  442.     chdir $self->{'build_dir'} or
  443.     Carp::croak("Couldn't chdir to $self->{'build_dir'}");
  444.     $self->debug("Changed directory to $self->{'build_dir'}")
  445.     if $CPAN::DEBUG;
  446.  
  447.     if ($^O eq 'MacOS') {
  448.         ExtUtils::MM_MacOS::make_install($self);
  449.         return;
  450.     }
  451.  
  452.     $CPAN::Report::LAST_MOD = $self->called_for;
  453.     my $system = join(" ", $CPAN::Config->{'make'},
  454.               "install", $CPAN::Config->{make_install_arg});
  455.     my($stderr) = $^O =~ /Win/i ? "" : " 2>&1 ";
  456.     my($pipe) = FileHandle->new("$system $stderr|");
  457.     my($makeout) = "";
  458.     my $tee = new IO::Tee(\*STDOUT, new IO::File(">$LOG"));
  459.     select($tee);
  460.     while (<$pipe>){
  461.     $CPAN::Frontend->myprint($_);
  462.     $makeout .= $_;
  463.     }
  464.     $pipe->close;
  465.     if ($?==0) {
  466.      $CPAN::Frontend->myprint("  $system -- OK\n");
  467.      return $self->{'install'} = "YES";
  468.     } else {
  469.      $self->{'install'} = "NO";
  470.      $CPAN::Frontend->myprint("  $system -- NOT OK\n");
  471.      if ($makeout =~ /permission/s && $> > 0) {
  472.          $CPAN::Frontend->myprint(qq{    You may have to su }.
  473.                       qq{to root to install the package\n});
  474.      }
  475.     }
  476.     delete $self->{force_update};
  477.     select(STDOUT);
  478. }
  479.  
  480. ### End of main program; subroutines follow
  481.  
  482.  
  483. sub ask_cc {
  484.   my $cc = prompt('CC', 'none');
  485.   
  486.   return ($cc eq 'none') ? undef : expand_author($cc);
  487. }
  488.  
  489.  
  490. # Given an author identifier (either a CPAN authorname or a proper
  491. # email address), return a proper email address.
  492. sub expand_author {
  493.   my ($author)    = @_;
  494.   
  495.   if ($author =~ /^[-A-Z]+$/) {   # Smells like a CPAN authorname
  496.     
  497.     my $email = $CPAN::META->instance("CPAN::Author", $author)->email;
  498.     if ($email) {
  499.       return $email;
  500.     }
  501.     else {
  502.       $CPAN::Frontend->mywarn(qq{
  503. No email address for "$author" is known.
  504. });
  505.       return undef;
  506.     }
  507.   }
  508.     elsif ($author =~ /^\S+@[a-zA-z0-9\.-]+$/) {
  509.       return $author;
  510.     }
  511.   
  512.   return undef;
  513. }
  514.  
  515.  
  516. # Prompt for a new value for $label, given $default; return the user's
  517. # selection.
  518. sub prompt {
  519.   my ($label, $default)   = @_;
  520.   
  521.   $CPAN::Frontend->mywarn(qq{
  522. $label [$default]: });
  523.   my $input = scalar <STDIN>;
  524.   chomp $input;
  525.   
  526.   return (length $input) ? $input : $default;
  527. }
  528.  
  529.  
  530. sub usage {
  531.   my ($message)   = @_;
  532.   
  533.   $CPAN::Frontend->mywarn(qq{
  534. Error:  $message
  535. }) if defined $message;
  536.   $CPAN::Frontend->mywarn(qq{
  537. Usage:
  538.   cpantest  -g grade [ -nc ] [ -auto ] [ -m module ]
  539.               [ -cc ] [ -i ] [ email-addresses ]
  540.  
  541.   -g grade  Indicates the status of the tested package.
  542.             Possible values for grade are:
  543. });
  544.   $CPAN::Frontend->mywarn(sprintf qq{
  545.               %-10s  %s}, $_, $Grades{$_}) for (keys %Grades);
  546.   
  547.   $CPAN::Frontend->mywarn(qq{
  548.  
  549.   -m module  Specify the name of the module tested.
  550.   -nc        No comments on the package are needed.
  551.   -auto      Autosubmission (non-interactive); implies -nc.
  552.   -cc        Send a copy of the report to the module author
  553.   -i         Include a transcript of the last make/test/install session
  554. }); 
  555.   return;
  556. }
  557.  
  558. sub prepare_Report {
  559.   my $self = shift;
  560.   my $comment_marker = $self->{No_comment} ? '' :
  561.     q{--
  562. [ insert comments here ]
  563.       
  564. };
  565.   
  566.   
  567.   ### Compose report:
  568.   unless (open (REPORT, ">$Report")) {
  569.     $CPAN::Frontend->mywarn(qq{
  570. Could not open $Report: $!
  571. });
  572.     return undef;
  573.   }
  574.   print REPORT <<"EOF";
  575. This distribution has been tested as part of the cpan-testers
  576. effort to test as many new uploads to CPAN as possible.
  577. See http://testers.cpan.org/.
  578.  
  579. Please cc any replies to cpan-testers\@perl.org to keep other
  580. test volunteers informed and to prevent duplicate effort.
  581. $comment_marker  
  582. EOF
  583.   if ($self->{Include}) {
  584.     unless (open (LOG, $LOG)) {
  585.       $CPAN::Frontend->mywarn(qq{
  586. Could not open $LOG: $!});
  587.     return undef;
  588.     }
  589.     print REPORT "\n-- \n" if $self->{No_comment};
  590.     print REPORT $_ while (<LOG>);
  591.     close LOG;
  592.   }
  593.   print REPORT "\n-- \n\n";
  594.   print REPORT Config::myconfig();
  595.   close REPORT;
  596.   
  597.   unless ($self->{No_comment}) {
  598.     my $editor  = $ENV{VISUAL} || $ENV{EDITOR} || $ENV{EDIT}
  599.       || ($^O eq 'VMS'     and "edit/tpu")
  600.     || ($^O eq 'MSWin32' and 'notepad.exe')
  601.       || 'vi';
  602.     
  603.     $editor = prompt('Editor', $editor);
  604.     my $file = $Report;
  605.     $file =~ tr!/!\\! if $^O eq 'MSWin32';
  606.     if (system "$editor $file") {
  607.       $CPAN::Frontend->mywarn(qq{
  608. The editor "$editor" could not be run
  609. });
  610.       return undef;
  611.     }
  612.     unless (scalar @{$self->{CC}}) {
  613.       my $cc = ask_cc();
  614.       push @{$self->{CC}}, $cc if $cc;
  615.     }
  616.   }
  617.   return 1;
  618. }
  619.  
  620. sub send_Report {
  621.   my $self = shift;
  622.   $self->{headers}->{Subject} = uc($self->{Grade}) 
  623.     . " $self->{Package} $Config{archname} $Config{osvers}";
  624.  
  625.   my $number = scalar @{$self->{CC}};
  626.   $self->{headers}->{Cc} =  $number > 0 ? 
  627.     ($number == 1 ? $self->{CC}->[0] :
  628.       join ', ', @{$self->{CC}} ) : undef;
  629.  
  630.   unless ($self->{Automatic}) {
  631.     $self->{headers}->{Subject} = 
  632.       prompt('Subject', $self->{headers}->{Subject});
  633.     
  634.     for (sort keys %{$self->{headers}}) {
  635.       if (! $self->{headers}->{$_}) {
  636.     delete $self->{headers}->{$_};
  637.     next;
  638.       }
  639.     $CPAN::Frontend->mywarn(qq{
  640. $_:  $self->{headers}->{$_}}) ;
  641.     }
  642.  
  643.     if (prompt("\nSend/Ignore", 'Ignore') !~ /^[Ss]/) {
  644.       $CPAN::Frontend->mywarn(qq{
  645. Ignoring message.});
  646.       return undef;
  647.     }
  648.   }
  649.  
  650.   MIME::Lite->send('smtp', $SMTP_HOST, Timeout => 60) if $SMTP_HOST;
  651.  
  652.   my $msg = MIME::Lite->new(%{$self->{headers}}, 
  653.                 Path => $Report, Type => 'TEXT');
  654.   unless ($msg) {
  655.     $CPAN::Frontend->mywarn(qq{
  656. Could not send create message});
  657.     return undef;
  658.   }
  659.   
  660.   unless ($msg->send) {
  661.     $CPAN::Frontend->mywarn(qq{
  662. Could not send message});
  663.     return undef;
  664.   }
  665.   return 1;
  666. }
  667.  
  668. 1;
  669.  
  670. __END__
  671.  
  672. =head1 NAME
  673.  
  674. CPAN::Report - send a report on a module to the cpan-testers list
  675.  
  676. =head1 SYNOPSIS
  677.  
  678.   bash$ perl -MCPAN::Report -e shell
  679.  
  680.   cpan> install Net::FTP
  681.   cpan> cpantest -g pass -m  Net::FTP -nc -cc -i
  682.  
  683. =head1 DESCRIPTION
  684.  
  685. CPAN:Report adds to the CPAN.pm shell the functionality to
  686. send package test results for a particular module to the cpan-testers 
  687. list. See B<http://testers.cpan.org/> for details. It is assumed that the
  688. version of the package being tested is that as reported by CPAN.pm
  689. for the named module.
  690.  
  691. When the CPAN.pm shell is invoked via C<perl -MCPAN::Report -e shell>,
  692. sending a report is done with the C<cpantest> shell command:
  693.  
  694.   cpan> cpantest -g grade [ -nc ] [ -auto ] [ -m module ]
  695.            [ -cc ] [ -i ] [ email-addresses ]
  696.  
  697. where the available options are
  698.  
  699. =over 4
  700.  
  701. =item -g grade
  702.  
  703. C<grade> indicates the success or failure of the package's builtin
  704. tests, and is one of:
  705.  
  706.     grade     meaning
  707.     -----     -------
  708.     pass      all tests included with the package passed
  709.     fail      some tests failed
  710.     na        the package does not work on this platform
  711.     unknown   the package did not include tests
  712.  
  713. =item -m module
  714.  
  715. C<module> is the name of the module being tested.  If not specified
  716. on the command line, you will be prompted for one.
  717.  
  718. =item -nc
  719.  
  720. No comment; you will not be prompted to supply a comment about the
  721. package.
  722.  
  723. =item -auto
  724.  
  725. Autosubmission (non-interactive); you won't be prompted to supply any
  726. information that you didn't provide on the command line.  Implies C<-nc>.
  727.  
  728. =item -cc
  729.  
  730. Include a copy of the report to the author of the module
  731.  
  732. =item -i
  733.  
  734. Include in the report a transcript of the last make/test/install
  735. session done within the shell.
  736.  
  737. =item email-addresses
  738.  
  739. A list of additional email addresses that should be cc:'d in this
  740. report. If such an address matches C< /^[-A-Z]+$/ >, it will
  741. assume this is a CPAN id, and look up the address for you.
  742.  
  743. =back
  744.  
  745. =head1 CONFIGURATION
  746.  
  747. This module requires I<MIME::Lite>, I<Getopt::Long>,
  748. and I<IO::Tee>. Near the top of I<Report.pm> are possible
  749. variables that you might like to change from the values set
  750. at the time of building - these are
  751.  
  752. =over
  753.  
  754. =item $SMTP_HOST
  755.  
  756. Set this to specify an SMTP host to use to send
  757. the report. If this is not set, C<sendmail> will
  758. be used.
  759.  
  760. =item $From
  761.  
  762. Set this to specify your return address in the report.
  763.  
  764. =item $CPAN_testers
  765.  
  766. This specifies where the report should be mailed to.
  767.  
  768. =back
  769.  
  770. =head1 AUTHOR
  771.  
  772. Randy Kobes E<lt>F<randy@theory.uwinnipeg.ca>E<gt>, based on
  773. the C<cpantest> script of Kurt Starsinic E<lt>F<kstar@isinet.com>E<gt>.
  774.  
  775. =head1 COPYRIGHT
  776.  
  777. Copyright (c) 1998 Kurt Starsinic, 2001 Randy Kobes.
  778. This program is free software; you may redistribute it
  779. and/or modify it under the same terms as Perl itself.
  780.  
  781. =cut
  782.