robotcode
robotcode copied to clipboard
[BUG] Windows Mapped Drives Are Not Understood Properly
Summary
RobotCode ignores a mapped drive's pathing and instead uses a full UNC pathing, resulting in a test suite file not being located properly.
Detail
If you have your repo on a mapped network drive (in my case, via VMware's Shared Folders), although your tests are "discovered", when you click on the Go to Test (Alt+Enter)
icon, instead of using the Windows mapping (e.g., e:\Repos\windows-qa-automation
) it attempts to use the full UNC pathing (e.g. /Shared folders/Repos/windows-qa-automation/tests/MYSUITENAMEHERE.robot
).
Because Windows can't find it, it asks the user if they want to create it.
Additionally, in opening up the suite, the test cases are formatted/discovered properly, but you cannot execute the test cases by clicking on a 'run' arrow.
Prerequisites
- A Windows machine (or VM)*
- Python installed
- The repository on a mapped network drive. Example using VMware's Shared Folders and set to enabled:
- The host's directory leading to the code was something like
C:\Users\myuser\Repos
- Set this share to a mapped drive via PowerShell with something like
net use e: "\\vmware-host\Shared Folders"
- The host's directory leading to the code was something like
* FWIW, In the author's case, it is a Windows 11 Virtual Machine running under VMware Workstation Pro 17.5
Steps to Reproduce
Scenario 1 - code.exe CLI
Note: The author will provide other scenarios as time permits; simply trying to describe the initial scenario here.
- Launch a PowerShell console, and map the shared repo directory as a Windows drive (see example above)
- Run the Code CLI in tunnel mode:
.\code.exe tunnel
(if you've not authorized this tunnel before, you'll need to do so via GitHub) - Connect to this tunnel via VS Code desktop or via https://vscode.dev/
- Make sure you have the following extensions activated:
- Python
- Pylance
- RobotCode
- Click on the 'flask' icon to discover tests (they are discovered as shown below)
- Find a test you're interested in; click the
Go to Test (Alt+Enter)
icon
Issue: VS Code/RobotCode attempts to open the file as a UNC path vs. a file on a mapped drive. The result is that the test cannot be executed.
Screenshots
Tests discovered - repo name is 'doubled'
Robocorp LSP Example:
Video Screen Captures
Note: GIF "videos" are more easily seen if opened in new tab.
Robocorp's LSP Under Scenario 1
Robotcode Under Scenario 1
Expected Behavior
Using Robocorp's LSP, the tests are discovered, you are able to go to the file/test case in question, execute and debug the test.
I would expect the same behavior with RobotCode.
VS Code Output Logs
RobotCode
executeRobotCode: C:\Users\TestUser\.virtualenvs\windows-qa-automation-JN6Q2o76\Scripts\python.exe -u -X utf8 c:\Users\TestUser\.vscode-server\extensions\d-biehl.robotcode-0.75.0\bundled\tool\robotcode --format json --no-color --no-pager discover info
Error: Can't get items for keywords treeview: Error: Request canceled.
executeRobotCode: exit code 0
executeRobotCode: exit code 0
executeRobotCode: C:\Users\TestUser\.virtualenvs\windows-qa-automation-JN6Q2o76\Scripts\python.exe -u -X utf8 c:\Users\TestUser\.vscode-server\extensions\d-biehl.robotcode-0.75.0\bundled\tool\robotcode --format json --no-color --no-pager --default-path . profiles list
executeRobotCode: exit code 0
executeRobotCode: exit code 0
executeRobotCode: exit code 0
Error: Can't get items for keywords treeview: Error: Request canceled.
RobotCode Language Server
none
Environment
- VS Code Version:
1.86.1
- RobotCode Version:
v0.74.0
- OS:
Windows 11 Enterprise
- Python Version:
3.10.11
- RobotFramework Version:
6.0
-
robotframework-robocop
=4.2.1
I use the Python method pathlib.Path.resolve
in some places to get a normalized file name. Depending on how the command line parameters are, I sometimes have absolute paths or relative paths, which can also contain things like ..
, under Windows even the upper/lower case is irrelevant. But since VSCode internally only works with URI's and these can only be absolute paths and are also case sensitive when comparing, I need a way to make sure that a filename I supply to VSCode is absolute and normalized.
Unfortunately, the python method pathlib.Path.resolve
has the habit of resolving symbolic links. And you can't turn it off.
In os.path
there is also no real way to do this without the symbolic link resolution.
Maybe someone knows an algorithm, function or something else in Python that can do this?
Otherwise I'll have to write one myself.
But problem recognized, I know what to do, but maybe it takes a litte time...
Tests discovered - repo name is 'doubled'
In contrast to RFLS, RobotCode uses RobotFramework algorithms to recognize which suites/test cases/tasks are in the project. Therefore, the test case structure in RobotCode looks and behaves exactly the same as in RobotFramework execution/reports or logs. You can even use --include --exclude or PreRunModifier if you define them in the (attention spoiler) robot.toml
.
And with RobotCode you can open several RobotFramework projects/folders in the same workspace, all of which have completely different Python interpreters, RobotFramework versions etc..
Therefore the top node is the folder/project name, the second node is not duplicated, but the suite name of RobotFramework. You can also customize the name of the suite via command line, (spoiler) robot.toml
file, or also with name
in *** Settings ***
, but also define paths where RobotCode should search for test cases, this corresponds to the call robot folder1 folder2
.