Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday December 16, 2008
05:52 AM

Sanity Tests

[ #38095 ]

Sometimes a test doesn't really need to be written because something else tests something so thoroughly that the other test isn't strictly necessary, but "isn't strictly necessary" doesn't mean "isn't useful". Case in point, try loading the following "YAML" with &YAML::LoadFile:

---
aliases:
  - &RevisionErrorXPath '/p:pips/p:import/p:error[@type="SomeError"]'
xpath_is:
  - *RevisionFailureXPath

That gives you the following error:

YAML Error: No anchor for alias '*RevisionFailureXPath'
   Code: YAML_PARSE_ERR_NO_ANCHOR
   Line: 5
   Document: 1
at /home/ovid/trunk/deps/lib/perl5/YAML.pm line 33

Notice anything interesting there? How about no file name!?!? (I haven't reported the bug due to years of neglect for this module. Why bother?) Unfortunately, our code doesn't blow up on this until about 20 minutes into the test suite run and since we don't see which file we loaded, I was a bit annoyed. My first pass attempt to fix this failed and I was even more annoyed to have to wait another 20 minutes to find this out. As a result, I gave in an wrote the following:

#!/usr/bin/env perl

use strict;
use warnings;

use Test::Most;
use File::Find::Rule;
use YAML;

my @yaml = File::Find::Rule->file->name('*.yml')->in(qw/t aggtests/);
plan tests => scalar @yaml;

for my $yaml (@yaml) {
    lives_ok { YAML::LoadFile($yaml) } "YAML should load OK - $yaml";
}

It's now taken me 9 seconds to find the bug.

I might just rejigger out test suite so that our "sanity" tests such as this one always run first.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.