stevanmilic / neotest-scala

MIT License
26 stars 15 forks source link

Error message when running munit tests #2

Closed justinhj closed 2 years ago

justinhj commented 2 years ago

Hi Stevan

I've never used neotest but I was looking for something like this so tried it out. Forgive me if this is user error, but I ran into some problem.

I'm running bloop and metals latest versions. I installed neotest and your plugin.

My config...

require("neotest").setup({
  adapters = {
    require("neotest-scala")({
        -- Command line arguments for runner
        -- Can also be a function to return dynamic values
        args = {"--no-color"},
        -- Runner to use. Will use bloop by default.
        -- Can be a function to return dynamic value.
        -- For backwards compatibility, it also tries to read the vim-test scala config.
        -- Possibly values bloop|sbt.
        runner = "bloop",
        -- Test framework to use. Will use utest by default.
        -- Can be a function to return dynamic value.
        -- Possibly values utest|munit|scalatest.
        framework = "munit",
    })
  }
})
E5108: Error executing lua ...im/localplugins/plenary.nvim/lua/plenary/async/async.lua:14: The coroutine failed with this message: .../nvim/localplugins/neotest/lua/neote
st/consumers/run.lua:32: attempt to index upvalue 'client' (a nil value)                                                                                                  
stack traceback:                                                                                                                                                          
        [C]: in function 'error'                                                                                                                                          
        ...im/localplugins/plenary.nvim/lua/plenary/async/async.lua:14: in function 'callback_or_next'                                                                    
        ...im/localplugins/plenary.nvim/lua/plenary/async/async.lua:40: in function 'step'                                                                                
        ...im/localplugins/plenary.nvim/lua/plenary/async/async.lua:43: in function 'execute'                                                                             
        ...im/localplugins/plenary.nvim/lua/plenary/async/async.lua:103: in function 'run'  

I ran this on my file which has an munit.FunSuite

lua require("neotest").run().run()

stevanmilic commented 2 years ago

I'll check it out, thanks for reporting.

stevanmilic commented 2 years ago

hmm seems like a neotest issue, like you didn't run the setup of the plugin. Can you post the test file you're trying to run? Or just a minimal example for me to try to reproduce.

justinhj commented 2 years ago

Sure I'm running against my project here https://github.com/justinhj/duct.git

I was using this file but I had to rename it because I'm not using the names that the test expects. I changed to Semigrouptests.scala

https://github.com/justinhj/duct/blob/master/core/src/test/scala/org/justinhj/duct/SemigroupTests.scala

stevanmilic commented 2 years ago

I've successfully ran tests in your project, but I had to:

  1. add a commit https://github.com/stevanmilic/neotest-scala/commit/9d6ae97810a80eeb3ad85e5f3759fcf7e055f817 that can now run test suites without package set.
  2. add name := "core" line in your build.sbt in order to explicitly set the project name, as I didn't implement resolving lazy definition of projects

The second point could also be done by explicitly passing project name to neotest-scala adapter, I'll add that too.

But do tell me if this fixes your problem, since I haven't received the error you reported.

stevanmilic commented 2 years ago

I've added 2b69ab06ab98b079561a1e4f595d55eeda35406c so project name should be resolved automatically, you can try again now.

justinhj commented 2 years ago

Hi Stevan, thanks for the troubleshooting. It turns out neotest is not setup correctly, I get the same error with a lua test. I'll figure that out and come back and close this once I've confirmed no issue.

justinhj commented 2 years ago

Still can't get neotest working but I'll close this since it's clearly not the problem.