-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unittest + basic python and lua unittests (#174)
--------- Co-authored-by: Danymat <d.danymat@gmail.com>
- Loading branch information
1 parent
6de0add
commit fef1ab3
Showing
9 changed files
with
1,027 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
on: [push, pull_request] | ||
name: test | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
neovim: [v0.10.0, nightly] | ||
runs-on: ${{ matrix.os }} | ||
name: "OS: ${{ matrix.os }} - Neovim: ${{ matrix.neovim }}" | ||
steps: | ||
- name: Checkout neogen | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: danymat/neogen | ||
path: neogen | ||
- uses: rhysd/action-setup-vim@v1 | ||
with: | ||
neovim: true | ||
version: ${{ matrix.neovim }} | ||
- name: Run tests | ||
working-directory: ./neogen | ||
run: | | ||
nvim --version | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
TESTS_INIT=tests/minimal_init.lua | ||
TESTS_DIR=tests/ | ||
|
||
.PHONY: test | ||
|
||
documentation: | ||
nvim --headless --noplugin -u ./scripts/minimal_init.vim -c "lua MiniDoc.generate()" -c "qa!" | ||
|
||
tag: | ||
./scripts/generate_tag.sh | ||
|
||
test: | ||
@nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u ${TESTS_INIT} \ | ||
-c "PlenaryBustedDirectory ${TESTS_DIR} { minimal_init = '${TESTS_INIT}' }" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
local plugins = { | ||
["https://github.com/nvim-treesitter/nvim-treesitter"] = os.getenv("NVIM_TREESITTER_DIRECTORY") | ||
or "/tmp/nvim_treesitter", | ||
["https://github.com/nvim-lua/plenary.nvim"] = os.getenv("PLENARY_DIRECTORY") or "/tmp/plenary.nvim", | ||
} | ||
|
||
local tests_directory = vim.fn.fnamemodify(vim.fn.expand("<sfile>"), ":h") | ||
local plugin_root = vim.fn.fnamemodify(tests_directory, ":h") | ||
vim.opt.runtimepath:append(plugin_root) | ||
|
||
for url, directory in pairs(plugins) do | ||
if vim.fn.isdirectory(directory) == 0 then | ||
vim.fn.system({ "git", "clone", url, directory }) | ||
end | ||
|
||
vim.opt.runtimepath:append(directory) | ||
end | ||
|
||
vim.cmd("runtime plugin/plenary.vim") | ||
require("plenary.busted") | ||
|
||
vim.cmd("runtime plugin/nvim-treesitter.lua") | ||
|
||
-- Some tests require the Python parser | ||
vim.cmd([[TSInstallSync! python]]) | ||
|
||
require("neogen").setup({ snippet_engine = "nvim" }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- Test cases for emmylua | ||
--- | ||
--- @module 'tests.neogen.lua_spec' | ||
|
||
local specs = require('tests.utils.specs') | ||
|
||
local function make_emmylua(source) | ||
return specs.make_docstring(source, 'lua', { annotation_convention = { lua = 'emmylua' } }) | ||
end | ||
|
||
describe("lua: emmylua", function() | ||
describe("func", function() | ||
it("works with an empty function", function() | ||
local source = [[ | ||
function foo()|cursor|end | ||
]] | ||
|
||
local expected = [[ | ||
--- [TODO:description] | ||
function foo()end | ||
]] | ||
|
||
local result = make_emmylua(source) | ||
|
||
assert.equal(expected, result) | ||
end) | ||
end) | ||
end) |
Oops, something went wrong.