robocorp / robotframework-lsp

Robocorp extensions for VS Code: Robocorp Code and RFW LSP
https://robocorp.com/docs/developer-tools/visual-studio-code
Apache License 2.0
203 stars 92 forks source link

is there a way i programmatically start the robotframework debugger? #994

Open DetachHead opened 11 months ago

DetachHead commented 11 months ago

Is your feature request related to a problem? Please describe. i've created a pytest plugin that allows you to run robot tests using pytest, as well as generate robot reports for tests written in python: https://github.com/detachhead/pytest-robotframework

since pytest is able to discover robot tests with my plugin, i added an option in #993 to disable the test view to prevent vscode from duplicating the tests.

but when running tests in pytest, breakpoints set in .robot files don't work because it doesn't use the robot lsp extension's debugger

Describe the solution you'd like is there a way i can programmatically start the robotframework debug adapter such that i can enable it when running tests with pytest?

Describe alternatives you've considered i tried just using the listeners located in robotframework_debug_adapter.listeners and robotframework_debug_adapter.events_listener but that didn't seem to do anything

# conftest.py

from pytest_robotframework import listener

def pytest_sessionstart() -> None:
    from robotframework_ls import import_robocorp_ls_core

    import_robocorp_ls_core()
    from robotframework_debug_adapter import events_listener, listeners

    # register these classes as listeners using the pytest-robotframework plugin
    # (equivalent to the `--listener` robot argument)
    listener(listeners.DebugListener)
    listener(listeners.DebugListenerV2)
    listener(events_listener.EventsListenerV2)

so then i tried copying a bunch of code from robotframework_debug_adapter.run_robot__main__ but i don't really understand how it works so i couldn't get that working either.

fabioz commented 11 months ago

The problem isn't getting it working on the server side (adding the listener should be enough), the problem is that on a Python run the breakpoints won't be added to the extension and thus won't be sent to the listener to make the breaks.

So, I don't think you can approach it that way (unless you fork debugpy to make it a hybrid debugger).

Usually what'd be needed in this case is for one of the debuggers to be started in remote debug mode (so, you'd start the python debugger and then do a second connection for the robot debugger -- unfortunately I haven't been able to work on it -- https://github.com/robocorp/robotframework-lsp/issues/775 -- so far and I can't give an estimate on when I'll be able to tackle it given other priorities I have).