0

Context

I'm working on a Robot Framework project using VSCode and the robotcode extension (robotcode-dbiel). In production, we have one git repo for the framework, and one git repo for any test related assets maintained separately.

Therefore when developing / debugging my folder structure looks like this:

git/
├── .vscode/
│   └── launch.json
├── FW/
│   └── Python libraries, resource files
├── FW-TEST-RESOURCES/
│   └── test_cases
│   └── input_variables.yaml   <--- Paths of configuration files relative to working dir folder which will be loaded in the various python scripts

When I CD to git, and run robot via CLI it works.

robot FW-TEST-RESOURCES/test_cases/test.robot

But when I set up my launch.json for debugging,

    {
       "name": "Robotcode: Run Test with Root CWD",
       "type": "robotcode",
       "request": "launch",
       "target": "${file}",         // Runs the currently active file
       "cwd": "${workspaceFolder}", // Forces CWD to the root (your git folder)
       "args": [],
    }

Problem

Even though I’ve explicitly set "cwd": "${workspaceFolder}", the debugger still sets the current working directory to the base folder of the git repo of the test file (e.g., FW-TEST-RESOURCES/), not the root git/ folder.

This breaks my logic because:

  • I load input_variables.yaml (stored in FW-TEST-RESOURCES/), which contains relative paths from the git folder pointing at paths inside FW folder.

  • My Python code in FW/ expects to resolve these paths relative to the root project folder (git/), since cwd is wrong, when I prepend Path.cwd() to the relative path, I get errors like:

    FileNotFoundError: Configuration file 'git/FW-TEST-RESOURCES/FW/configs/config.yaml' not found!

    When the expected path would be git/FW/configs/config.yaml

I have also tried hardcoding the cwd in launch.json to the absolute path of the git folder, with same result.

How can I make VSCode and robotcode use the actual workspace root (git/) as the working directory during debug runs? So it works as when I run it from CLI with robot

1 Answer 1

0

It is possible to make robotcode use the git folder as EXECDIR by placing a robot.toml file in that folder.

New contributor
StochasticEntropy is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Sign up to request clarification or add additional context in comments.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
What should that file contain?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.