R-nvim / R.nvim

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

Modify test setup to allow testing in live Neovim sessions. #50

Closed she3o closed 7 months ago

she3o commented 7 months ago

This commit will allow us to test the plugin in a live Neovim session. It also includes TODOs and pending() for future implementation.

she3o commented 7 months ago

Hi, I think this PR is mature enough now. I will fix any shortsightedness and implement some of the pending tests after my work shift.

jalvesaq commented 7 months ago

With make test I got this:

tmp-R-Nvim (test-infrastructure|✔) » make test                                                                                    ~/src/she3o_tmp-R-Nvim
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●
8 successes / 1 failure / 0 errors / 4 pending : 0.167151 seconds

Pending → ./tests/r/rmd_spec.lua @ 57
rmd module is_in_code_chunk(language, verbose) Unit Tests test verbosity
./tests/r/rmd_spec.lua:57: test verbosity

Pending → ./tests/r/rmd_spec.lua @ 60
rmd module is_in_code_chunk(language, verbose) Unit Tests returns true if inside code chunk (filetype-agnostic)
./tests/r/rmd_spec.lua:60: test filetype-agnostic code chunk detection

Pending → ./tests/r/rmd_spec.lua @ 64
rmd module is_in_code_chunk(language, verbose) Unit Tests returns false if outside code chunk (filetype-agnostic)
./tests/r/rmd_spec.lua:64: test filetype-agnostic code chunk detection

Pending → ./tests/r/rmd_spec.lua @ 68
rmd module is_in_code_chunk(language, verbose) Unit Tests returns false if it cannot match ```
./tests/r/rmd_spec.lua:68: test behaviour if chunk start/end not found

Failure → ./tests/r/rmd_spec.lua @ 51
rmd module is_in_code_chunk(language, verbose) Unit Tests returns true if on an '```{r' line
./tests/r/rmd_spec.lua:55: 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 7 months ago

make test fails because the following test fails

it("returns true if on an '```{r' line", function()                                
    rpcrequest(nvim, "nvim_win_set_cursor", 0, { 12, 0 })                          
    local result =                                                                 
        send_lua_via_rpc([[return require('r.rmd').is_in_code_chunk('r', false)]]) 
    assert.is_true(result)                                                         
end)                                                                               

I think it's expected from this function to return true if The cursor is on ```{r (I would still consider the cursor in a code chunk).

I will make the Makefile more error-friendly.

she3o commented 7 months ago

Hello @jalvesaq,

I'm looking to proceed with merging this pull request and plan to begin crafting tests in subsequent PRs. Could you confirm if this PR is complete and ready for merging, or is there anything else needed before it can be finalized?

jalvesaq commented 7 months ago

I'm getting this:

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

E5113: Error while calling lua chunk: [NULL]

The problem is that line 12 is not R code. It's the chunk header. The R code is line 13.

she3o commented 7 months ago

Ok that makes sense. I will remove it.

she3o commented 7 months ago

If there are no more adjustments required with this PR. Please feel free to proceed with the merging. @jalvesaq

jalvesaq commented 7 months ago

I merged it. Thanks! The chunk test should work if you have changed the line from 12 to 13.