in reply to Portably unit testing scripts

The basic skeleton of my script is below, but it is built around the "modulino" approach of main(@ARGV) unless caller .... How would you unit test something like this? I could actually execute the script, but that isn't much of a "unit" test anymore and also defeats the purpose of the "modulino" style of unit testing scripts like this, and doing that portably would be tricky.

Hi,

What purpose does that modulino stuff serve anyway?

The most it can accomplish is to to substitute 1 symlink for 1 regular file -- thats silly golf , esp in a distribution

pod2usage exitval does accept "noexit"

  • Comment on Re: Portably unit testing scripts (no modulinos)

Replies are listed 'Best First'.
Re^2: Portably unit testing scripts (no modulinos)
by wanna_code_perl (Friar) on Oct 26, 2019 at 09:17 UTC
    What purpose does that modulino stuff serve anyway?

    The idea is to make unit testing of applications easier/possible, since the main control flow gets put into a subroutine that can be unit tested like any other sub.

    The most it can accomplish is to to substitute 1 symlink for 1 regular file -- thats silly golf , esp in a distribution

    What? It's not designed to shorten (golf) anything... in fact, the code is a bit more verbose. And it has nothing to do with the filesystem.

    pod2usage exitval does accept "noexit"

    That's right, "NOEXIT" would help with testing the --help / pod2usage() path. Unfortunately that doesn't help the general case, though.

      Having a main sub and all code in subs is plain modularity. The modulino part is unless caller. Deciding if act as a module or program based on caller is silly modulino golf.