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 ]

Sunday January 04, 2004
12:37 PM

Recreating many files at the same time

[ #16624 ]

Here is a program to write programs. In this case I want to replace all of the pod.t files in my working directories. I have wanted to do this for a while, and now I have. Andy's talking about Test::Harness or something doing automagically generating stuff like pod.t, cover.t, and whatnot, and then I will not have to write any of these tests.

Hey, I could even write a module to create these tests, and if a user has the module, the Makefile.PL creates the tests, otherwise it just goes on with life. People interested in testing and quality control could use the module, and others could just install the distro and get back to work. (I think Andy does this manually anyway, so you know automating it is just around the corner).

#!/usr/bin/perl
 
use File::Find::Rule;
 
my @files = File::Find::Rule->file
    ->name( 'pod.t' )->in( '/Users/brian/Dev' );
 
foreach my $file ( @files )
    {
    print "$file\n";
    rename $file, "$file.bak";
    open my($fh), "> $file" or next;
    print $fh <<'HERE';
#$Id$
use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();
HERE
 
    close $fh;
    }

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.
  • I thought of another solution to the same problem.
    I submitted a patch to Module::Build to add a "testpod" action. There could also be some mechanism to have auto-tests run as a part of a basic "./Build test" as well.

    I prefer this solution to auto-generating and shipping around more code. What if there is a bug in in the auto-generated code? There will be "N" places to fix it, versus 1 if it's in Module::Build.
  • I prefer that solution too, but it is not a currently available solution, and I don't use Module::Build.

    Eventually everything will catch up, though.