hesco has asked for the wisdom of the Perl Monks concerning the following question:

I just published version 0.12 of Test::MonitorSites to cpan. The bugs introduced at version 0.06 with its new functionality have at last been squashed (by version 0.09) and by now this module will run quietly and w/o obvious (to me) bugs.

However, I am not yet satisfied with the operation of the test suite. It's been doing the 'ET phone home' thing, because I haven't settled on an elegant way to propogate user input into the test suite, yet. I understand I can grab user input using the prompt() method. Once I have it, though, I need to use that input to rewrite a number of t/testsuite_*.ini files, replacing placeholder values with the user defined ones.

But how do I allow for the possibility that someone might run make test more than once? My current thinking is that the way to go here might be to create a new directory at t/ini/ which would have a set of stock configuration files needed to drive the test suite, each with its placeholders. Then have the Makefile.PL script use those to rewrite the real config files used by the test suite.

Am I making this harder than it needs to be? Is there a more elegant way to handle this without this proliferation of files on the system? My current approach is adding an additional prerequisite with File::Util. Is there a more straight-forward way of approaching this? Is there some platform independent way to avoid my use of File::Utils->list_dir() method and its additional dependency?

My Makefile.PL currently reads:

use strict; use warnings; use ExtUtils::MakeMaker; use File::Util; print "==> These tests generate email output + <==\n"; print "==> Where would you like your test results sent? + <==\n"; print "==> By default test email summaries go to dev-null\ +m <==\n"; print "==> By default test sms summaries go to dev-null\ + <==\n"; my $email = prompt('Send test email summaries to?',' +m'); my $sms = prompt('Send test sms summaries to?',''); my($f) = File::Util->new(); my @config_files = $f->list_dir( 't/ini' , '--pattern=\.ini$' ); foreach my $config_file (@config_files){ print "writing t/$config_file \n"; open ('INI','>',"t/$config_file"); open ('SRC',"t/ini/$config_file"); while(<SRC>){ if(m/^sms_recipients =/){ $_ =~ s/$_/sms_recipients = '$sms'\n/; } if(m/^results_recipients =/){ $_ =~ s/$_/results_recipients = '$em +ail'\n/; } print INI $_; } close SRC; close INI; } WriteMakefile( NAME => 'Test::MonitorSites', AUTHOR => 'Hugh Esco <>', VERSION_FROM => 'lib/Test/', ABSTRACT_FROM => 'lib/Test/', PL_FILES => {}, PREREQ_PM => { 'Cwd' => 0, 'Carp' => 0, 'File::Util' => 0, 'Data::Dumper' => 0, 'Test::More' => 0, 'Test::Pod' => 1.14, 'Test::Pod::Coverage' => 1.04, 'Test::Builder' => 0, 'Mail::Mailer' => 0, 'Config::Simple' => 0, 'WWW::Mechanize' => 0, 'Test::WWW::Mechanize' => 0, 'Test::HTML::Tidy' => 0, 'HTTP::Request::Common' => 0, 'Test::Builder::Tester' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', } +, clean => { FILES => 'Test-MonitorSites-*' }, );

I have now posted to cpan, version 0.13, which incorporates the approach outlined above and busts the ET-phone-home bug which was previously a part of the test suite. It also allows for the clean up of the t/*.ini files with `make clean`, as well. I'm still looking for ways to get this done without the extra dependency. Thanks to diotalevi for the lead about postponing the work until the build itself.

if( $lal && $lol ) { $life++; }

Replies are listed 'Best First'.
Re: Propogating user settings w/ ExtUtils::MakeMaker
by diotalevi (Canon) on Mar 26, 2007 at 21:10 UTC

    You can defer work to build time by moving that code into a PL file run from PL_FILES.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊