robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
187 stars 15 forks source link

[ENHANCEMENT] Definition and handling of ${EXECDIR} #201

Closed DanielPenning closed 2 months ago

DanielPenning commented 10 months ago

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}

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

d-biehl commented 10 months ago

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:

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.

DanielPenning commented 10 months ago

Thanks for the detailed explanation. 👍