Skip to content

Commit 6f6d419

Browse files
committed
WIP
1 parent 44cd9c2 commit 6f6d419

File tree

9 files changed

+78
-70
lines changed

9 files changed

+78
-70
lines changed

.busted

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
return {
2+
_all = {
3+
helper = 'spec/spec_helper.lua',
4+
lpath = 'lua/?.lua;lua/?/init.lua',
5+
lua = './spec/nvim-shim',
6+
},
7+
default = {
8+
coverage = false,
9+
verbose = false
10+
},
11+
verbose = {
12+
coverage = false,
13+
verbose = true
14+
},
15+
coverage = {
16+
coverage = true,
17+
verbose = true
18+
},
19+
}

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
- uses: actions/checkout@v4
2828
with:
2929
persist-credentials: false
30+
31+
- uses: leafo/gh-actions-lua@v10
32+
with:
33+
luaVersion: "luajit-openresty"
34+
- uses: leafo/gh-actions-luarocks@v4
35+
3036
- name: Install Neovim
3137
uses: rhysd/action-setup-vim@v1
3238
with:
@@ -37,8 +43,6 @@ jobs:
3743
- uses: extractions/setup-just@v2
3844
- name: Run tests
3945
run: just test
40-
env:
41-
TEST_SEQUENTIAL: 1
4246

4347
release:
4448
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ demo.mp4
88

99
/luapath
1010
/packpath
11-
/pack
11+
/.isolated_config*
1212

1313
/.tests
1414
/lua/tests/fixtures/example-project/build

justfile

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
packpath := justfile_directory() / "packpath"
21
scripts := justfile_directory() / "scripts"
32
doc := justfile_directory() / "doc"
43
devcontainer := justfile_directory() / ".devcontainer/lazyvim/Dockerfile"
@@ -8,23 +7,23 @@ spec := justfile_directory() / "spec"
87
fixtures := spec / "fixtures"
98
demos := justfile_directory() / "demos"
109

11-
init_lua := scripts / "minimal_init.lua"
12-
clean_config := justfile_directory() / ".test-config"
10+
export LEAN_NVIM_ISOLATED_CONFIG_ROOT := justfile_directory() / ".isolated_config_for_tests"
11+
packpath := LEAN_NVIM_ISOLATED_CONFIG_ROOT / "local/share/nvim/site/pack/testing/start"
1312

1413
# Run the lean.nvim test suite.
1514
[group('testing')]
16-
test: _rebuild-test-fixtures _clone-test-dependencies
17-
@just retest
15+
test *ARGS='': _rebuild-test-fixtures _clone-dependencies
16+
@just retest {{ ARGS }}
1817

1918
# Run the test suite without rebuilding or recloning any dependencies.
2019
[group('testing')]
21-
retest *test_files=spec:
22-
XDG_CONFIG_HOME="{{ clean_config }}" nvim --headless --clean -u {{ init_lua }} -c 'lua require("inanis").run{ specs = vim.split("{{ test_files }}", " "), minimal_init = "{{ init_lua }}", sequential = vim.env.TEST_SEQUENTIAL ~= nil }'
20+
retest *ARGS='':
21+
eval $(luarocks path --no-bin --lua-version 5.1); luarocks --lua-version 5.1 test -- {{ ARGS }}
2322

24-
# Run an instance of neovim with the same minimal init used to run tests.
23+
# Run an instance of neovim with the same setup used to run tests.
2524
[group('dev')]
2625
nvim *ARGS='':
27-
XDG_CONFIG_HOME="{{ clean_config }}" nvim --clean -u {{ init_lua }} -c "lua require('lean').setup { mappings = true }" {{ ARGS }}
26+
XDG_CONFIG_HOME="{{ LEAN_NVIM_ISOLATED_CONFIG_ROOT }}"/config nvim --clean -u NONE -c "lua require('lean').setup { mappings = true }" {{ ARGS }}
2827

2928
# Run an instance of the `devcontainer` which uses LazyVim.
3029
[group('dev')]
@@ -40,7 +39,7 @@ scratch *ARGS='':
4039

4140
# Coarsely profile how long the whole test suite takes to run.
4241
[group('testing')]
43-
profile-test *ARGS: _rebuild-test-fixtures _clone-test-dependencies
42+
profile-test *ARGS: _rebuild-test-fixtures _clone-dependencies
4443
hyperfine --warmup 2 {{ ARGS }} "just retest"
4544

4645
# Lint lean.nvim for style and typing issues.
@@ -50,7 +49,7 @@ lint:
5049
{{ if `lua-language-server --version 2>&1 >/dev/null; echo $?` != "0" { error('lua-language-server not found') } else { "" } }}
5150
lua-language-server --check {{ lean }} --checklevel=Warning --configpath "{{ justfile_directory() }}/.luarc.json"
5251
{{ if `selene --version 2>&1 >/dev/null; echo $?` != "0" { error('selene not found') } else { "" } }}
53-
selene {{ src }}
52+
selene {{ src }} {{ spec }}
5453

5554
# Rebuild a demo from our VHS script.
5655
demo:
@@ -73,7 +72,7 @@ docs:
7372
{{ lean }}/stderr.lua \
7473
{{ lean }}/sorry.lua \
7574
>{{ doc }}/lean.txt
76-
nvim --headless --clean -u {{ init_lua }} -c 'helptags {{ doc }}' -c 'quit'
75+
nvim --headless --clean -u NONE -c 'helptags {{ doc }}' -c 'quit'
7776

7877
# Update the versions of test fixtures used in CI.
7978
[group('testing')]
@@ -86,19 +85,13 @@ bump-test-fixtures:
8685

8786
# Delete any previously cloned dependencies.
8887
_clean-dependencies:
89-
rm -rf '{{ packpath }}'
90-
mkdir '{{ packpath }}'
88+
rm -rf '{{ LEAN_NVIM_ISOLATED_CONFIG_ROOT }}'
9189

9290
# Clone any neovim dependencies required for the plugin.
9391
_clone-dependencies: _clean-dependencies
94-
for dependency in AndrewRadev/switch.vim andymass/vim-matchup neovim/nvim-lspconfig nvim-lua/plenary.nvim tomtom/tcomment_vim lewis6991/satellite.nvim; do \
95-
git clone --quiet --filter=blob:none "https://github.com/$dependency" "{{ packpath }}/$(basename $dependency)"; \
96-
done
97-
98-
# Clone any neovim dependencies required for the test suite.
99-
_clone-test-dependencies: _clone-dependencies
100-
for dependency in Julian/inanis.nvim; do \
101-
git clone --quiet --filter=blob:none "https://github.com/$dependency" "{{ packpath }}/$(basename $dependency)"; \
92+
mkdir -p '{{ packpath }}' && ln -s "{{ justfile_directory() }}" "{{ packpath }}"
93+
for dependency in AndrewRadev/switch.vim andymass/vim-matchup tomtom/tcomment_vim lewis6991/satellite.nvim; do \
94+
git clone --quiet --filter=blob:none "https://github.com/$dependency" "{{ packpath }}/$(basename $dependency)"; \
10295
done
10396

10497
# Rebuild some test fixtures used in the test suite.

lean.nvim-scm-1.rockspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ dependencies = {
1616
'nvim-lspconfig',
1717
'plenary.nvim',
1818
}
19+
test_dependencies = {
20+
}
1921

2022
source = {
2123
url = 'https://github.com/Julian/lean.nvim',

scripts/minimal_init.lua

Lines changed: 0 additions & 45 deletions
This file was deleted.

spec/fixtures.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local assert = require 'luassert.assert'
2+
13
local this_file = debug.getinfo(1).source:match '@(.*)$'
24

35
local root = vim.fs.joinpath(vim.fs.dirname(this_file), 'fixtures')

spec/nvim-shim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
set -euf
3+
4+
export XDG_CONFIG_HOME="$LEAN_NVIM_ISOLATED_CONFIG_ROOT/config"
5+
export XDG_STATE_HOME="$LEAN_NVIM_ISOLATED_CONFIG_ROOT/local/state/"
6+
export XDG_DATA_HOME="$LEAN_NVIM_ISOLATED_CONFIG_ROOT/local/share/"
7+
8+
nvim --cmd 'set loadplugins' -l $@

spec/spec_helper.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
local assert = require 'luassert.assert'
2+
local say = require 'say'
3+
4+
--- Assert a Lua object is empty.
5+
--- In particular, the empty string, empty table and nil are all empty.
6+
local function is_empty(_, arguments)
7+
local got = arguments[1]
8+
if not got then
9+
return true
10+
elseif type(got) == 'string' then
11+
return got == ''
12+
else
13+
return vim.tbl_isempty(got)
14+
end
15+
end
16+
17+
say:set('assertion.empty.positive', '%q is non-empty')
18+
say:set('assertion.empty.negative', '%q is empty')
19+
assert:register(
20+
'assertion',
21+
'empty',
22+
is_empty,
23+
'assertion.empty.positive',
24+
'assertion.empty.negative'
25+
)

0 commit comments

Comments
 (0)