このページは大阪弁化フィルタによって翻訳生成されたんですわ。

翻訳前ページへ


blogs.perl.org - blogging the onion
The Wayback Machine - http://web.archive.org/web/20100804221623/http://blogs.perl.org:80/

I ? perlbrew

I love perlbrew! I like to keep the version of Perl that I normally use as up-to-date as possible, but it's nice to keep other versions around for compatibility. Just now, I needed to know when readline got fixed. With perlbrew, it was faster to check directly than it was to look it up!

$ cat >> VentureBros
Hank
Dean
Brock
$ perlbr…

YAPC::EU::2010 - First Morning

I am at YAPC::EU::2010 and I would like to congratulate the Italian organization. Everything is going smoothly. Just a few itches (like the fact of the chairs not being comfortable to be more than half an hour listening to somebody).

For now I watched two presentations:


  • Larry Wall and the state of the onion was fun. Larry had his conscience represented by his wife (Gl?ria) and one of his sons? (not sure). Unfortunately it was not easy to understand by non-native English speakers, as the talk was more talk and slides. Nevertheless, a keynote by Larry is, always,…

SF.pm grant funding proposal to TPF up for public review

A grant proposal I wrote for SF.pm is up for public review. All views welcome - http://news.perlfoundation.org/2010/08/2010q3-grant-proposal-sfpm-fun.html

Your Test Suite is Broken

Here are some indicators that your test suite is broken:

  • It has any failing tests.
  • It emits anything other than test information.
  • It takes too long to run.

People are going to have issues with the second item on that list but they're definitely going to argue with that last one. I don't care. It's time to throw the gauntlet down. Let's look at these three points in detail.

A Matrix Worthy of Perl 6

The Problem

use strict; use warnings; use Math::MatrixReal; my $x = 1; my $m = Math::MatrixReal->new_from_rows([ [$x, 2*$x], [3*$x, 4*$x] ]); for(; $x 4; ++$x) { print "$m\n"; }

The output of this code is:
[  1.000000000000E+00  2.000000000000E+00 ]
[  3.000000000000E+00  4.000000000000E+00 ]

[  1.000000000000E+00  2.000000000000E+00 ]
[  3.000000000000E+…

At the airport en route to YAPC::EU

After a while of loose planning, while working on 20 other things at the same time, we've finally left for the airport. We've taken 4 hours in advanced so we don't worry about delays.

We've reached the airport and got to the terminal so quickly that it left us quite a lot of time. One of the people at the border checkup asked me which metal festival am I going to. "A Perl conference" - "what?" - "computer stuff" - "oh..", "surprised?" - "hell yeah!" I suppose a lot of tattoos give that impression. :)

Unfortunately there isn't much to do here. There's internet connection so I …

A new way to create error free software

After too many failing cpanreports for perl-compiler releases I'll finally unify my failing test results into manable code of todo logic. Automatically.

Test::TAP::Unify at http://gist.github.com/506341

NAME

Test::TAP::Unify - Create a minimal set of TODO code for a set of test results

SYNOPSIS

rm log.test-* os=$(uname -o) for p in 5.10.1 5.10.1-nt 5.12.1 5.12.1d 5.12.1d-nt 5.13.3 \ 5.13.3d 5.13.3-nt do perl$p Makefile.PL make test >log.test-$os-$p done

use Test::TAP::Unify; # take features from test filenames or test comments my $features = {debugging => qr/\dd/, threads => qr/-nt/, os => qr/log.test-(\w+)-/, version => qr/(5.[\d.]+/)}; my $t = Test::TAP::Unify->new(filename => $features, comment => $name); my $u = $t->parse();

# prints the complete test matrix print $u->matrix;

# prints @TODO lists as test.pl code snippet print $u->todo->code('PUSH', 'index'); # as PUSH'ed lists of test indices

my $m = Test::TAP::Unify->new ( filenames => {debugging => qr/\dd/, threads => qr/-nt/, os => qr/log.modules-(\w+)-/, version => qr/(5.[\d.]+/)}, comment => {module => qr/(pass|fail) (\S+)/}) ->parse(); print $m->matrix; # all results print $m->todo->code('IF', 'module'); # as IF checked lists for module lists

DESCRIPTION

You hate failing tests, you get a set of test results per perl version by yourself, and also gathered by cpantesters. So you can mark all failing tests as TODO check tickets, and release a new version, where all tests pass. Great! Error free software.

Really, for more complicated XS modules with some randomly failing tests you need to keep TODO lists uptodate. Just to see regressions.

This modules was written to unify test results of the perl compiler L, you will get tired to mark TODO tests manually after each feature change or added platform or perl version you are testing against. It will give you insights which feature might cause the damage. You can e.g. mark tests with any feature name and check them with this module.

Test::TAP::Unify reads the output of make test (TAP results), detects features by various methods, e.g. the filename where make test is logged to, or the test comments and tries to find the minmal set of failing tests per feature. The shortest set of feature-fail combination. Since you have an arbitrary long list of features - typically: version, threads, os, debugging, cc - producing this set is not trivial.

The sets can be printed as matrix, or as code, lists of @TODO with added feature logic. Each test is indexed by number 1..plan.

Sample output for todo->code('PUSH', 'index')

sub is_todo { my @TODO; @TODO = (15,39,44); @TODO = (39) if !$ITHREADS; @TODO = (15,41..45) if $version < 5.007; @TODO = (39,41,44) if $version >= 5.010; @TODO = (15,29,39,44) if $version >= 5.010 and !$ITHREADS; push @TODO, (27) if $version >= 5.012 and $ITHREADS; push @TODO, (6,8..10,16,21,23,24,26,30,31,35) if $version >= 5.013002; push @TODO, (15,25,42..43) if $version >= 5.013 and $ITHREADS; return @TODO; }

Sample output for todo->code('IF', 'module')

sub istodo { my ($module, $version, $name, $threads) = @; foreach (qw(ExtUtils::MakeMaker LWP Attribute::Handlers MooseX::Types)) { return 'generally' if $_ eq $module; } if ($] < 5.007) { foreach(qw( ExtUtils::CBuilder Sub::Name)) { return '< 5.007' if $_ eq $module; } } if ($] < 5.010) { foreach(qw(B::Hooks::EndOfScope)) { return '< 5.010' if $_ eq $module; } } if ($threads) { foreach(qw( File::Temp ExtUtils::Install Test::Tester Attribute::Handlers Test::Deep FCGI B::Hooks::EndOfScope Digest::SHA1 namespace::clean DateTime::Locale DateTime Template::Stash )) { return 'with threads' if $_ eq $module; } if ($] >= 5.010 and $] < 5.012) { foreach(qw( Class::Accessor Class::MOP )) { return '5.10 with threads' if $_ eq $module; } } } else { if ($] >= 5.010 and $] < 5.012) { foreach(qw( IO ExtUtils::Install Test::Tester Test::Deep Path::Class Scalar::Util )) { return '5.10 without threads' if $_ eq $module; } } } }

SEE ALSO

TAP::Harness

Test::Harness::Straps

B::C

Open Perl modules with vim

After reading about opening Perl module via name with vim, I realized it had a couple of (for me) limitations. First, I always operate from my top-level directory in a project, but that post doesn't prepend a lib/. Second, when I'm running a test suite, I see failure which might be from a module in the lib/ directory, but more often than not are in the t/lib/ directory. Since I keep all of my project directories identical, I can use one little bash function to handle this:

function vim {
  set -- "${@//:://}"
  module="lib/${@/%/.pm}"
  testclass="t/${@/%/.pm}"
  if [ -f $module ]; then
    command vim $module
  elif [ -f $testclass ]; then
    command vim $testclass
  else
    command vim "${@}"
  fi
}

So using it like this:

vim Veure::Foo::Bar::Baz

It will first look for lib/Veure/Foo/Bar/Baz.pm, and then look for t/lib/Veure/Foo/Bar/Baz.pm before finally giving up and just executing vim with whatever arguments I pass into it.

Improvements welcome.

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.