Re: testing scripts inside your distro

[email protected] ("Jonas B. Nielsen")
Newsgroups perl.cpan.testers.discuss
Message-ID <[email protected]>
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]> 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.
>
signature.asc (application/pgp-signature, 874 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQIzBAEBCgAdFiEE4C8kYvvdY+r5KjeUsF0pBlZwp20FAlqYK/8ACgkQsF0pBlZw
p22bDBAAvXMwSpkG1fWIheRaXbZkRePlSxwaxRSztrhAuDd7kVyufVG0COd+dsW5
nUigvzRmznh8RuUXF4SirZCFPDDHIT9KHD/mHBVc0kvP8ACZkPdaQv0yhb7Yn6jf
esMmTQN0J0k7Q4y3CK0rwZBTf7QGTCyiRltF3J3aQVb9uFgTja3RDAOijfPxEt1K
n1tDftEq2gzgQcIshjK/EXaFKFRZELS+jhHcdy6J13ffww4xgoWgzRxT2txquNBY
4UzjJDLa08gQ5ykZd9Cw4VNKLgjCGucyWnv/GnBq4786cXcjZwDHjfKYka+tZ80M
nK3HtP7PuxuMG7iFhi6eOMVgZP0t5fF4/U2Tg3Y3hh2RL9EfI0ei+++iu468amVR
VT8x3HtXVSjuhzhH3H3bHX+ju0bi1HdSDXT4zOON5o5yZ8EpWllHRGNmeCWigUJ9
gacKgef7IwA6mLK0Y+2w0WLms3yQtCF17C9TVG3RXqEhkw7DBCZFG3reHJtFEOdI
whBx55MYdmmRdriugby7+qwcPu8k3U23DY2T+F+4jxNGzryfqt+akuQCBF6BIi5i
IL/njxgjEcgeCFEK6DbBGUf5VgkMAyxhqJPMqFgRyXJr/spGYXoVMxkuTdbApMAD
PMHHi3CGoYLHeohwr2W4uz9V4zoXSYeJEndPTW5hym7BgcTbf98=
=qqsu
-----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.