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

Running tests in docker container #38

Open
guess opened this issue Jun 17, 2024 · 1 comment
Open

Running tests in docker container #38

guess opened this issue Jun 17, 2024 · 1 comment

Comments

@guess
Copy link

guess commented Jun 17, 2024

Hi! I am trying to run my tests in a docker container, however I am getting these errors because it can't find the formatter.ex and json_encoder.ex in my container:

-r : No files matched pattern /Users/steve/.local/share/nvim/lazy/neotest-elixir/neotest_elixir/json_encoder.ex
-r : No files matched pattern /Users/steve/.local/share/nvim/lazy/neotest-elixir/neotest_elixir/formatter.ex

Is there a way to override these paths somehow so I can mount the files and point to the new location in the container?

Here is how I am setting it up:

require("neotest").setup({
  log_level = vim.log.levels.DEBUG,
  adapters = {
    require("neotest-elixir")({
      post_process_command = function(cmd)
        return vim.tbl_flatten({
          { "docker", "compose",     "exec", "-i" },
          { "-w",     "/app" },
          { "-e",     "MIX_ENV=test" },
          { "app" },
          cmd })
      end,
    }),
  },
})

Or do you have a better recommendation for how to run these in docker instead?

@jfpedroza
Copy link
Owner

Running inside Docker is tricky. See nvim-neotest/neotest#89. Most of the issues mentioned there apply to the Elixir adapter as well.

You could overwrite the paths in post_process_command. If everything works, we can add an option to specify the base path when configuring the adapter. Besides that, the formatter receives an env var with the path where it's going to write the output files. When running inside a container, those files would be in the container, so they would need to be mounted as well so that the Neovim side can read them.

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

No branches or pull requests

2 participants