test: test harness isolation improvements

This commit is contained in:
Steven Arcangeli 2022-10-21 06:17:30 -07:00
parent f8cb4a9d89
commit c5f656cb78
6 changed files with 29 additions and 15 deletions

View file

@ -6,5 +6,3 @@ mkdir -p "$PLUGINS"
wget "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim.appimage"
chmod +x nvim.appimage
sudo mv ./nvim.appimage /usr/bin/nvim
git clone --depth=1 https://github.com/nvim-lua/plenary.nvim.git "$PLUGINS/plenary.nvim"
git clone https://github.com/nvim-treesitter/nvim-treesitter.git "$PLUGINS/nvim-treesitter"

View file

@ -52,10 +52,6 @@ jobs:
run: |
npm install -g tree-sitter-cli
- name: Ensure TS parsers installed
run: |
nvim --headless -c "TSInstallSync $(ls queries)" -c "q"
- name: Run tests
run: |
bash ./run_tests.sh

1
.gitignore vendored
View file

@ -40,3 +40,4 @@ luac.out
*.hex
.direnv/
.testenv/

View file

@ -1,6 +1,26 @@
#!/bin/bash
set -e
nvim --headless --noplugin -u tests/minimal_init.lua \
mkdir -p ".testenv/config/nvim"
mkdir -p ".testenv/data/nvim"
mkdir -p ".testenv/state/nvim"
mkdir -p ".testenv/run/nvim"
mkdir -p ".testenv/cache/nvim"
PLUGINS=".testenv/data/nvim/site/pack/plugins/start"
if [ ! -e "$PLUGINS/plenary.nvim" ]; then
git clone --depth=1 https://github.com/nvim-lua/plenary.nvim.git "$PLUGINS/plenary.nvim"
fi
if [ ! -e "$PLUGINS/nvim-treesitter" ]; then
git clone --depth=1 https://github.com/nvim-treesitter/nvim-treesitter.git "$PLUGINS/nvim-treesitter"
fi
XDG_CONFIG_HOME=".testenv/config" \
XDG_DATA_HOME=".testenv/data" \
XDG_STATE_HOME=".testenv/state" \
XDG_RUNTIME_DIR=".testenv/run" \
XDG_CACHE_HOME=".testenv/cache" \
nvim --headless -u tests/minimal_init.lua \
-c "TSUpdateSync" \
-c "PlenaryBustedDirectory ${1-tests} { minimal_init = './tests/minimal_init.lua' }"
echo "Success"

View file

@ -1,6 +1,4 @@
vim.cmd([[set runtimepath+=.]])
vim.cmd([[runtime! plugin/plenary.vim]])
vim.cmd([[runtime! plugin/nvim-treesitter.vim]])
-- Force load the nvim-treesitter query predicates
require("nvim-treesitter.query_predicates")
@ -19,4 +17,5 @@ for lang, _ in vim.fs.dir("queries") do
end
require("nvim-treesitter.configs").setup({
ensure_installed = langs,
sync_install = true,
})

View file

@ -12,7 +12,7 @@ describe("config", function()
col = 0,
end_col = 3,
}
data.set_symbols(0, {sym})
data.set_symbols(0, { sym })
local bufdata = data.get_or_create(0)
local ret = window.get_symbol_position(bufdata, 1, 0)
assert.are.same({ lnum = 1, closest_symbol = sym, relative = "above" }, ret)
@ -27,7 +27,7 @@ describe("config", function()
col = 0,
end_col = 3,
}
data.set_symbols(0, {sym})
data.set_symbols(0, { sym })
local bufdata = data.get_or_create(0)
local ret = window.get_symbol_position(bufdata, 12, 0)
assert.are.same({ lnum = 1, closest_symbol = sym, relative = "below" }, ret)
@ -51,7 +51,7 @@ describe("config", function()
col = 0,
end_col = 3,
}
data.set_symbols(0, {sym, sym2})
data.set_symbols(0, { sym, sym2 })
local bufdata = data.get_or_create(0)
local ret = window.get_symbol_position(bufdata, 12, 0)
assert.are.same({ lnum = 1, closest_symbol = sym, relative = "below" }, ret)
@ -66,7 +66,7 @@ describe("config", function()
col = 0,
end_col = 3,
}
data.set_symbols(0, {sym)
data.set_symbols(0, { sym })
local bufdata = data.get_or_create(0)
local ret = window.get_symbol_position(bufdata, 8, 0)
assert.are.same({ lnum = 1, closest_symbol = sym, exact_symbol = sym, relative = "exact" }, ret)
@ -92,7 +92,7 @@ describe("config", function()
children = { sym },
}
sym.parent = parent
data.set_symbols(0, {parent})
data.set_symbols(0, { parent })
local bufdata = data.get_or_create(0)
local ret = window.get_symbol_position(bufdata, 11, 0)
assert.are.same(
@ -131,7 +131,7 @@ describe("config", function()
end_col = 12,
},
}
data.set_symbols(0, {var1, var2})
data.set_symbols(0, { var1, var2 })
local bufdata = data.get_or_create(0)
local ret = window.get_symbol_position(bufdata, 10, 6)
assert.are.same(