It's not clear to me where you're going with this. If, for example, you're going to do all this in a single process, then I can see how loading/reading/parsing multiple times is less than desirable. In this case, a separate module where you just ask for the configuration data you need and the module merely loads it when required (i.e., first time data is requested), like others have suggested, would simplify things. If, however, you're hoping to spread your tests out over multiple processes, then either you're forking off each subprocess (where they can inherit the pre-loaded data) or, more likely, they're running completely independently, in which case there's no way to avoid loading the configuration multiple times. In both of these cases, partitioning it off into its own module will just make things easier.

Ok, that's not entirely true - you could set up some shared memory to hold the data so that each test can simply attach to the shared memory to retrieve its data, or have a configuration daemon that you query over sockets or tcp or something instead of reading the file, but I don't think either of these options are seriously viable for this :-)


In reply to Re: Sharing configuration information among test files by Tanktalus
in thread Sharing configuration information among test files by talexb

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.