#!/usr/bin/perl -w
use strict;
use File::Spec;
use File::Find::Rule;
use Test::More 'no_plan';
my $base = (shift || $ENV{TWROOT} || '.');
my $rule = File::Find::Rule->new;
$rule->or( $rule->new->directory->name('CVS')->prune->discard,
$rule->new->file->name( '*.pl','*.pm','*.t' ) );
my @files = $rule->in( $base );
for my $file ( @files ) {
check( $file );
}
sub check {
my $filename = shift;
my $dispname = File::Spec->abs2rel( $filename, $base );
local $/ = undef;
open( my $fh, $filename ) or return fail( "Couldn't open $dispname: $!" );
my $text = <$fh>;
close $fh;
# Search for strict and warnings. You can get around this just by
# having the text in comments, but that's not the point.
ok( $text =~/use strict;/, "$dispname uses strict" );
ok( $text =~/use warnings;|perl -w/, "$dispname uses warnings" );
}
Ergh (Score:1)
I was about to ask why you didn't use
like()instead ofok(). Then I realized exactly how verbose a failure message would be. Good thinking.Oooh (Score:2)
Re:Oooh (Score:2)
Yes, testing IS great. :-)
I don't count the files because I don't know how many tests per file I'm going to have, and I may actually have a different number of tests for each file.
One of the things I was talking with Farmer Schwern about at YAPC::NA was the possibility of having a count of tests, with a
--
xoa
But does it *really* use strict? (Score:1)
Re:But does it *really* use strict? (Score:2)
The code is to catch mistakes, not malfeasance. There's also nothing stopping you from doing
At that point, it's a management issue, not a technical one.
--
xoa
Re:But does it *really* use strict? (Score:2)