chore(ci):add basic tests
parent
2f6490ecb8
commit
9506a5b7d5
|
|
@ -38,7 +38,7 @@ jobs:
|
||||||
run: pip install codespell
|
run: pip install codespell
|
||||||
|
|
||||||
- name: Use codespell
|
- name: Use codespell
|
||||||
run: make spell
|
run: codespell --quiet-level=2 --check-hidden --skip=./.git,./CHANGELOG.md
|
||||||
|
|
||||||
generate-doc:
|
generate-doc:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
@ -59,9 +59,28 @@ jobs:
|
||||||
with:
|
with:
|
||||||
commit_message: "docs: auto-generate vimdoc"
|
commit_message: "docs: auto-generate vimdoc"
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Neovim
|
||||||
|
run: |
|
||||||
|
mkdir -p /tmp/nvim
|
||||||
|
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
|
||||||
|
cd /tmp/nvim
|
||||||
|
chmod a+x ./nvim.appimage
|
||||||
|
./nvim.appimage --appimage-extract
|
||||||
|
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
nvim --version
|
||||||
|
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
|
||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [stylua, selene, codespell, generate-doc]
|
needs: [stylua, selene, codespell, generate-doc, test]
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
steps:
|
steps:
|
||||||
- uses: googleapis/release-please-action@v4
|
- uses: googleapis/release-please-action@v4
|
||||||
|
|
|
||||||
48
Makefile
48
Makefile
|
|
@ -1,48 +0,0 @@
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
GREEN=[00;32m
|
|
||||||
RESTORE=[0m
|
|
||||||
else
|
|
||||||
GREEN="\033[0;32m"
|
|
||||||
RESTORE="\033[0m"
|
|
||||||
endif
|
|
||||||
|
|
||||||
# make the output of the message appear green
|
|
||||||
define style_calls
|
|
||||||
$(eval $@_msg = $(1))
|
|
||||||
echo ${GREEN}${$@_msg}${RESTORE}
|
|
||||||
endef
|
|
||||||
|
|
||||||
lint: style-lint
|
|
||||||
@$(call style_calls,"Running selene")
|
|
||||||
@selene --display-style quiet --config ./.selene.toml lua
|
|
||||||
@$(call style_calls,"Done!")
|
|
||||||
|
|
||||||
.PHONY: lint
|
|
||||||
|
|
||||||
style-lint:
|
|
||||||
@$(call style_calls,"Running stylua check")
|
|
||||||
@stylua --color always -f ./.stylua.toml --check lua
|
|
||||||
@$(call style_calls,"Done!")
|
|
||||||
|
|
||||||
.PHONY: style-lint
|
|
||||||
|
|
||||||
format:
|
|
||||||
@$(call style_calls,"Running stylua format")
|
|
||||||
@stylua --color always -f ./.stylua.toml lua
|
|
||||||
@$(call style_calls,"Done!")
|
|
||||||
|
|
||||||
.PHONY: format
|
|
||||||
|
|
||||||
spell:
|
|
||||||
@$(call style_calls,"Running codespell check")
|
|
||||||
@codespell --quiet-level=2 --check-hidden --skip=./.git,./CHANGELOG.md
|
|
||||||
@$(call style_calls,"Done!")
|
|
||||||
|
|
||||||
.PHONY: spell
|
|
||||||
|
|
||||||
spell-write:
|
|
||||||
@$(call style_calls,"Running codespell write")
|
|
||||||
@codespell --quiet-level=2 --check-hidden --skip=./.git,./CHANGELOG.md --write-changes
|
|
||||||
@$(call style_calls,"Done!")
|
|
||||||
|
|
||||||
.PHONY: spell-write
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
local internal_substitutions = {
|
M.internal_substitutions = {
|
||||||
{ find = ":/", replace = "__" },
|
{ find = ":/", replace = "__" },
|
||||||
{ find = "/", replace = "_" },
|
{ find = "/", replace = "_" },
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ end
|
||||||
M.encode_session = function(session_str, opts)
|
M.encode_session = function(session_str, opts)
|
||||||
local user_substitutions = opts.path_substitutions or {}
|
local user_substitutions = opts.path_substitutions or {}
|
||||||
session_str = M.apply_substitutions(session_str, user_substitutions, true)
|
session_str = M.apply_substitutions(session_str, user_substitutions, true)
|
||||||
session_str = M.apply_substitutions(session_str, internal_substitutions)
|
session_str = M.apply_substitutions(session_str, M.internal_substitutions)
|
||||||
|
|
||||||
return session_str
|
return session_str
|
||||||
end
|
end
|
||||||
|
|
@ -43,7 +43,7 @@ end
|
||||||
--- @return string[] The decoded session strings
|
--- @return string[] The decoded session strings
|
||||||
M.decode_sessions = function(sessions, opts)
|
M.decode_sessions = function(sessions, opts)
|
||||||
for i, session in ipairs(sessions) do
|
for i, session in ipairs(sessions) do
|
||||||
session = M.apply_substitutions(session, internal_substitutions, true)
|
session = M.apply_substitutions(session, M.internal_substitutions, true)
|
||||||
session = M.apply_substitutions(session, opts.path_substitutions)
|
session = M.apply_substitutions(session, opts.path_substitutions)
|
||||||
sessions[i] = session
|
sessions[i] = session
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
local config = require("telescope._extensions.resession.config")
|
||||||
|
|
||||||
|
describe("setup", function()
|
||||||
|
it("should populate an empty opts table with defaults", function()
|
||||||
|
config.setup()
|
||||||
|
assert.are.same(config.opts, config.defaults)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should keep user defined options", function()
|
||||||
|
config.setup({ prompt_title = "New Title" })
|
||||||
|
assert.are.same(config.opts.prompt_title, "New Title")
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
local plenary_dir = os.getenv("PLENARY_DIR") or "/tmp/plenary.nvim"
|
||||||
|
local is_not_a_directory = vim.fn.isdirectory(plenary_dir) == 0
|
||||||
|
if is_not_a_directory then
|
||||||
|
vim.fn.system({ "git", "clone", "https://github.com/nvim-lua/plenary.nvim", plenary_dir })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.opt.rtp:append(".")
|
||||||
|
vim.opt.rtp:append(plenary_dir)
|
||||||
|
|
||||||
|
vim.cmd("runtime plugin/plenary.vim")
|
||||||
|
require("plenary.busted")
|
||||||
|
|
||||||
|
print("Running tests...")
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
local utils = require("telescope._extensions.resession.utils")
|
||||||
|
|
||||||
|
describe("apply_substitutions", function()
|
||||||
|
it("should apply substitutions to a session string", function()
|
||||||
|
local session = "C__Users_user_AppData_Local_nvim"
|
||||||
|
local substitutions = utils.internal_substitutions
|
||||||
|
local result = utils.apply_substitutions(session, substitutions, true)
|
||||||
|
assert.are.same("C:/Users/user/AppData/Local/nvim", result)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should apply substitutions in reverse to a session string", function()
|
||||||
|
local session = "C:/Users/user/AppData/Local/nvim"
|
||||||
|
local substitutions = utils.internal_substitutions
|
||||||
|
local result = utils.apply_substitutions(session, substitutions)
|
||||||
|
assert.are.same("C__Users_user_AppData_Local_nvim", result)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("should apply substitutions to a session string with user substitutions", function()
|
||||||
|
local session = "C:/Users/user/AppData/Local/nvim"
|
||||||
|
local substitutions = {
|
||||||
|
{ find = "C:/", replace = "D:/" },
|
||||||
|
{ find = "nvim", replace = "neovim" },
|
||||||
|
}
|
||||||
|
local result = utils.apply_substitutions(session, substitutions)
|
||||||
|
assert.are.same("D:/Users/user/AppData/Local/neovim", result)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe("encode_session", function()
|
||||||
|
it("should encode a session string", function()
|
||||||
|
local session = "D:/Users/user/AppData/Local/neovim"
|
||||||
|
local opts = { path_substitutions = { { find = "C:/", replace = "D:/" } } }
|
||||||
|
local result = utils.encode_session(session, opts)
|
||||||
|
assert.are.same("C__Users_user_AppData_Local_neovim", result)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe("decode_sessions", function()
|
||||||
|
it("should decode a list of session strings", function()
|
||||||
|
local sessions = { "C__Users_user_AppData_Local_neovim" }
|
||||||
|
local opts = { path_substitutions = { { find = "C:/", replace = "D:/" } } }
|
||||||
|
local result = utils.decode_sessions(sessions, opts)
|
||||||
|
assert.are.same({ "D:/Users/user/AppData/Local/neovim" }, result)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
Loading…
Reference in New Issue