mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-20 18:45:08 +02:00
[Feature]: Add some very basic unit-tests (#1369)
This commit is contained in:
parent
ac32f2e64d
commit
38f53bf08c
8 changed files with 113 additions and 31 deletions
27
.github/workflows/format.yaml
vendored
27
.github/workflows/format.yaml
vendored
|
@ -1,11 +1,11 @@
|
|||
name: format
|
||||
on:
|
||||
push:
|
||||
branches: '**'
|
||||
branches: "**"
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'rolling'
|
||||
- "master"
|
||||
- "rolling"
|
||||
|
||||
jobs:
|
||||
stylua-check:
|
||||
|
@ -14,14 +14,13 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Prepare dependencies
|
||||
run: |
|
||||
sudo apt install -y curl unzip --no-install-recommends
|
||||
bash ./utils/installer/install_stylua.sh
|
||||
- name: Lint with stylua
|
||||
uses: JohnnyMorganz/stylua-action@1.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# CLI arguments
|
||||
args: --check .
|
||||
|
||||
- name: Check formatting
|
||||
run: |
|
||||
./utils/stylua --config-path .stylua.toml -c .
|
||||
shfmt-check:
|
||||
name: "Formatting check with shfmt"
|
||||
runs-on: ubuntu-20.04
|
||||
|
@ -31,14 +30,12 @@ jobs:
|
|||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '1.16'
|
||||
|
||||
go-version: "1.16"
|
||||
|
||||
- name: Use shfmt
|
||||
run: |
|
||||
GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt
|
||||
|
||||
# https://google.github.io/styleguide/shellguide.html
|
||||
- name: Check formatting
|
||||
run: |
|
||||
shfmt -f . | grep -v jdtls | xargs shfmt -i 2 -ci -l -d
|
||||
|
||||
run: make style-sh
|
||||
|
|
5
.github/workflows/install.yaml
vendored
5
.github/workflows/install.yaml
vendored
|
@ -43,6 +43,11 @@ jobs:
|
|||
ln -s "$PWD"/* "$HOME"/.local/share/lunarvim/lvim/.
|
||||
bash ./utils/installer/install.sh
|
||||
|
||||
- name: Run unit-tests
|
||||
# NOTE: make sure to adjust the timeout if you start adding a lot of tests
|
||||
timeout-minutes: 4
|
||||
run: make test
|
||||
|
||||
- name: Test LunarVim PackerCompile
|
||||
run: if "$HOME"/.local/bin/lvim --headless +PackerCompile -c ':qall' 2>&1|grep -q 'Error'; then false; fi
|
||||
|
||||
|
|
24
.github/workflows/lint.yaml
vendored
24
.github/workflows/lint.yaml
vendored
|
@ -1,11 +1,11 @@
|
|||
name: lint
|
||||
on:
|
||||
push:
|
||||
branches: '**'
|
||||
branches: "**"
|
||||
pull_request:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'rolling'
|
||||
- "master"
|
||||
- "rolling"
|
||||
|
||||
jobs:
|
||||
lua-linter:
|
||||
|
@ -13,23 +13,23 @@ jobs:
|
|||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
|
||||
- uses: leafo/gh-actions-lua@v8
|
||||
- uses: leafo/gh-actions-luarocks@v4
|
||||
|
||||
- name: Use luacheck
|
||||
run: luarocks install luacheck
|
||||
|
||||
|
||||
- name: Run luacheck
|
||||
run: luacheck *.lua lua/
|
||||
run: make lint-lua
|
||||
|
||||
shellcheck:
|
||||
name: Shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
with:
|
||||
scandir: './utils'
|
||||
ignore: 'bin'
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run ShellCheck
|
||||
uses: ludeeus/action-shellcheck@master
|
||||
with:
|
||||
scandir: "./utils"
|
||||
ignore: "bin"
|
||||
|
|
|
@ -26,6 +26,8 @@ stds.nvim = {
|
|||
}
|
||||
std = "lua51+nvim"
|
||||
|
||||
files["tests/*_spec.lua"].std = "lua51+nvim+busted"
|
||||
|
||||
-- Don't report unused self arguments of methods.
|
||||
self = false
|
||||
|
||||
|
|
|
@ -7,20 +7,19 @@ repos:
|
|||
language: system
|
||||
types: [shell]
|
||||
entry: bash
|
||||
args: [-c, "shfmt -f $(git rev-parse --show-toplevel) | grep -v jdtls | xargs shfmt -i=2 -ci -w"]
|
||||
args: [-c, make lint-sh]
|
||||
- id: shellcheck
|
||||
name: shellcheck
|
||||
language: system
|
||||
types: [shell]
|
||||
entry: bash
|
||||
args:
|
||||
[-c, "shfmt -f $(git rev-parse --show-toplevel) | grep -v jdtls | xargs shellcheck"]
|
||||
args: [-c, make style-sh]
|
||||
- id: stylua
|
||||
name: StyLua
|
||||
language: rust
|
||||
entry: stylua
|
||||
types: [lua]
|
||||
args: ['-']
|
||||
args: ["-"]
|
||||
- id: luacheck
|
||||
name: luacheck
|
||||
language: system
|
||||
|
|
33
Makefile
Normal file
33
Makefile
Normal file
|
@ -0,0 +1,33 @@
|
|||
SHELL := /bin/bash
|
||||
|
||||
install:
|
||||
@echo Starting LunarVim Installer
|
||||
bash ./utils/installer/install.sh
|
||||
|
||||
install-neovim-binary:
|
||||
@echo Installing Neovim from github releases
|
||||
bash ./utils/installer/install-neovim-from-release
|
||||
|
||||
uninstall:
|
||||
@echo TODO: this is currently not supported
|
||||
|
||||
lint: lint-lua lint-sh
|
||||
|
||||
lint-lua:
|
||||
luacheck *.lua lua/* tests/*
|
||||
|
||||
lint-sh:
|
||||
shfmt -f . | grep -v jdtls | xargs shellcheck
|
||||
|
||||
style: style-lua style-sh
|
||||
|
||||
style-lua:
|
||||
stylua --config-path .stylua.toml --check .
|
||||
|
||||
style-sh:
|
||||
shfmt -f . | grep -v jdtls | xargs shfmt -i 2 -ci -l -d
|
||||
|
||||
test:
|
||||
bash ./utils/bin/test_runner.sh "$(TEST)"
|
||||
|
||||
.PHONY: install install-neovim-binary uninstall lint style test
|
37
tests/bootstrap_spec.lua
Normal file
37
tests/bootstrap_spec.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
local a = require "plenary.async_lib.tests"
|
||||
|
||||
a.describe("initial start", function()
|
||||
local uv = vim.loop
|
||||
local home_dir = uv.os_homedir()
|
||||
-- TODO: update once #1381 is merged
|
||||
local lvim_config_path = home_dir .. "/.config/lvim"
|
||||
local lvim_runtime_path = home_dir .. "/.local/share/lunarvim/lvim"
|
||||
|
||||
a.it("should not be reading default neovim directories in the home directoies", function()
|
||||
local rtp_list = vim.opt.rtp:get()
|
||||
assert.falsy(vim.tbl_contains(rtp_list, vim.fn.stdpath "config"))
|
||||
end)
|
||||
|
||||
a.it("should be able to read lunarvim directories", function()
|
||||
local rtp_list = vim.opt.rtp:get()
|
||||
assert.truthy(vim.tbl_contains(rtp_list, lvim_runtime_path))
|
||||
assert.truthy(vim.tbl_contains(rtp_list, lvim_config_path))
|
||||
end)
|
||||
|
||||
a.it("should be able to run treesitter without errors", function()
|
||||
assert.truthy(vim.treesitter.highlighter.active)
|
||||
end)
|
||||
|
||||
a.it("should be able to load default packages without errors", function()
|
||||
-- TODO: maybe there's a way to avoid hard-coding the names of the modules?
|
||||
local startup_plugins = {
|
||||
"packer",
|
||||
"lspconfig",
|
||||
"nlspsettings",
|
||||
"null-ls",
|
||||
}
|
||||
for _, plugin in pairs(startup_plugins) do
|
||||
assert.truthy(package.loaded[tostring(plugin)])
|
||||
end
|
||||
end)
|
||||
end)
|
9
utils/bin/test_runner.sh
Normal file
9
utils/bin/test_runner.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# TODO: allow running with a minimal_init.lua
|
||||
if [ -n "$1" ]; then
|
||||
nvim --headless -u ./init.lua -c "lua require('plenary.busted').run('$1')"
|
||||
else
|
||||
nvim --headless -u ./init.lua -c "PlenaryBustedDirectory tests/ { minimal_init = './init.lua' }"
|
||||
fi
|
Loading…
Reference in a new issue