CURDIR & EXECDIR values and usage

5,050 views
Skip to first unread message

learner

unread,
Apr 14, 2012, 4:54:33 PM4/14/12
to robotframework-users
I'm puzzled by the value of CURDIR & EXECDIR when running from RIDE.
I may have the same questions when invoking robot from the CLI (not
from RIDE), but I haven't tried that yet.

When starting a test from RIDE, I don't yet see much rhyme or reason
for the setting of CURDIR or EXECDIR.

It **seems** that:

1. EXECDIR is set to the path to the directory where RIDE is initially
invoked, and
2. CURDIR is set to the path to the directory of the most recently
sourced resource file in the test case file.

*** Questions ***
1. Are my statements above correct?

2. I'm a little puzzled on how to proceed. I want to be able to load
different resources from a specific relative path (a different
resource depending on the device name provided upon invocation). I
think that I cannot guarantee the directory that RIDE was started from
because it depends on the user behavior (where they invoke RIDE from)
and I cannot guarantee the directory of the most recently sourced
resource file because the user may have changed the test case or suite
setup to source other resources.

Any ideas?

Thanks in advance.

Janne Härkönen

unread,
Apr 16, 2012, 2:42:57 AM4/16/12
to robotframe...@googlegroups.com
Hello learner,

On 04/14/2012 11:54 PM, learner wrote:
> I'm puzzled by the value of CURDIR& EXECDIR when running from RIDE.


> I may have the same questions when invoking robot from the CLI (not
> from RIDE), but I haven't tried that yet.
>
> When starting a test from RIDE, I don't yet see much rhyme or reason
> for the setting of CURDIR or EXECDIR.
>
> It **seems** that:
>
> 1. EXECDIR is set to the path to the directory where RIDE is initially
> invoked, and
> 2. CURDIR is set to the path to the directory of the most recently
> sourced resource file in the test case file.
>
> *** Questions ***
> 1. Are my statements above correct?

Not entirely. EXECDIR points to the working directory where test
execution is started, it is basically os.path.abspath(os.curdir). CURDIR
points to the directory where a particular test suite/resource file is.
It is resolved during parsing, and cannot be changed dynamically.

> 2. I'm a little puzzled on how to proceed. I want to be able to load
> different resources from a specific relative path (a different
> resource depending on the device name provided upon invocation). I
> think that I cannot guarantee the directory that RIDE was started from
> because it depends on the user behavior (where they invoke RIDE from)
> and I cannot guarantee the directory of the most recently sourced
> resource file because the user may have changed the test case or suite
> setup to source other resources.

CURDIR can be used for this purpose. Having e.g

.
|--tests
| |-mysuite.txt
|--resources
| |-dev1res.txt
| |-dev2res.txt

you can always use import like this in mysuite.txt

Resource | ${CURDIR}${/}..${/}resource{/}${DEVICE}res.txt

where ${DEVICE} can be defined e.g. from the command line. ${CURDIR}
used in mysuite.txt always resolves as absolute path to `tests` directory.

hope this helps,
--J

--
Janne H�rk�nen <|> Software Craftsman @ http://reaktor.fi
http://twitter.com/#!/janneharkonen

learner

unread,
Apr 28, 2012, 5:03:24 PM4/28/12
to robotframework-users
Thank you, that helped very much! I'm using CURDIR now. I was a
little surprised by your comment "CURDIR points to the directory where
a particular test suite/resource file is."

After experimenting a little, I observed that when a **test case**
references CURDIR, the value of CURDIR is the directory that contained
the test case. Similarly, when a **resource** references CURDIR, the
value of CURDIR is the directory that contains that resource file.

Just wondering if my observation/understanding correct?

Thanks again!
Reply all
Reply to author
Forward
0 new messages