Re: testing scripts inside your distro

[email protected] ("Jonas B. Nielsen")
Newsgroups perl.cpan.testers.discuss
Message-ID <[email protected]>
Huh?

Just must have been drunk or something,

I mean to say, I can ONLY agree with this approach.

Sorry for any confusion and thanks for not roasting me :-)

Have a nice weekend,

jonasbn

> On 1 Mar 2018, at 17.36, Jonas B. Nielsen <[email protected]> wrote:
> 
> I cannot agree with this approach, but sometimes a single file is the easiest to distribute.
> 
> Currently I am looking at App::Fatpacker - https://metacpan.org/pod/App::FatPacker <https://metacpan.org/pod/App::FatPacker>
> 
>> On 1 Mar 2018, at 15.00, yary <[email protected] <mailto:[email protected]>> wrote:
>> 
>> 
>> On Thu, Mar 1, 2018 at 9:56 AM, David Cantrell <[email protected] <mailto:[email protected]>> wrote:
>> 
>> My approach is to have the script be mostly a wrapper around more
>> easily-testable modules - the script just wrangles arguments and shows
>> results.
>> 
>> +1 for that approach in general. Makes it easy to call the "useful" code in the script in other places.
>> 
>> Something to do in small scripts which don't aren't module material, is to put all the "useful" code into subs, put the command-line processing & printing into a "sub MAIN", and then have only this top-level statement:
>> 
>>     exit MAIN unless caller;
>> 
>> That lets the script be called normally, executing when run from the command line. On the other hand, another perl program can "require 'the_code_file.pl <http://the_code_file.pl/>'" and load all the subs without anything executing- so your test code can call MAIN after setting @ARGV to whatever it wants - or can test the other subs as needed.
>> 
> 



—
pauseid: JONASBN
email: [email protected]
twitter: @jonasbn
blog: https://lastmover.wordpress.com/ <https://lastmover.wordpress.com/>
signature.asc (application/pgp-signature, 874 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIzBAEBCgAdFiEE4C8kYvvdY+r5KjeUsF0pBlZwp20FAlqZojkACgkQsF0pBlZw
p21KXxAAonBCUA37P1P2zA+TsdCFi7+wtVa5arnh57xwxBgtrgWQSKoSVACx+eOL
VIbQPgaydtCP0GsOmjU6CCBIxgS8poBOewCTQPrXqAVLRWjOHM40MWzqWtIaIaWf
3BTCzq7ux99ErdflCreZEwgXpG01nru0W2SHSpylroRv+/HyDEncUR6GILdceHua
EwxYn9TvI5TQ9hZyrIAwNDp94svjinfDAce1yFyc8Y+xLYYwSwYTddboGIzbN6Mi
LGLkdOW/3RpokAzFlDgFNWYJkuYTULEph1/MSkbw0+DAN+gv0fWUhYCjhNAMNFvI
/vjCOga+ERM1uTjsenqCAK/9cfkEThUTRZoxhQHN56CYm8XYuxntghw4pEbdIQNL
D0DemHEGDl7T8mwutwJmKmuKa6W8ssEgwMjg1eNDuUMAGIwYLQ2/jCRph4Zqjfcj
0Y/q+vNQphBRavOErtvGgy65u+IEmuZr41zLv6yh8pCCNH4JEWWX/4XanqIZJKB2
/bK7Tb7qKtU+kwjZ0P/th8wyCv28iASAG1HCq4u5E/apX400m7bRRQpAwcbSoyww
2+j2ZzFF/QENKXRcPSXWaBsqAE99rIIkAwe+SGguOYrrX+EPm+mBZyCtFHO7TDCD
4qoguuj+aUr04Zu3zu1MEFsFkv/9pVAWHfNGO1vAMINpxnCW5wY=
=YC4F
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.