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

WIP: proof-of-concept busted test setup #134

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mikavilpas
Copy link
Contributor

This PR takes some baby steps towards solving
#107

Short explanation of the commit

To get started,

  • install luarocks
  • run luarocks --local install nlua to install https://github.com/mfussenegger/nlua which is needed for running busted locally
  • run make init to install the necessary dependencies
  • run eval $(luarocks path --no-bin --lua-version 5.1) (seems to be required on osx) to set up the luarocks path, which is needed to run the tests locally
  • run make test to run the tests
  • optionally, use a file watcher like https://github.com/watchexec/watchexec to automatically run the tests when files change

Current status

  • some of the tests are failing, but the setup is working
  • not sure about ci, but it's the same setup as in https://github.com/mikavilpas/yazi.nvim and that works, so it can be incrementally copied over when in doubt
  • I meant to finish this in one go, but it proved more challenging than I originally thought so I'm sending this as a WIP

Recommendations

  • I might have missed some crucial setup steps, so let me know if something doesn't make sense
  • I think it's possible to implement some things diferently, so if you have some preferences, we can simplify the setup (or complicate it 😄)

https://github.com/nvim-neorocks/nvim-busted-action

image
(2 tests pass and one fails for me)

mikavilpas and others added 2 commits November 1, 2024 19:17
This PR takes some baby steps towards solving
andrewferrier#107

Short explanation of the commit
===============================

To get started,
- install luarocks
- run `luarocks --local install nlua` to install
  https://github.com/mfussenegger/nlua which is needed for running
  busted locally
- run `make init` to install the necessary dependencies
- run `eval $(luarocks path --no-bin --lua-version 5.1)` (seems to be
  required on osx) to set up the luarocks path, which is needed to run
  the tests locally
- run `make test` to run the tests
- optionally, use a file watcher like
  https://github.com/watchexec/watchexec to automatically run the tests
  when files change

Current status
==============

- some of the tests are failing, but the setup is working
- not sure about ci, but it's the same setup as in
  https://github.com/mikavilpas/yazi.nvim and that works, so it can be
  incrementally copied over when in doubt
- I meant to finish this in one go, but it proved more challenging than
  I originally thought so I'm sending this as a WIP

Recommendations
===============

- I might have missed some crucial setup steps, so let me know if
  something doesn't make sense
- I think it's possible to implement some things diferently, so if you
  have some preferences, we can simplify the setup (or complicate it 😄)

https://github.com/nvim-neorocks/nvim-busted-action
@mikavilpas
Copy link
Contributor Author

Looks like CI is also able to run these tests - although right now the same failure is also reflected there. 👍🏻

.PHONY: init test

init:
luarocks init --no-gitignore
Copy link
Owner

Choose a reason for hiding this comment

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

Would be great to add the luarocks --local install nlua here also. And shouldn't the busted install be local also?

@andrewferrier
Copy link
Owner

Sounds like a good start. I can't get this to run though, when I run make test I get Missing dependencies for debugprint.nvim scm-1: plenary.nvim (not installed).

@andrewferrier
Copy link
Owner

OK, with some more changes to the Makefile I got the tests to run, now looks like:

init:
	luarocks --lua-version 5.1 init --no-gitignore
	luarocks --lua-version 5.1 install --local busted 2.2.0-1
	luarocks --lua-version 5.1 install --local plenary.nvim
	luarocks --lua-version 5.1 install --local nlua

@andrewferrier
Copy link
Owner

I'm finding the first test fails, unfortunately, it looks like probably some filetype detection issue:

spec/debugprint/debugprint_spec.lua:4: Expected objects to be the same.
Passed in:
(table: 0x7dbb81d8f370) {
  [1] = 'foo'
 *[2] = 'No debugprint configuration for filetype ; see https://github.com/andrewferrier/debugprint.nvim?tab=readme-ov-file#add-custom-filetypes'
  [3] = 'bar' }
Expected:
(table: 0x7dbb81d8f148) {
  [1] = 'foo'
 *[2] = 'print('DEBUGPRINT[1]: 0.lua:1 (after foo)')'
  [3] = 'bar' }

Worse, the tests quit out directly afterward and don't run the first of the test suite.

@mikavilpas
Copy link
Contributor Author

Yeah, I get the same thing. It looks like on the main branch the fileconfig is the following:

$ make
nvim --headless --clean -u tests/minimal.vim -c "PlenaryBustedFile tests/debugprint.lua"
Scheduling: tests/debugprint.lua

========================================
Testing:        /Users/mikavilpas/git/debugprint-main/tests/debugprint.lua
Success ||      can do setup() can do basic setup
🤔 DEBUGPRINT[1]: init.lua:135: fileconfig={
  find_treesitter_variable = <function 1>,
  left = "print('",
  mid_var = "' .. vim.inspect(",
  right = "')",
  right_var = "))"
}
Success ||      can do basic debug statement insertion can insert a basic statement below

Success:        2
Failed :        0
Errors :        0
========================================

But on this branch, fileconfig is nil

luarocks test --local

debugprint.nvim scm-1 depends on plenary.nvim (scm-1 installed: success)

debugprint.nvim scm-1 depends on nlua (0.2.0-1 installed: success)
●🤔 DEBUGPRINT[1]: init.lua:135: fileconfig=nil◼●
2 successes / 1 failure / 0 errors / 0 pending : 0.011771 seconds

Failure → spec/debugprint/debugprint_spec.lua @ 64
can do basic debug statement insertion can insert a basic statement below
spec/debugprint/debugprint_spec.lua:5: Expected objects to be the same.
Passed in:
(table: 0x0100fdc2e0) {
  [1] = 'foo'
 *[2] = 'No debugprint configuration for filetype ; see https://github.com/andrewferrier/debugprint.nvim?tab=readme-ov-file#add-custom-filetypes'
  [3] = 'bar' }
Expected:
(table: 0x0100fdc0b8) {
  [1] = 'foo'
 *[2] = 'print('DEBUGPRINT[1]: 0.lua:1 (after foo)')'
  [3] = 'bar' }

stack traceback:
        spec/debugprint/debugprint_spec.lua:5: in function 'check_lines'
        spec/debugprint/debugprint_spec.lua:74: in function <spec/debugprint/debugprint_spec.lua:64>


E5113: Error while calling lua chunk: [NULL]

Error: test suite failed.
make: *** [test] Error 1

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