note
chexmix
OK, I am still getting the same output (see below) and I think I am beginning to understand why ... so I hope my fellow Monks will excuse my ox-like progress ... :^)
<p>In the script I am testing, what is now the sub main() calls out to a parse_opts() routine to set the values in %params. Therefore (if I am understanding this), the line I have added to myScript to enable testing, e.g.
<code>
main( @ARGV ) unless caller( );
</code>
<p> ... doesn't really make sense because the script isn't accessing @ARGV directly -- it is doing so via Getopt::Long and a parse_opts() routine. In other words there is kind of a collision of approaches here.
<p> ... so I am still lost in a way. Am not sure if I need to totally recast the script to be tested so that it doesn't make use of this form of parameter processing, or if there is still a way to do what I want, e.g. write a test that allows one to point the script at a particular file, read 'dummy' input and create 'dummy' output, and test that that is all being done correctly.
<p>For what it is worth, this is what test_myScript.t looks like now:
<code>
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 5;
use Test::Exception;
ok( require( 'pluck4gl' ), 'loaded file okay' ) or exit;
my @ARGV = ('-files=S2008-10-22_13:01.failed.lis','-output=doodad.4gl','/data/mola/sap/daily4gl/S2008-10-22_13:01.4gl');
throws_ok (sub {main ( @ARGV )}, qr/Usage:/, 'main () should give a usage error without any arguments');
throws_ok (sub {main( 'bad command' ) }, qr/Unknown command 'bad command'/,
'... or with a bad command given');
</code>
<p> ... and here is the output:
<code>
1..5
ok 1 - loaded file okay
parameter `files' not set
parameter `output' not set
# Looks like you planned 5 tests but only ran 1.
# Looks like your test died just after 1.
</code>
<p>I apologize for my utter fecklessness. I definitely need some more feck.
<p>Thanks,
<p>G
747874
747907