olimorris / neotest-phpunit

🧪 Neotest adapter for PHPUnit
MIT License
28 stars 22 forks source link

Debug via summary is not working #25

Open eerison opened 4 months ago

eerison commented 4 months ago

after get last updates the DAP is not working anymore :/

I tried to do this

dap = dap.configurations.php[1],

...

dap.defaults.fallback.switchbuf = "useopen"

But it is not working :/

it is my config: https://github.com/eerison/lazyvim/blob/main/lua/plugins/php.lua#L34

do you have any example to set this with lazyvim?

eerison commented 4 months ago

maybe it is not working because I am using: mason-nvim-dap ....

przepompownia commented 4 months ago

@eerison could you start with some minimal example? I especially mean no additional plugins and no containerized environment to elminiate external dependencies.

I updated https://github.com/przepompownia/neotest-phpunit-example to ensure if it works with recent dependencies on the provided example and then fixed it to work on some real project too. I used unit tests from Phpactor and they work. You can try it too at the start or provide other minimal repro.

eerison commented 4 months ago

Hey @przepompownia I guess it was related with other dependency, I guess it was on https://github.com/williamboman/mason-lspconfig.nvim

after I update it, it is not losting the buffer file as you described here: https://github.com/olimorris/neotest-phpunit?tab=readme-ov-file#debugging-with-dap-strategy

it is working, but I use like ... add a break point and execute DAP debugger, after this I execute the tests and it works as expect. I am not using d from summary ... I guess to make this work I need to set dap on neotest.

eerison commented 4 months ago

I guess it should work out the box: https://github.com/nvim-neotest/neotest?tab=readme-ov-file#strategies in theory when run via summary d it executes require("neotest").run.run({strategy = "dap"}) ...

in theory you could get the dap from there, don't you?

eerison commented 4 months ago

I am getting this error message:

 Warn 16:18:52 notify.warn Neotest neotest-phpunit: ...e/nvim/lazy/neotest-phpunit/lua/neotest-phpunit/init.lua:16: dap: expected not empty table, got nil. Info: Configure dap field (like in dap.configurations.php) before using this strategy

I tried like this: dap = require("dap").configurations[1], (https://github.com/eerison/lazyvim/blob/main/lua/plugins/php.lua#L85) But it didn't work :'(

I don't know how to make it work :(

przepompownia commented 4 months ago

Look at your configurations. I'm not sure if it's saved directly into dap.configurations. Notice that it's a list of tables. Try to add php key, i.e.

config.configurations = {
  php = {
    type = ...

You can try also declare dap.configurations directly like in README here (with your settings inside).

przepompownia commented 4 months ago

What lua vim.print(require'dap'.configurations.php) shows you?

przepompownia commented 4 months ago

Does your DAP configuration work outside neotest?

While debugging you can also assign duplicated adapter configuration table directly under dap key of neotest-phpunit configuration.

eerison commented 1 month ago

lua vim.print(require'dap'.configurations.php)

{ {
    name = "Listen for Xdebug",
    pathMappings = {
      ["/app"] = "${workspaceFolder}"
    },
    port = 9003,
    request = "launch",
    type = "php"
  }, {
    name = "PHP: Listen for Xdebug",
    port = 9000,
    request = "launch",
    type = "php"
  } }