Slash Boxes
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • We use Test::Harness and its supporting tools to test everything. The initiation of the test isn't automatic, but everything else is.

    We have a script called smoke that

    • Runs *.t files
    • Runs *.phpt files, which are PHP versions of *.t files for PHP libraries, and that emits the same style output
    • Syntax checks all *.pl, *.pm and *.php files

    All this is done by creating my own subclass of Test::Harness::Straps which can handle all those other non-*.t files.

    Also, some of the test files are meta-test files. For example, there's a .t file that verifies that every .pm file in the tree has a corresponding .t file, that the POD in that file passes muster, and that it uses warnings and strict.

    #!/usr/bin/perl -w

    use strict;
    use File::Spec;
    use File::Find::Rule;
    use Pod::Checker;

    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 );

    our $podchecker = Pod::Checker->new( '-warnings' => 1 );

    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" );

    I'm doing all sorts of automated testing as I keep going on. I'm thinkin' of starting a series of articles in The Perl Review [] on it.



    • Cool stuff. What I'm trying to sort out for myself is if there are additional benefits to be found from doing a build on a nightly basis. That is, doing a cvs checkout into a fresh directory, firing up an Apache process which points to that directory, running the automated tests, then (assuming everything passes) tar'ing up the directory and storing it away.

      The tests that you are doing seem to capture a lot of the benefits of a nightly build:
      • Syntax checking of all of your scripts is the equivalen