On Tue, Aug/11/2009 02:53:50PM, Mike Dubman wrote: > Hey Jeff, > > This code acts as a pre-processor during loading of ini file into mtt. > It replaces builtin vars %VAR% with their values, for example: > > ... > [Test run: trivial] > my_sect_name=%INI_SECTION_NAME% > ... > > %INI_SECTION_NAME% get replaced with real value. (trivial) > > it is useful in the following situation: > > ... > [test run: trivial] > #param=&test_run_name() > param=%INI_SECTION_NAME% > ... > > when "param" was accessed from Reporter context, test_run_name() will > return undef, but real value if %INI_SECTION_NAME% is used!
Doesn't ¤t_simple_section() do the same thing as %INI_SECTION_NAME%? There are a couple predefined INI vars already, but they use @VAR@ syntax: @INI_NAME@ @PROGRAM_NAME@ The predefined vars are for strings that can't be known via the Config::IniFiles module (e.g., the full path to the INI file and client/mtt). Could you add INI_SECTION_NAME to InsertINIPredefines, and use the @VAR@ syntax? -Ethan > > regards > > Mike > > On Tue, Aug 11, 2009 at 2:03 PM, Jeff Squyres <jsquy...@cisco.com> wrote: > > Mike -- > > Can you explain what this does? > > On Aug 11, 2009, at 4:28 AM, <mi...@osl.iu.edu> wrote: > > Author: miked > Date: 2009-08-11 04:28:03 EDT (Tue, 11 Aug 2009) > New Revision: 1306 > URL: https://svn.open-mpi.org/trac/mtt/changeset/1306 > > Log: > added poor-man-inifile-preprocessor > Text files modified: > * trunk/client/mtt * * | * * 3 +++ > * trunk/lib/MTT/INI.pm | * *24 ++++++++++++++++++++++++ > * 2 files changed, 27 insertions(+), 0 deletions(-) > > Modified: trunk/client/mtt > = > = > = > = > = > = > = > = > ====================================================================== > --- trunk/client/mtt * *(original) > +++ trunk/client/mtt * *2009-08-11 04:28:03 EDT (Tue, 11 Aug 2009) > @@ -652,6 +652,9 @@ > * * * * # Expand all the "include_section" parameters > * * * * $unfiltered = MTT::INI::ExpandIncludeSections($unfiltered); > > + * * * *# Expand all the "%PREDEFINED_VARS%" parameters > + * * * *$unfiltered = MTT::INI::ExpandPredefinedVars($unfiltered); > + > * * * * # Keep an unfiltered version of the ini file for error > checking > * * * * my $filtered = dclone($unfiltered); > > Modified: trunk/lib/MTT/INI.pm > > ============================================================================== > --- trunk/lib/MTT/INI.pm * * * *(original) > +++ trunk/lib/MTT/INI.pm * * * *2009-08-11 04:28:03 EDT (Tue, 11 Aug > 2009) > @@ -275,6 +275,30 @@ > * * return $ini; > *} > > +sub ExpandPredefinedVars { > + * *my($ini) = @_; > + > + * *foreach my $section ($ini->Sections) { > + * * * * * * * foreach my $parameter ($ini->Parameters($section)) { > + * * * * * * * * * * * my $val = $ini->val($section, $parameter); > + * * * * * * * * * * * if ( $val =~ /%INI_SECTION_NAME%/i ) { > + * * * * * * * * * * * * * * * my $sect = $section; > + * * * * * * * * * * * * * * * $sect =~ s/test run://gi; > + * * * * * * * * * * * * * * * $sect =~ s/test build://gi; > + * * * * * * * * * * * * * * * $sect =~ s/test get://gi; > + * * * * * * * * * * * * * * * $sect =~ s/mpi get://gi; > + * * * * * * * * * * * * * * * $sect =~ s/mpi install://gi; > + * * * * * * * * * * * * * * * $sect =~ s/mpi details://gi; > + * * * * * * * * * * * * * * * $sect =~ s/reporter://gi; > + * * * * * * * * * * * * * * * $val =~ s/%INI_SECTION_NAME%/$sect/g; > + * * * * * * * * * * * * * * * $ini->delval($section, $parameter); > + * * * * * * * * * * * * * * * $ini->newval($section, $parameter, > $val); > + * * * * * * * * * * * } > + * * * * * * * } > + * *} > + * *return $ini; > +} > + > *# Worker subroutine for recursive ExpandIncludeSections > *sub _expand_include_sections { > * * my($ini, $section) = @_; > _______________________________________________ > mtt-svn mailing list > mtt-...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/mtt-svn > > -- > Jeff Squyres > jsquy...@cisco.com > > _______________________________________________ > mtt-devel mailing list > mtt-de...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/mtt-devel > > References > > Visible links > . mailto:jsquy...@cisco.com > . mailto:mi...@osl.iu.edu > . https://svn.open-mpi.org/trac/mtt/changeset/1306 > . mailto:mtt-...@open-mpi.org > . http://www.open-mpi.org/mailman/listinfo.cgi/mtt-svn > . mailto:jsquy...@cisco.com > . mailto:mtt-de...@open-mpi.org > . http://www.open-mpi.org/mailman/listinfo.cgi/mtt-devel > _______________________________________________ > mtt-devel mailing list > mtt-de...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/mtt-devel