test: add initial tests and ci
parent
f6cfb73d62
commit
aa45be80ad
|
|
@ -0,0 +1,51 @@
|
||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
# Cancel any in-progress CI runs for a PR if it is updated
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
unit_tests:
|
||||||
|
name: unit tests
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-20.04
|
||||||
|
url: https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.tar.gz
|
||||||
|
- os: ubuntu-20.04
|
||||||
|
url: https://github.com/neovim/neovim/releases/download/v0.6.0/nvim-linux64.tar.gz
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- run: date +%F > todays-date
|
||||||
|
- name: Restore from todays cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: _neovim
|
||||||
|
key: ${{ runner.os }}-${{ matrix.url }}-${{ hashFiles('todays-date') }}
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
test -d _neovim || {
|
||||||
|
mkdir -p _neovim
|
||||||
|
curl -sL ${{ matrix.url }} | tar xzf - --strip-components=1 -C "${PWD}/_neovim"
|
||||||
|
}
|
||||||
|
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
|
||||||
|
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
|
||||||
|
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
export PATH="${PWD}/_neovim/bin:${PATH}"
|
||||||
|
export VIM="${PWD}/_neovim/share/nvim/runtime"
|
||||||
|
nvim --version
|
||||||
|
make test
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
|
plenary.nvim/
|
||||||
|
tests/data/
|
||||||
.luarc.json
|
.luarc.json
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
all: test
|
||||||
|
|
||||||
|
test:
|
||||||
|
nvim --headless --noplugin -u tests/minimal.vim +Test
|
||||||
|
|
||||||
|
check:
|
||||||
|
stylua --color always --check .
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
local e = vim.fn.fnameescape
|
||||||
|
local session_dir = vim.fn.getcwd() .. "/tests/data/"
|
||||||
|
require("persisted").setup({
|
||||||
|
dir = session_dir
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("With default settings", function()
|
||||||
|
after_each(function()
|
||||||
|
-- vim.fn.system("rm -rf " .. e(session_dir))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("saves a session", function()
|
||||||
|
-- Edit a buffer
|
||||||
|
vim.cmd(":e tests/data/test.txt")
|
||||||
|
vim.cmd(":w")
|
||||||
|
|
||||||
|
-- Save the session
|
||||||
|
require("persisted").save()
|
||||||
|
|
||||||
|
-- Check that it is written to disk
|
||||||
|
assert.equals(vim.g.persisting, true)
|
||||||
|
assert.equals(vim.fn.system("ls tests/data | wc -l"), "2\n")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("loads a session", function()
|
||||||
|
-- Load a session
|
||||||
|
require("persisted").load()
|
||||||
|
|
||||||
|
-- Read the buffers contents
|
||||||
|
local content = vim.fn.getline(1, '$')
|
||||||
|
|
||||||
|
assert.equals(content[1], "This is a test file")
|
||||||
|
end)
|
||||||
|
|
||||||
|
end)
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
if !isdirectory('plenary.nvim')
|
||||||
|
!git clone https://github.com/nvim-lua/plenary.nvim.git plenary.nvim
|
||||||
|
!git -C plenary.nvim reset --hard 1338bbe8ec6503ca1517059c52364ebf95951458
|
||||||
|
endif
|
||||||
|
|
||||||
|
set runtimepath+=plenary.nvim,.
|
||||||
|
set noswapfile
|
||||||
|
set noundofile
|
||||||
|
|
||||||
|
runtime plugin/plenary.vim
|
||||||
|
command Test PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}
|
||||||
Loading…
Reference in New Issue