in reply to Sharing configuration information among test files

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 :-)

  • Comment on Re: Sharing configuration information among test files

Replies are listed 'Best First'.
Re^2: Sharing configuration information among test files
by talexb (Chancellor) on Aug 18, 2008 at 00:36 UTC

    Thanks -- it's not really necessary for me to fork off a bunch of processes or go to the complication of using shared memory -- I just wanted to simplify (heh) the opening and reading of configuration files by not duplicating work -- but it seems that there isn't a simple way to do it.

    Thanks all for your feedback.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds