nvim-neotest / neotest-go

MIT License
124 stars 43 forks source link

feat: support nested go modules (monorepo) #87

Closed troyanov closed 2 months ago

troyanov commented 3 months ago

In case of a monorepo project (e.g. Python + Go) go.mod might be located somewhere in nested directories, but not in the project root. This leads to an issue when running test from the Summary window.

With this change location variable (from the Summary window) is exposed to the args function, so additional logic can be used based on the path.

Example:

args = function(location)
  local Path = require('plenary.path')
  local current_dir = Path:new(location):parent()
  local module_dir = current_dir:find_upwards('go.mod'):parent()
  local coverprofile = module_dir .. '/cover.out'
  print('Generated coverprofile:' .. coverprofile)
  return {
    '-coverprofile=' .. coverprofile,
  }
end