Running PlenaryBustedDirectory with more than one option via the command interface

Open
#284 1 comment 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
lua

Research direction

Start with the PlenaryBustedDirectory command interface and compare its argument handling with the directly invoked test_harness.test_directory API shown in the report. Reproduce the multi-option command, then determine whether the supported outcome should be corrected command parsing or documentation of the API workaround; the issue is done when the chosen behavior is verified and clearly documented.

Written by the indexing model from the issue text.

Description

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?

Dominant language
Lua
Stars
3.5k
Forks
340
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nvim-lua/plenary.nvim

All issues in nvim-lua/plenary.nvim

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.