Skip to content

Commit

Permalink
test: Make all tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewferrier committed May 25, 2024
1 parent 00a5c5c commit 0efb4bb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: all clean test

test:
nvim --headless --clean -u tests/init-minimal.vim -c "PlenaryBustedFile tests/minimal.lua"
nvim --headless --clean -u tests/init-treesitter.vim -c "PlenaryBustedFile tests/treesitter.lua"
nvim --headless --clean -u tests/init.vim -c "PlenaryBustedFile tests/minimal.lua"
nvim --headless --clean -u tests/init.vim -c "PlenaryBustedFile tests/treesitter.lua"
3 changes: 3 additions & 0 deletions tests/common.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
local M = {}

vim.o.hidden = true
vim.o.swapfile = false

local wrapping = require("wrapping")

M.set_lines = function(lines)
Expand Down
5 changes: 0 additions & 5 deletions tests/init-treesitter.vim

This file was deleted.

5 changes: 1 addition & 4 deletions tests/init-minimal.vim → tests/init.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
set hidden
set noswapfile

set rtp+=~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
set rtp+=../plenary.nvim
set rtp+=.

runtime! plugin/plenary.vim
24 changes: 24 additions & 0 deletions tests/treesitter.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
vim.opt.runtimepath:prepend(
"~/.local/share/nvim/site/pack/vendor/start/nvim-treesitter"
)
vim.opt.runtimepath:prepend("../nvim-treesitter")

vim.cmd("runtime! plugin/nvim-treesitter.lua")

local install_parser_if_needed = function(filetype)
if vim.tbl_contains(vim.tbl_keys(vim.fn.environ()), "GITHUB_WORKFLOW") then
print("Running in GitHub; installing parser " .. filetype .. "...")
vim.cmd("TSInstallSync! " .. filetype)
else
vim.cmd("new")
vim.cmd("only")
local ok, _ = pcall(vim.treesitter.get_parser, 0, filetype, {})
if not ok then
print("Cannot load parser for " .. filetype .. ", installing...")
vim.cmd("TSInstallSync! " .. filetype)
end
end
end

install_parser_if_needed("markdown")

local common = require("tests.common")
local wrapping = require("wrapping")

Expand Down

0 comments on commit 0efb4bb

Please sign in to comment.