Closed gavyrodg closed 3 years ago
${EXECDIR}: An absolute path to the directory where test execution was started from.
This is a running time variable. You can start execution from any directory. So can't know the value during static parse.
For work around, you can create a fake directory named "EXECDIR" in Pycharm project, put or link Settings.robot in it. Or you may link the directory "EXECDIR" directly. Or change your directory hierarchy, e.g, change from /home/tester/repo/ to /home/tester/EXECDIR/repo/
Then in Pycharm, menu, File | Settings | Languages & Frameworks | Robot Options, Check "Strip Variable in library path (${name}/ to be name/)".
After that, when it see "${EXECDIR}/Settings.robot", it will search "EXECDIR/Settings.robot".
I have a forked version of the original intellibot plugin that solves this exact issue (and is the only reason we created our own version to begin with). I would be happy to share how we solved it if you like. I would much rather this be fixed in your version of the plugin so I can stop maintaining my own. The only files we changed to implement this functionality are RobotFileManager.java and RobotPythonReferenceSearch.java.
I went ahead and created a pull request with the changes we made to support the built-in ${EXECDIR} variable in Resource and Library path references.
With this fix, instead of having to use messy relative paths like this:
Library ../../../Path/To/File/MyLibrary.py Resource ../../../Path/To/File/MyResource.robot
You can use absolute paths with the ${EXECDIR} variable referencing the root of your project like this:
Library ${EXECDIR}/Path/To/File/MyLibrary.py Resource ${EXECDIR}/Path/To/File/MyResource.robot
And still be able to resolve the keyword names and navigate between keywords in the IDE using the usual Ctrl+B or Command+B.
@sparkymartin Thanks for the code sharing. I see you replace ${EXECDIR} to project.getBasePath(). I believe this works well in your environment. But I checked several projects in our organization. Some ${EXECDIR} are users's home directory, other ${EXECDIR} are Jenkins's workspace, none of them set to project.getBasePath().
So I suggest could your add a field in Settings | Languages & Frameworks | Robot Options to let user input what's value of ${EXECDIR}. And add a flag in same page to enable/disable this feature. Thanks!
Good point @lte2000. This code was actually written by a previous intern and employee who are no longer with my team. The environment that they used to build and test this is no longer available. Is this something that you would be able to add to the code? I just simply wanted to share how we solved it, but if there is fine tuning to be made to make it a more widely acceptable solution, I am fine with whatever tweaks need to be made to make it usable by anyone. I am just not in a position to easily make further changes.
@lte2000, is adding the setting to the Robot Options page something that you or another contributor can do?
@sparkymartin , I'm not working on it. You're the contributor :)
Indeed, our projects also use variable in library path (please see the screenshot below):
We are using the method of "Strip Variable in library path" I described in previous comment (that's why I develop such feature), it works very well.
now, you can provide the value for any variable yourself in Robot Option. For example, input: ${EXECDIR}=/path/to/execution ${ANYVAR}=/path/to/VAR Then Library ${EXECDIR}/aa/bb/${ANYVAR}/lib.py will be Library /path/to/execution/aa/bb/path/to/VAR/lib.py
Note: it just do simple string replacement, no any other function.
Please try dev_0.10.143.397 from https://github.com/lte2000/intellibot
please install "intellibot #patched" v0.10.143.397 from jetbrain marketplace, which can define value the ${EXECDIR} so can resolve the import path.
Hi @lte2000,
Came across this issue a long time ago but as the plugin was no longer being developed I let it slide.
Currently when you do a
Log To Console ${EXEC_DIR}
the directory is correct and when I use this in a file to reference a resource or different file in my repo it works at run time but I cannot use Cmd+Click to follow through to the exact file.I can use
../../Settings.resource
but in time as my repo gets bigger this will become a pain to maintain and I could end up with../../../../../../../settings.resource
etc.As an example when I have
${EXECDIR}
at the top of my file all of the intellisense is broken. But it still works at run time.I hope I have explained this well enough but if you need any more details or screenshots please let me know.
Thanks,
Gavin