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

Add TestNearest support for Lua's Busted test runner #598

Merged
merged 9 commits into from Nov 9, 2021

Conversation

mblayman
Copy link
Contributor

This PR updates the busted plugin to add support for TestNearest so that it will execute the nearest test instead of the entire file (which is the current implementation). The modifications handle both it and describe functions. I also wrote some tests for Moonscript to make sure that it works for that style of Lua too.

I made this work by taking advantage of the --filter flag with busted. The --filter flag expects the value to be a proper Lua pattern. Because of that constraint, the plugin does the proper escaping of the Lua pattern "magic characters" (defined in the Lua docs).

There is a small limitation to this implementation. If multiple tests in the same file have the same string description, then TestNearest will run all identically labeled tests. This seemed like an acceptable tradeoff because it's still more accurate than running all the tests in a file.

PR Checklist:

  • Add fixtures and spec when implementing or updating a test runner
  • Update the README accordingly
  • Update the Vim documentation in doc/test.txt

@@ -93,7 +93,7 @@ endfunction
" Instead of taking a "position" argument, this function takes 3:
" - "filename" is the equivalent of "position['file']"
" - "from_line" the line number from where to start the search, is the
" equivalent fo "position['line']"
" equivalent of "position['line']"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for fixing this typo!

Copy link
Collaborator

@codeinabox codeinabox left a comment

Choose a reason for hiding this comment

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

Thank you for taking the time for this great addition, it's super appreciated!

@codeinabox codeinabox merged commit d9e112c into vim-test:master Nov 9, 2021
@mblayman mblayman deleted the busted-nearest branch November 9, 2021 20:39
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.

None yet

2 participants