robotcodedev / robotcode

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

[BUG] Cannot run tests in a folder with double underscores name #175

Closed massonal closed 8 months ago

massonal commented 8 months ago

Describe the bug The extension won't run test files contained in a folder whose name is enclosed in underscores. Typically example: ~/__foldername__/trivial_suite.robot. Syntax higlighting, autocompletion, documentation pop-up work fine, but there is no "Run Test" button in the margin. The "Run Current File" command from the VSCode commande palette also fails, stating "no test found in this file".

To Reproduce Steps to reproduce the behavior:

  1. Create a test suite in a folder with the required pattern ("__folder_name__"). The Robot file can be nested arbitrarily deeply.
  2. Fill the suite with some tests (trivial tests suffice here). 3a. Try to run the test from the VSCode command palette. This should not work. 3b. Try to run the test from the "Run test" button in the margin. The button should not be present. 3c. Try to run the test from VSCode's test panel. The test should not be detected.
  3. Try to run the test from a shell by invoking Robot directly. This should work.

Expected behavior All the options mentioned in step 3. above should be present and functional.

Desktop (please complete the following information):

Addition Notes Is this behavior actually intentional? Feel free to move this issue to a suggestion for improvement; the current behavior is actually an issue for me in my current workspace.

d-biehl commented 8 months ago

Unfortunately it is not a bug and it works exactly as it should.

RobotCode finds all tests and test suites exactly as Robot Framework does, it uses Robot Framework's algorithm. Files and directories starting with an underscore are ignored, see also the Robot Frameworks documentation https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#suite-directories.

You can edit the files, with completion and syntax highlighting etc. but it is not a valid test suite to check if tests are included.

What exactly do you have in mind? Why do you want underscores in your suite name?

massonal commented 8 months ago

Thanks for the reply. I was not aware of this limitation, as I usually cd at or below the offending folder when running tests.

The workspace I'm working with has a __INTERNAL_TOOLS__ folder at the root, where we store, well, internal tools. We use Robot to test some of these tools, and I would like to run these tests from inside VSCode.

The point, I guess, is that you can have several "projects" in the same workspace, so recusing makes sense.

I have just tried opening __INTERNAL_TOOLS__/toolA/ as a workspace, and in this situation the robotcode extension behaves as I'd expect. This makes sense given your explanations, but it is counter-intuitive to me... So, I'd like this changed, but I understand if you wouldn't.

d-biehl commented 8 months ago

There is a setting robotcode.robot.paths in which you can define the paths in which Robot should search for *.robot files. You can specify one path or several. Just like you would do on the console with the robot command if you specify multiple directories, files. Maybe it helps if you specify your __INTERNAL_TOOLS__ here. Relative to the root of your working directory should be enough.

e.g. add this to your .vscode/settings.jon

"robotcode.robot.paths": [
  "__INTERNAL_TOOLS__"
]

or

"robotcode.robot.paths": [
  "__INTERNAL_TOOLS__/toolA",
  "__INTERNAL_TOOLS__/toolB"
]

if you want to add only the tools folders where you have robot tests.

If you change the settings via the vscode settings dialog, be sure you have select the workspace tab

massonal commented 8 months ago

Thanks for the tip! That should be sufficient for my usage.