Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Unable to use non-default robot.toml configuration when running tests from VSCode GUI #333

Open
jhartika opened this issue Oct 16, 2024 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@jhartika
Copy link

I want to have my robot.toml configuration in non-default locations.
For most part this works fine

  • I can run tests through CLI nicely by passing the correct robot.toml in with --config
  • VSCode language server works nicely if I configure robotcode.languageServer.extraArgs

What does not work for me is running/debugging tests with VSCode

  • If I configure robotcode.extraArgs they do not seem to get passed to the robotcode when starting test runs from VSCode GUI (Testing View or Editor). Test runs are started with robot.toml configuration in one of the default paths instead.

Is there an option I am missing that would allow me to configure which robot.toml file to use when starting test runs from VSCode GUI?

  • VS Code Version 1.94.0
  • RobotCode Version [0.93.1]
  • OS: [Windows 10]
  • Python Version [3.11.8]
  • RobotFramework Version [7.0.0]
@jhartika jhartika added the question Further information is requested label Oct 16, 2024
@d-biehl
Copy link
Member

d-biehl commented Oct 16, 2024

How can the robotcode.extraArgs be configured? Could you provide an example?

Additionally, what is the rationale for using non-default locations?

@d-biehl d-biehl changed the title [QUESTION] [QUESTION] Unable to use non-default robot.toml configuration when running tests from VSCode GUI Oct 16, 2024
@jhartika
Copy link
Author

In VSCode there is robotcode.extraArgs setting. I would like to use --config to give path to robot.toml
image

Rationale for non-default locations is that our git repository has tests, which can be ran with multiple different hardware setups.

Based on hardware setup we create configuration file which has arguments for robot, which decide which keyword resource files are used for Suite and Test setup, what communication protocols are used to command the devices, and where related protocol message definitions are.
For language server to work correctly it needs to be aware of python paths and robot variables configured. Similarly for test-runner. It would be ideal if we could use robot.toml as the single source of configuration, instead of defining same configuration multiple times separately for CLI, language server and runner.

Putting the robot.toml in default location and using profiles is a possibility and not out of question. But for my use case maintaining multiple test environment profiles in one file is more complicated than maintaining one robot.toml file per test environment.

@d-biehl d-biehl self-assigned this Oct 16, 2024
@d-biehl
Copy link
Member

d-biehl commented Oct 16, 2024

I will investigate this a bit further. It might be possible to use a launch.json with a default configuration to start tests, but it sounds a bit complicated. Perhaps a VSCode setting to specify different configurations would make more sense, instead of using ExtraArgs.

However, there is another request for supporting multiple TOML files: #282. This might be a better solution for your challenge. The implementation shouldn't take too long. I would lean towards option 2, as you would only need to create the files, and robotcode would take care of the rest. What do you think?

@jhartika
Copy link
Author

Option 1 (config-files directive) in #282 would let me couple the configuration files with the various test_environments in the way I'm looking for. Then I could do

[profiles.test_env1]
config-files = ['test_env1/robot.toml']

[profiles.test_env2]
config-files = ['test_env2/robot.toml']

And still use --config test_env1/robot.toml on the CI pipeline side.

Option 2 falls bit short in that the test_environments would still be decoupled from their configuration files and conflict resolution between configurations for different environments would have to be done inside robot.toml.d/ through profile directive. This would make using same robot.toml on our CI pipeline side more complicated since specifying correct config file wouldn't be sufficient anymore, but profile selection would be necessary on top, even if the config in robot.toml.d/ would only contain one profile.

@d-biehl
Copy link
Member

d-biehl commented Oct 17, 2024

At the moment, you need to use the robotcode.languageServer.extraArgs setting with -c, path_to/config.toml, and if you want to run the tests, you have to create a .vscode/launch.json file in your project and specify the same settings there again.

Something like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "RobotCode: Default",
            "type": "robotcode",
            "request": "launch",
            "presentation": {
                "hidden": true
            },
            "purpose": "default",
            "robotCodeArgs": [
                "-c",
                "path_to/config.toml"
            ]
        }
    ]
}

You need to adjust the paths, of course ;-)

I'm thinking of a way to configure this better, or I'll implement issue #282, or both, but that will take a little while...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants