robotcode
robotcode copied to clipboard
[ENHANCEMENT] Definition and handling of ${EXECDIR}
RobotFramework defines ${EXECDIR} as
An absolute path to the directory where test execution was started from.
I am surprised by how this variable is handled in Visual Studio Code. This affects both the execution and also the test explorer.
Consider this directory structure:
project_dir
- .git
- subfolder
- explore.robot
explore.robot:
*** Test Cases ***
Print ExecDir
Log To Console ${EXECDIR}
- When I open
project_dirin VS Code and runexplore.robot, the output is the absolute path to project_dir. As expected. - When I open
subfolderin VS Code and runexplore.robot, the output is the still the absolute path to project_dir. - When I init a git repo inside subfolder, open
subfolderin VS Code and runexplore.robot, the output is the absolute path to subfolder.
One can observe the same behaviour in the test explorer. Somehow the git repo of an upper folder - even when not part of the folder currently opened in VS Code- seems to be taken into account for root path determination.
This is very counterintuitive for me. I would expect that EXECDIR is basically equal to ${workspaceDir} VS Code variable.
Desktop
- VS Code Version: 1.85.2
- RobotCode Version 0.69
- OS: Windows
- Python Version: 3.10.6
- RobotFramework Version: 6.1
Normally, when trying to run a suite below the project directory with robot, you have to be very careful and possibly adjust all paths that need to be passed (outputdir, python_path), the ${EXECDIR} and some other internal variables change, the IDs of the tests change, etc.
RobotCode (in VSCode and on the console) tries to avoid/improve this by trying to find a project directory from which it should start "robot". RobotCode searches for it from the current directory upwards for various properties that indicate a project directory. If it doesn't find one, it takes the current directory.
The indications of a project directory are:
robot.toml,.robot.tomlfilespyproject.toml.gitor.hgdirectory
So if you want to open a subdirectory of a Git repository in VSCode and this should be your Execdir, you currently still have to create a robot.toml file. In the future, there will be a way to turn off the detection, or to explicitly specify the ${Execdir}, I still have to see how I do that.
That's why I leave this question/issue open and convert it into an enhancement.
Thanks for the detailed explanation. 👍