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(busted): option to filter tests to run by pattern [wip] #378

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joeveiga
Copy link
Contributor

@joeveiga joeveiga commented Jun 12, 2022

This is a step towards being able to run individual tests. See #343.
I'm just starting with lua and vim plugin development as well so, be gentle 😆.

Kapture 2022-06-12 at 16 01 28

Todo

  • Document the changes.
  • Fix vim command (not sure how to parse the options correctly or serialize a lua table to be passed down, please see TODOs in the code).

@@ -214,7 +233,9 @@ after_each = mod.after_each
clear = mod.clear
assert = require "luassert"

mod.run = function(file)
mod.run = function(file, opts)
_PlenaryBustedOpts = vim.tbl_deep_extend("force", {}, opts or {})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing a global is technically fine because busted is already run in another process. But can't we do

-- top of the file
local busted_opts

--- ......

mod.run = function(file, opts)
  busted_opts = vim.F.if_nil(opts, {})
-- ...
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks! Although I did a vim.F.if_nil(opts, {}, opts) (3rd arg) 👍

@Conni2461
Copy link
Collaborator

Overall Looks good. Thanks :)

@joeveiga joeveiga marked this pull request as draft June 12, 2022 20:35
@joeveiga
Copy link
Contributor Author

joeveiga commented Jun 12, 2022

Overall Looks good. Thanks :)

Thanks @Conni2461!
Could you perhaps help me out with some guidance on how to fix the PlenaryBustedDirectory command? I tried modifying the Makefile when testing this to include the filter option in the second argument, but that breaks here:

-- TODO: this is broken if we pass mutliple args!

It seems we're doing some hacking there to parse the second argument as a lua table manually? But adding a second field to the table causes an error. I'm guessing it doesn't like the comma in {minimal_init = 'tests/minimal_init.lua', filter = 'test'}?

EDIT: found this #284

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.

2 participants