My life as mini-pumpking, week 2

I'm half-way through my tenure as Perl release manager of the month. In just two weeks, I'll be releasing Perl 5.13.3 while I'm at OSCON. Here's what I've done so far:

  • Writing a command-line tool to keep perldelta notes for each commit to the core repository in git notes and collate them for me by section to add to the perldelta
  • Writing a command-line tool to propose specific commits for cherry picking back to the Perl 5.12 maintenance branch
  • Actually working through the first week or so of commits for perldelta
  • Applying a lot more patches from the p5p mailing list than I usually do
  • Fixing a couple bugs
  • Cherry picking the commits from 5.12 maintenance needed to "forward-port" the perl5121delta file to blead

I haven't been as diligent about marking up commits as I'd hoped, partly due to personal commitments and partly due to the extra distractions of the CPAN Testers 2.0 release announcement. Now it's a big enough backlog to be intimidating, so I need to pick off small pieces and work through it.

It looks like one of the big changes in Perl 5.13.3 will be updated dual-life modules. Chris (BinGOs) Williams has done a heroic job bringing dual-life modules up to date with the versions on CPAN. That's a great step forward and gives us a long lead time for testing in advance of Perl 5.14.

Posted in perl-programming | Tagged , | 1 Comment

Downloading RT patches from the command line

I love it when people post patches to RT, but I don't really like the work required to download them from the web interface. I know there's an rt command line client somewhere, but the last time I tried it, it didn't work very well for me. Thankfully, with the help of RT::Client::REST, I whipped up a short program that will take a ticket number, pluck my credentials from my .pause file, and save the attachments into the current directory.

#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use autodie;
use Encode qw/decode/;
use Error qw(:try);
use Path::Class;
use RT::Client::REST;
use RT::Client::REST::Ticket;

my %credential = split " ", file($ENV{HOME}, '.pause')->slurp;
my $user = lc $credential{user};
my $pass = $credential{password};
my $id = shift(@ARGV) || die "No ticket # provided";
$id =~ s{^(?:rt#?)}{};
die "Ticket must be an integer" if $id =~ /\D/;

my $rt = RT::Client::REST->new(
  server => 'http://rt.cpan.org/',
  timeout => 30,
);

try {
  $rt->login(username => $user, password => $pass);
} catch Exception::Class::Base with {
  die "problem logging in: ", shift->message;
};

my $ticket;
try {
  $ticket = RT::Client::REST::Ticket->new( rt => $rt, id => $id);
} catch RT::Client::REST::UnauthorizedActionException with {
  print "You are not authorized to view ticket $id\n";
} catch RT::Client::REST::Exception with {
  die "problem getting $id, ", shift->message;
};

try {
  my $iter = $ticket->attachments->get_iterator;
  while ( my $i = $iter->() ) {
    $i->retrieve;
    my $name = $i->file_name or next;
    my $encoding = $i->content_encoding;
    $encoding = '' if $encoding eq 'none';
    my $string = $encoding ?
      decode( $encoding, $i->content, 1 ) : $i->content;
    say "Writing $name";
    file($name)->openw->printflush($string);
  }
} catch RT::Client::REST::Exception with {
  die "problem getting attachments from $id, ", shift->message;
};

This is mostly just some cut/paste/modify work with the relevant synopses in the documentation. There was a little trial-and-error required, particularly in how encoding was being passed through, but it seems to work. I was able to download a patch while connected via ssh, which is exactly what I was looking for.

Update: I fixed a hardcoded "#10" in an error message.

Posted in perl-programming | Tagged , | 9 Comments

Capture-Tiny 0.08

I've released a new version of Capture::Tiny, which now catches exceptions, cleans up file handles, then rethrows the exception. This is the first major bug-fix in a while and was easy to address.

I'm feeling pretty confident that Capture::Tiny is a robust, cross-platform answer for any sort of output capturing. If you'd like to understand why, the slides from my talk, "How (not) to capture output in Perl", provide an explanation of why most other output capture approaches are flawed and why this is the single best tool for the job.

Posted in perl-programming | Tagged , | 4 Comments

File-chdir on Perl 5.13.1

For any Perl developers who use File::chdir, please note that Perl 5.13.1 fixed a bug with tied variables in a way that broke things for File::chdir. The change has been reverted and I expect to see File::chdir passing tests on 5.13.2 when it is released.

In the meantime, I've released a new version of File::chdir that bails out during configuration on 5.13.1 with an explicit error message. This gives NA results during CPAN smoke testing, which is more appropriate than FAIL results.

Posted in perl-programming | Tagged , | Leave a comment

Torture testing CPAN::Meta

To be useful for CPAN indexers like search.cpan.org, the new CPAN::Meta library has to be pretty good at dealing with whatever CPAN can throw at it.

A while ago, I put together a test sample of 15,569 CPAN metadata files from a minicpan repository. I'm happy to report that with the latest release today, CPAN::Meta can handle almost 99% of metafiles found "in the wild". Here is the breakdown:

  • no errors: 11411 (73.29%)
  • fixable errors: 3994 (25.65%)
  • parser errors: 124 (0.80%)
  • missing 'name' or 'version' fields: 32 (0.21%)
  • remaining errors (not fixable): 8 (0.05%)

The "unfixable" errors range from missing mandatory fields deep within the structure that can't be assumed from context to invalid module names or else just strange data that somehow slipped into a metafile.

The "torture" part of the test was partly a test of my own patience, since I was tweaking CPAN::Meta and re-running the test against the 15,000 distributions over and over again. One quick-win worth mentioning was Parallel::Iterator, which let me take advantage of all four cores of my CPU. As expected, it cut the runtime by nearly three-quarters (11.5 seconds vs 38.3 seconds). If anyone is interested in seeing how I used it, my quick-and-dirty CPAN::Meta torture program is available online.

Posted in cpan, perl-programming, toolchain | Tagged , | Leave a comment

© 2009-2010 David Golden All Rights Reserved