Recreating many files at the same time

brian_d_foy on 2004-01-04T17:37:25

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


could also be solved with Module Build

markjugg on 2004-01-04T19:12:03

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.

It only works if it exists

brian_d_foy on 2004-01-05T17:38:15

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.