Skip to main content

Posts

Showing posts from October, 2010

Test reports on Hudson in 30 seconds (well, let's say quickly)

There are so many articles on how to generate test reports on Hudson for perl modules or applications, that I thought it was somehow complicated. It's not. The underlying problem is that Hudson has support for test results in JUnit format. To solve this you need to convert from TAP to JUnit the test results. Of course there are some pre-requirement: Your perl code must have tests (duh) You must have Hudson set up to run those tests You need to install TAP::Harness::JUnit on the building box You need to install ' prove ' on the building box Then all you have to do is add this command in the shell script you execute to run the tests: prove --harness=TAP::Harness::JUnit and configure the "Publish JUnit Test Result Reports" section of your project to point to the resulting XML file. No mumbo jumbo . Since TAP::Harness::JUnit is not available as a debian package, if you need to install it properly, just follow the usual procedure to generate debian packages from CPA...

A rather serious matter – deciding what to read

If you are not interested in the full post, the concept of it is: “What are the 500 books that are worth reading before I die?” What do you recommend? Here’s the full post: I’m a keen reader since I was a child, and I’ve recently become an enthusiastic user of Kindle . Infinite (well, I know they are finite, but allow me this mathematically inconsistent emphasis) opportunities have suddenly become available: I can have thousands of books on my Kindle in seconds. Kindle books cost less their paper version, and often are even free (what’s slightly concerning is how easily you can buy a Kindle book: you just click on a button and your Amazon account is charged automatically - that’s why I set up a password to lock the device). Anyway the point of this post is about decisions: what to read. Let’s start with estimating how much I can read in my life, to give more sense on what follows. I need about one month to read a technical book of 400-500 pages, about two weeks to read an in...

A forgotten note

Almost a year ago I attended " Literature and Freedom : Writers in Conversation ", a discussion hosted by Tate Modern which presented among the others Tahar Ben Jelloun . Now I wish I took more notes during that discussion, but this afternoon I found one - I'd rather write it here before losing even that piece of paper: Behind every work of fiction lies a tragedy. It's probably something you may easily believe reading "This blinding absence of light", which definitely impressed me this Spring, and I faced like a long work of poetry rather than a novel. Here's a review from The Guardian .

Need some constructive criticism on your code? Ask perlcritic.

perlcritic is "a static source code analysis engine", a CPAN module which can also be used as a command . An example: $ perlcritic -severity 3 src/AModule.pm Subroutine does not end with "return" at line 24, column 1. See page 197 of PBP. (Severity: 4) Return value of eval not tested. at line 32, column 5. You can't depend upon the value of $@/$EVAL_ERROR to tell whether an eval failed.. (Severity: 3) As you can see you can get extremely useful information about the sanity of your code and how much it complies to good coding practices. There are 5 different severity levels (being 5 the "less critic"). Most Policy modules are based on Damian Conway's book Perl Best Practices ( PBP ), but it's not limited to it. I run perlcritic (using typically severity 3) automatically on all the source code files, every time I run the unit tests and/or build a package, in order to get as soon as possible a valuable feedback after code changes. Since the ...

Merging hashes with Perl - easy but (maybe) tricky

Merging hashes with Perl is extremely easy: you can just "list" them. For example try this: use strict; use warnings; use Data::Dumper; my %hash1 = ('car' => 'FIAT', 'phone' => 'Nokia'); my %hash2 = ('laptop' => 'Dell', 'provider' => 'Orange'); my %mergedHash = (%hash1, %hash2); print "hash1: " . Dumper(\%hash1); print "hash2: " . Dumper(\%hash2); print "merged hash: " . Dumper(\%mergedHash); You'll see that %mergedHash contains the result of merging the two hashes. This is the simplest but not most efficient way to do it: here Perl Cookbook presents a different method , which uses less memory - interesting if you're merging big hashes (and have memory constraints). Now the tricky bit is that you can have this merge even when maybe you don't expect it... For example add this code to the previous lines: useHashes(%hash1, %hash2); sub useHashes { my(%hashInp...