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

feat: add ability to pass args as function instead of table #188

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

fredrikaverpil
Copy link
Owner

@fredrikaverpil fredrikaverpil commented Sep 17, 2024

Fixes #186

Why?

Some users need to dynamically generate the go test command on each test run.

What?

Supply a function instead of a table as go test args:

Please give something like this a try:

return {
  {
    "nvim-neotest/neotest",
    dependencies = {
      "nvim-neotest/nvim-nio",
      "nvim-lua/plenary.nvim",
      "antoinemadec/FixCursorHold.nvim",
      "nvim-treesitter/nvim-treesitter",
      {
        "fredrikaverpil/neotest-golang", -- Installation
        branch = "args-function", -- Custom branch
      },
    },
    config = function()
      local opts = { -- Specify configuration
        go_test_args = function()
          -- Place your custom logic here for the 'go test' args
          return {
            "-v",
            "-race",
            "-count=1",
            "-coverprofile=" .. vim.fn.getcwd() .. "/coverage.out",
          }
        end,
      }
      require("neotest").setup({
        adapters = {
          require("neotest-golang")(opts), -- Apply configuration
        },
      })
    end,
  },
}

@fredrikaverpil fredrikaverpil self-assigned this Sep 17, 2024
@fredrikaverpil fredrikaverpil force-pushed the args-function branch 5 times, most recently from 6d48210 to 2b266db Compare September 18, 2024 19:22
@fredrikaverpil fredrikaverpil marked this pull request as ready for review September 18, 2024 19:22
@fredrikaverpil fredrikaverpil changed the title feat(runners): add ability to pass in function as args feat: add ability to pass in function as args Sep 18, 2024
@fredrikaverpil fredrikaverpil changed the title feat: add ability to pass in function as args feat: add ability to pass args as function instead of table Sep 18, 2024
@fredrikaverpil fredrikaverpil merged commit c5df84c into main Sep 18, 2024
8 checks passed
@fredrikaverpil fredrikaverpil deleted the args-function branch September 18, 2024 19:33
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 this pull request may close these issues.

feature: test args evaluated at runtime
1 participant