alfaix / neotest-gtest

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

support older versions of google test #14

Closed zotlann closed 3 months ago

zotlann commented 8 months ago

This happens whenever I try to run tests with this adapter, but is easily reproducible with my small aocpp repo. Steps to reproduce and full error output below.

  1. build aocpp project ./build.sh -c -b -g
  2. open nvim in aocpp directory
  3. run :Neotest summary.
  4. navigate to tests/unit/source/day01_test.cpp/Day01Test
  5. mark Ascend
  6. run :ConfigureGtest with output/bin/LibAOCPPUnit
  7. navigate to the day01_test.cpp file and hover over the TEST(Day01Test, Ascend) line
  8. run `lua require("neotest").run.run()

Error output:

neotest-gtest: ...ovan.com/.local/share/nvim/lazy/neotest/lua/nio/init.lua:105: 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:131: 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>

neotest version:

commit 761019816a004897845b45466cece4ae3d357bb2 (HEAD -> master, tag: v4.2.1, origin/master, origin/HEAD)

neotest-gtest version:

commit 6e794ac91f4c347e2ea5ddeb23d594f8fc64f2a8 (HEAD -> main, origin/main, origin/HEAD)

nvim version:

NVIM v0.10.0-dev-1920+gaf93a74a0
Build type: RelWithDebInfo
LuaJIT 2.1.1702233742

neotest config:

local neotest = require("neotest")
local gtest = require("neotest-gtest")

neotest.setup({
    adapters = {
        gtest.setup({
        })
    },
})
DiGMi commented 8 months ago

Hi, I had the same problem. Upgrading the gtest library solved the issue, as older versions do not report the test file name in the json test results.

zotlann commented 8 months ago

That makes sense, updating gtest to a new version for what I can seems to work. Unfortunately I can't do this for all of my work projects, but this will work for now. Thanks.

alfaix commented 8 months ago

Hey! Sorry, not a whole lot of time to look into this during the holidays.

Could you please provide the gtest version that doesn't include the file path in results, so I can look for a workaround?

That said, using anything from Google and going against their "live at head" will likely yield other issues too.

zotlann commented 8 months ago

I was actually able to work around my work build infrastructure stuff to use a newer version of gtest. We have to support older versions for reasons, but at least for local development I can use the newer versions usually without issue. The version I was running into this issue with was 1.10, not sure if it is worth the effort to add a workaround.

Thanks for your work on this!

alejandroclaro commented 8 months ago

Same problem here with version 1.10.

Any chance this can be solved without needing a newer version?

Looks like the only issue is knowing the file name from a test name, but this should be possible with the registry generated using ConfigureGtest instead of from the GTest JSON output.