Suppose I have a shell script which takes any combination of switches say -a -b -c -d -e (but these are mnemonic in practice) all of which take arguments. I want to test the script using various test arguments numbering p(a) thru p(e) e.g. if I have 2 test cases for switch -a then p(a) is 2. Although I also have say 1 "break it" test for option -a.

In fact I have 220 shell scripts to test whose allowed switches overlap, but if I can make just one test for one script then I can figure out later how to replicate the process.

So I would configure the first test using a hash like:

%valid = ( 'a' => { goodcase => [ 'a1Case', 'a2Case', ... 'aNGoodaCase +' ], badcase => [ 'a1BadaCase', ..., 'aNBadaCase' ] }, etc. );
So how do I generate all combinations of switches, good cases and badcases?, bearing in mind that different options require different sets of cases (of differing cardinality) to test them.

I know I probably need something like Algorithm::Loops, but I can't fit the module to the particular requirement in my head because of the varying counts i.e. it's not the standard combination of multiple arrays situation published elsewhere on this site. There are additional issues such as managing conflicting option choices and generating test data that works for options in combination, but I have to start somewhere and this seems the most salient obstacle.

Thanks for any help!

-S


In reply to combinations of VARYING multiple arrays by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.