-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
76 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 |
---|---|---|
@@ -1,7 +1,15 @@ | ||
all: test check | ||
|
||
test: | ||
nvim --headless --noplugin -u tests/minimal.vim +Test | ||
install_plenary: | ||
if [ ! -d ~/.local/share/nvim/site/pack/vendor/opt/plenary.nvim ]; \ | ||
then \ | ||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim \ | ||
~/.local/share/nvim/site/pack/vendor/opt/plenary.nvim; \ | ||
fi | ||
|
||
test: install_plenary | ||
nvim --headless --noplugin -u tests/minimal.vim -R \ | ||
-c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}" | ||
|
||
check: | ||
stylua --color always --check . |
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,36 @@ | ||
local gi = require("guess-indent") | ||
local t = require("plenary.async.tests") | ||
|
||
local test_cases = require("tests.utils").load_test_cases() | ||
|
||
-- Check that all files indentation gets detected correctly. | ||
t.describe("guess-indent", function() | ||
for lang, tc in pairs(test_cases) do | ||
t.describe("for " .. lang, function() | ||
for _, file in ipairs(tc) do | ||
-- Open a new buffer containing the file | ||
vim.cmd(":edit! " .. file.path) | ||
|
||
-- Get first line from buffer and try to extract the expectation | ||
local line = vim.api.nvim_buf_get_lines(0, 0, 1, false) | ||
local data = loadstring("return " .. line[1]:match("{.*}"))() | ||
local expectation = data.expected | ||
|
||
if data.disabled then | ||
print("WARNING: Skipping test case for file '" .. file.path .. "'") | ||
goto cleanup | ||
end | ||
|
||
-- Perfom test | ||
t.it("should indent: " .. file.name, function() | ||
local result = gi.guess_from_buffer() | ||
assert.are.equal(expectation, result) | ||
end) | ||
|
||
-- Cleanup | ||
::cleanup:: | ||
print(vim.cmd(":bdelete!")) | ||
end | ||
end) | ||
end | ||
end) |
This file was deleted.
Oops, something went wrong.
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,11 +1,7 @@ | ||
if !isdirectory('plenary.nvim') | ||
!git clone https://github.com/nvim-lua/plenary.nvim.git plenary.nvim | ||
!git -C plenary.nvim reset --hard 1338bbe8ec6503ca1517059c52364ebf95951458 | ||
endif | ||
packadd plenary.nvim | ||
runtime plugin/plenary.vim | ||
|
||
set rtp+=. | ||
|
||
set runtimepath+=plenary.nvim,. | ||
set noswapfile | ||
set noundofile | ||
|
||
runtime plugin/plenary.vim | ||
command Test PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'} |
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,30 @@ | ||
local M = {} | ||
|
||
-- Load all test cases in the data directory | ||
function M.load_test_cases() | ||
local test_data_path = "./tests/data/" | ||
local subfolders = vim.fn.readdir(test_data_path) | ||
|
||
local test_cases = {} | ||
|
||
for _, language in ipairs(subfolders) do | ||
local language_path = test_data_path .. language .. "/" | ||
if vim.fn.isdirectory(language_path) ~= 0 then | ||
local l_test_cases = {} | ||
local test_files = vim.fn.readdir(language_path, "v:val !~ '^\\.\\|\\~$'") | ||
|
||
for i, file_name in ipairs(test_files) do | ||
l_test_cases[i] = { | ||
path = language_path .. file_name, | ||
name = file_name, | ||
} | ||
end | ||
|
||
test_cases[language] = l_test_cases | ||
end | ||
end | ||
|
||
return test_cases | ||
end | ||
|
||
return M |