alfaix / neotest-gtest

Google Test adapter for nvim-neotest
MIT License
42 stars 11 forks source link

ConfigureGtest crashing #16

Closed SGauvin closed 4 months ago

SGauvin commented 5 months ago

When selecting the tests to configure, there is an error making this plugin pretty much unusable. I'm using Neovim 0.9.5 and Lazy

Error executing Lua callback: ...gauvin/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:193: Cannot call async function from non-async context                                               
stack traceback:                                                                                                                                                                               
        [C]: in function 'error'                                                                                                                                                               
        ...gauvin/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:193: in function 'wait'                                                                                                    
        ...uvin/.local/share/nvim/lazy/nvim-nio/lua/nio/control.lua:141: in function 'wait'                                                                                                    
        ...azy/neotest-gtest/lua/neotest-gtest/executables/init.lua:28: in function <...azy/neotest-gtest/lua/neotest-gtest/executables/init.lua:27>

Culprit looks like it's

      nio.api.nvim_buf_create_user_command(buf, "ConfigureGtest", function()
        M.configure_executable().wait()
      end, {})

Was there a breaking change in nio recently that broke this?

msMatix commented 4 months ago

I have the same issue. I would be interested in a solution as well. Have you been able to find anything out?

alfaix commented 4 months ago

I don't think this error actually affects anything, it's just a print. wait() there is redundant and it's the part that causes the error.

Either way, should be fixed with 5ebf583aa5d119b6acfd8077578d05638d6a35f5

Please reopen if you still encounter the issue after updating.

msMatix commented 4 months ago

Unfortunately the error still occurs. The only difference is now, that I do not have the message. Is this also on your setup @SGauvin ?

alfaix commented 4 months ago

@msMatix I'm not sure I follow. I thought the error was calling wait(), or at least that's what the stacktrace says. Are you experiencing a different error? Could you please describe the behavior?

msMatix commented 4 months ago

I thought so, too. Of course so handling would be like this:

  1. toogle summary of neotest
  2. go to the unit tests and press m
  3. Execute cmd: ConfigureGTest

With the wait-fn the stack trace which @SGauvin printed is shown. Unfortunately, on my machine nothing happens.

If I have understood it correctly, an input field should now appear where I enter the path to executable, right?

I use the basic configuration of your plugin:

["neotest-gtest"] = { setup = {}, }

Or should something be called in the setup method?

rag-hav commented 4 months ago

I am facing the same issue. Configuregtest does nothing and makes the plugin unusable

alfaix commented 4 months ago

I use the basic configuration of your plugin:

["neotest-gtest"] = { setup = {}, }

Or should something be called in the setup method?

I'm not sure what plugin manager you're using, but this does not look like it calls neotest-gtest.setup(). The setup function needs to be called. For lazy.nvim, the setup looks like this:

{
    "nvim-neotest/neotest",
    dependencies = {
        "nvim-lua/plenary.nvim",
        "alfaix/neotest-gtest"
        -- your other adapters here
    }
}

And then you add it to adapters:

require("neotest").setup({
  adapters = {
    require("neotest-gtest").setup({})
  }
})

If you don't call setup(), the command ConfigureGtest is not set up.

If you did all that and it still doesn't work, please update all your plugins (neotest, neotest-gtest, nio), and share your neovim version. So far I cannot reproduce the issue.

msMatix commented 4 months ago

ah sorry :). Yeah im using lazyvim in combination with LazyVim-Framework. So the whole configuration looks like yours. Neotest works fine for rust or python. All my plugins are up2date. My neovim version is 0.9.5 /build type: release.

Are interesting that it works on your machine. Do you use nightly build?this is sometimes a problem for the release user

rag-hav commented 4 months ago
:version
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1692716794

All plugins up to date.

Lazy configuration


  {
    "nvim-neotest/neotest",
    dependencies = {
      "alfaix/neotest-gtest",
      "nvim-neotest/nvim-nio",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter"
    },
    config = function()
      require("neotest").setup({
        adapters = {
          require("neotest-gtest").setup({})
        }
      })

    end

  },
alfaix commented 4 months ago

Hey @rag-hav @msMatix ,

I think I managed to reproduce the bug with 0.9.5, but for me this only happens with the first time you run ConfigureGtest. Second, third, and so forth, work as expected. I think this might have something to do with either some change in nio coroutines or lazy's particular loading order.

For now, could you please check on your machines if running ConfigureGtest again works, so I would know if this is indeed the same issue?

msMatix commented 4 months ago

Hey alfaix,

thanks for checking the version out! Which kind of version do you use for nvim?

I have tried running the cmd ConfigureGTest more than once. Unfortunately, my terminal freezes the second time (wezterm, konsole). I have also switched off the lazy loading of neotest. However, this did not help either.

alfaix commented 4 months ago

Ah I think I figured out the bug (or found a completely unrelated one I suppose).

17 should fix it - could you please update the plugin and try again?

Thank you a lot for your patience :)

msMatix commented 4 months ago

Yeah nice! This time I am able to type in the executable path. Unfortunately it does not find it. So the path to my executable is: ./build/tst/my_test. My tests are in ./tst/test_foo.cpp. So what must be the path which I have to configure? I get this hint:

 Warn 09:23:39 PM notify.warn Neotest neotest-gtest: ...e/matix/.local/share/nvim/lazy/nvim-nio/lua/nio/init.lua:119: The coroutine failed with this message: ...hare/nvim/lazy/neotest-gtest/lua/neotest-gtest/utils.lua:82: attempt to index local 'path' (a nil value) stack traceback: ...hare/nvim/lazy/neotest-gtest/lua/neotest-gtest/utils.lua: in function 'normalize_path' ...are/nvim/lazy/neotest-gtest/lua/neotest-gtest/report.lua:25: in function 'position_id' ...are/nvim/lazy/neotest-gtest/lua/neotest-gtest/report.lua:18: in function 'new' ...are/nvim/lazy/neotest-gtest/lua/neotest-gtest/report.lua:219: in function 'results' ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:132: in function '_run_spec' ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:89: in function <...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:88> stack traceback: ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:89: in function <...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:88> [C]: in function 'error' ...e/matix/.local/share/nvim/lazy/nvim-nio/lua/nio/init.lua:119: in function 'gather' ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:94: in function '_run_tree' ...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:65: in function <...al/share/nvim/lazy/neotest/lua/neotest/client/runner.lua:22> [C]: in function 'xpcall' ...ocal/share/nvim/lazy/neotest/lua/neotest/client/init.lua:84: in function 'run_tree' ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:73: in function 'func' .../matix/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:173: in function <.../matix/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:172>

alfaix commented 4 months ago

@msMatix This one looks like #14 , unless you're using latest version of Google test.

The problem is that older versions do not contain filepath in test results, so it has to be remembered by the plugin. I plan to add support for it next time I have some free time - hopefully later this week.

Meanwhile I'll close this issue as solved - if you are using latest googletest version, please reopen

msMatix commented 4 months ago

Thank you for the tip! I'm actually using 1.11 and not 1.14. I'll test it tomorrow and let you know!

Thank you very much for your support!

msMatix commented 4 months ago

works for me now! Thank you again for the support! :)