Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support older versions of google test #14

Closed
zotlann opened this issue Dec 21, 2023 · 5 comments · Fixed by #18
Closed

support older versions of google test #14

zotlann opened this issue Dec 21, 2023 · 5 comments · Fixed by #18

Comments

@zotlann
Copy link

zotlann commented Dec 21, 2023

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
Copy link

DiGMi commented Dec 27, 2023

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
Copy link
Author

zotlann commented Dec 27, 2023

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
Copy link
Owner

alfaix commented Dec 29, 2023

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
Copy link
Author

zotlann commented Dec 29, 2023

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
Copy link

alejandroclaro commented Jan 9, 2024

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.

@alfaix alfaix changed the title utils.lua:82: attempt to index local 'path' ( a nil value) support older versions of google test May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants