R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
132 stars 15 forks source link

Add testing to `rmd.lua` #40

Closed she3o closed 4 months ago

she3o commented 4 months ago

This is a work in progress. Don't pull yet. I will finish it after work.

I am wondering how to test UI in a live neovim environment. I'll look into how MunifTanjim/nui.nvim does it.

she3o commented 4 months ago

Hi @jalvesaq, can you check if the testing infrastructure works on your computer. make test.

jalvesaq commented 4 months ago

I will look at this now...

jalvesaq commented 4 months ago

The output:

tmp-R-Nvim (test-rmd.lua|✔) » tests/run
Adding plenary.nvim: https://github.com/nvim-lua/plenary.nvim -> tests/xdg/local/share/nvim/site/pack/testing/start/plenary.nvim
fatal: 'tests/xdg/local/share/nvim/site/pack/testing/start/plenary.nvim' already exists in the index
Adding nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter -> tests/xdg/local/share/nvim/site/pack/testing/start/nvim-treesitter
fatal: 'tests/xdg/local/share/nvim/site/pack/testing/start/nvim-treesitter' already exists in the index
Testing dependencies are now available.
nvim: Argument missing after: "-l"
More info with "nvim -h"
she3o commented 4 months ago

I have no idea why this happens. It works fine for me.

eval $(luarocks path --lua-version 5.1 --bin) && busted --run r_tests
Adding plenary.nvim: https://github.com/nvim-lua/plenary.nvim -> tests/xdg/local/share/nvim/site/pack/testing/start/plenary.nvim
fatal: 'tests/xdg/local/share/nvim/site/pack/testing/start/plenary.nvim' already exists in the index
Adding nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter -> tests/xdg/local/share/nvim/site/pack/testing/start/nvim-treesitter
fatal: 'tests/xdg/local/share/nvim/site/pack/testing/start/nvim-treesitter' already exists in the index
Testing dependencies are now available.
✱●●●Error creating directory: Vim:E739: Cannot create directory /create_me: permission denied●
4 successes / 0 failures / 1 error / 0 pending : 5.108663 seconds

Error → ./tests/r/rmd_spec.lua @ 28
rmd module is_in_code_chunk(language, verbose) Unit Tests returns true if in R chunk
./tests/r/rmd_spec.lua:30: Invalid method: is_in_code_chunk

E5113: Error while calling lua chunk: [NULL]make: *** [Makefile:11: test] Error 1

It seems like there is a dependency requirement that's satisfied on my machine. can you ensure that Busted is compatible with the Lua version that Neovim uses

luarocks install --lua-version 5.1 --local busted

and that the 5.1 interpreter is in $PATH

whereis lua5.1

tests/run fails after running

nvim --cmd 'set loadplugins' -l "$@"

This means whatever runs tests/run doesn't send $@ correctly. So there is something different with Busted

she3o commented 4 months ago

I just realized you ran tests/run instead of make test which may explain why this error happened.

make test runs eval $(luarocks path --lua-version 5.1 --bin) && busted --run r_tests which uses ./.busted to execute tests/run

jalvesaq commented 4 months ago

Output of make test:

» make test
eval $(luarocks path --lua-version 5.1 --bin) && busted --run r_tests
Adding plenary.nvim: https://github.com/nvim-lua/plenary.nvim -> tests/xdg/local/share/nvim/site/pack/testing/start/plenary.nvim
fatal: 'tests/xdg/local/share/nvim/site/pack/testing/start/plenary.nvim' already exists in the index
Adding nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter -> tests/xdg/local/share/nvim/site/pack/testing/start/nvim-treesitter
fatal: 'tests/xdg/local/share/nvim/site/pack/testing/start/nvim-treesitter' already exists in the index
Testing dependencies are now available.
◼◼◼◼◼◼●●●Error creating directory: Vim:E739: Cannot create directory /create_me: permission denied●
4 successes / 6 failures / 0 errors / 0 pending : 0.005113 seconds

Failure → ./tests/r/rmd_spec.lua @ 23
rmd module is_in_code_chunk(language, verbose) Unit Tests returns true if in R chunk
./tests/r/rmd_spec.lua:23: Expected objects to be the same.
Passed in:
(boolean) false
Expected:
(boolean) true

Failure → ./tests/r/rmd_spec.lua @ 24
rmd module is_in_code_chunk(language, verbose) Unit Tests returns false if outside R chunk
./tests/r/rmd_spec.lua:24: Expected objects to be the same.
Passed in:
(boolean) false
Expected:
(boolean) true

Failure → ./tests/r/rmd_spec.lua @ 25
rmd module is_in_code_chunk(language, verbose) Unit Tests returns true if in Python chunk
./tests/r/rmd_spec.lua:25: Expected objects to be the same.
Passed in:
(boolean) false
Expected:
(boolean) true

Failure → ./tests/r/rmd_spec.lua @ 26
rmd module is_in_code_chunk(language, verbose) Unit Tests returns false if not in Python chunk
./tests/r/rmd_spec.lua:26: Expected objects to be the same.
Passed in:
(boolean) false
Expected:
(boolean) true

Failure → ./tests/r/rmd_spec.lua @ 27
rmd module is_in_code_chunk(language, verbose) Unit Tests returns true if on an '```{r' line
./tests/r/rmd_spec.lua:27: Expected objects to be the same.
Passed in:
(boolean) false
Expected:
(boolean) true

Failure → ./tests/r/rmd_spec.lua @ 28
rmd module is_in_code_chunk(language, verbose) Unit Tests returns true if on an '```' line that proceeds '```{r'
./tests/r/rmd_spec.lua:28: Expected objects to be the same.
Passed in:
(boolean) false
Expected:
(boolean) true

E5113: Error while calling lua chunk: [NULL]make: *** [Makefile:11: test] Error 1
she3o commented 4 months ago

It works! tests fail because I didn't implement them yet. now we can run tests in live neovim sessions. I will add some helper functions to abstract rpcrequest and nvim_feedkeys.

she3o commented 4 months ago

why is git telling me there are 126 conflicting hunks?

she3o commented 4 months ago

Git is like a Rubik's cube; every way I try to resolve this I make it worse. Do you have a solution to this?

jalvesaq commented 4 months ago

Yes, I messed with it yesterday: https://github.com/R-nvim/R.nvim/issues/27#issuecomment-1958571284 I'm sorry for that. You will have to close this PR and manually do it again on this new repository.

she3o commented 4 months ago

Okay