waldenner / robotframework

Automatically exported from code.google.com/p/robotframework
Apache License 2.0
0 stars 0 forks source link

Ability to reference already set variables in argument files and maybe command line #542

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to be able to reference Robot Framework variables that have
already been given values in an argument file, or maybe even on the command
line.  For example, I'd like to write a couple of argument files like this:

SetProject.txt
  --variable Project:MyCodeName

ArgFile.txt
#
# Set the Project variable
#
--argumentfile SetProject.txt
#
# Set the outputdir based on Project
#
--outputdir ${Project}/results
#
# Select suite files to run
#
${Project}*.html

If I used these two argument files in a pybot command like:

  pybot -A ArgFile.txt

then I'd like the ${Project} variable references in ArgFile.txt to be
substituted at run-time with the value assigned to that variable.  If the
Project variable was not assigned, the an error would be raised.

I'd be willing to work on this enhancement if someone could guide me as to
where the changes would need to be made and where to find the Robot
Framework methods for variable substitution.

Original issue reported on code.google.com by c.martin...@gmail.com on 28 Apr 2010 at 6:47

GoogleCodeExporter commented 9 years ago
This is hard to implement using RF's variables because command line arguments,
including argument files, are processed before variables are initialized. 
Changing
this order would be quite a big task.

Would it be enough to support environment variables? They could be replaced 
using
RF's Variables class, which supports also environment variables, without 
initializing
it otherwise:

>>> from robot.variables import Variables
>>> v = Variables(identifiers=['%'])
>>> v.replace_string('Hello, %{USER}!')
'Hello, peke!'

Notice also that at least on Unixes you can use environment variables on the 
command
line automatically when you use the syntax required by the OS. For example on my
Ubuntu box I can run `pybot --variable USER:$USER --monitorwidth $COLUMNS 
tests.txt`.
I don't have Windows machine here to test does the Windows shell replace 
environment
variables before arguments are passed to commands the same way.

Original comment by pekka.klarck on 28 Apr 2010 at 7:22

GoogleCodeExporter commented 9 years ago
Martin, any comments to my proposal to support environment variables?

Original comment by pekka.klarck on 30 Aug 2010 at 3:54

GoogleCodeExporter commented 9 years ago

Original comment by pekka.klarck on 23 Sep 2010 at 6:37

GoogleCodeExporter commented 9 years ago

Original comment by robotframework@gmail.com on 2 Dec 2011 at 9:33