robotframework-lsp icon indicating copy to clipboard operation
robotframework-lsp copied to clipboard

Accept settings with variable files (to be passed on run and used on code-completion/code analysis, etc).

Open Lomomo opened this issue 3 years ago • 5 comments

Describe the problem:

I have some problems with the run button in .robot file. Because I have many variables import by -V --variablefile path. But I just only can set by -v --variable name:value (As shown below). image

Hope add a new setting option for -V --variablefile path, or provide a setting option to use robot command argument when using run button.

Lomomo avatar Aug 25 '21 07:08 Lomomo

As a note, the current workaround is editing your launch configuration to pass those as arguments for the run...

Still, I agree that it'd be nice to have a way to set the variables from variable files.

fabioz avatar Aug 25 '21 10:08 fabioz

@fabioz Thank you for your reply, let me have the direction to solve it. Refer to the content below, I solved my problem. image

Lomomo avatar Aug 26 '21 05:08 Lomomo

I'm reopening because I think it'd still be useful to have those in the settings (that way, it'd be possible for code-completion to present those variables globally).

fabioz avatar Aug 26 '21 11:08 fabioz

FWIW, I screwed up my launch.json file and it wasn't loading the variables from a YAML file (my preferred way to have runtime variables in a file). This was a real bummer because I really appreciate being able to go into the Test explorer and run any test ad hoc. I tried everything I could think of to get it working again, and was about to give up.

My problem? I made the mistake of renaming the "name": value to something other than "Robot Framework: Launch Template" (I think I had it named Robot Framework: Launch w/ YAML variables).

When I changed it back - voilà!

GLMeece avatar Apr 22 '22 14:04 GLMeece

So for anyone, like me, who still got a bit confused.

  • You need to create a launch configuration with the exact name Robot Framework: Launch Template.
  • That configuration will be used for any run/debug from the Testing tab or CodeLens options.
  • I would also put a comment to prevent people from changing the name of the launch configuration.
    • Only since VS Code doesn't care about JSON comments, which are not allowed in the JSON spec
{
    "version": "0.2.0",
    "configurations": [
        {
            // This template is used when clicking run/debug in the UI.
            // The name must be `Robot Framework: Launch template` for it to work.
            "type": "robotframework-lsp",
            "name": "Robot Framework: Launch template",
            "request": "launch",
            "args": [
                "--variablefile", "${workspaceFolder}\\src\\varfile.py"
            ]
        }
    ]
}

Now, when you click Run a test in the text editor, the command will have the --variablefile argument present.

'--variablefile' 'C:\path\to\project\workspace\src\varfile.py'

I hope it helps.

BambusControl avatar Mar 19 '23 11:03 BambusControl