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 PlenaryBustedDirectory with more than one option via the command interface #284

Open
williamboman opened this issue Dec 9, 2021 · 1 comment

Comments

@williamboman
Copy link
Contributor

williamboman commented Dec 9, 2021

The docs suggest that one can run a test suite through the PlenaryBustedDirectory command. This seems to take two arguments - the second one being a Lua table of options. I learned that you can only really provide one entry in this table, as doing anything else seem to induce ambiguous syntax and the argument gets translated to something completely else.

For example, the following:

$ nvim --headless -c "PlenaryBustedDirectory tests/plenary/ {minimal_init = '/foobar', sequential=true}"

will make the test harness receive it as:

  local split_string = vim.split(command, " ")
  local directory = table.remove(split_string, 1) 

  print(vim.inspect(split_string)) -- { "minimal_init='/foobar'\n.", "", "sequential=true" }

  local opts = assert(loadstring("return " .. table.concat(split_string, " ")))()

  return harness.test_directory(directory, opts)

I've not researched this much more than this, but it seems like the comma might be the culprit.

To resolve this, I bypassed the command interface and call the Lua API directly instead, like so:

$ nvim --headless -c "lua require('plenary.test_harness').test_directory('.', {minimal_init='/foobar',sequential=true})"

I wonder if the docs should be updated to reflect this, and perhaps even deprecate this particular command interface?

@AckslD
Copy link
Contributor

AckslD commented Feb 5, 2022

Thanks a bunch @williamboman, I had the same issue today and you workaround helped me 👍

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