Skip to content

Commit d4913ee

Browse files
committed
make -> just
The README is updated with the new syntax for running recipes.
1 parent 9bb2933 commit d4913ee

File tree

5 files changed

+80
-72
lines changed

5 files changed

+80
-72
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,8 @@ jobs:
7575
run: sudo npm install -g lean-language-server
7676
if: contains(matrix.lean-version, 'lean:3')
7777

78+
- uses: extractions/setup-just@v1
7879
- name: Run tests
79-
run: make TEST_SEQUENTIAL=1 test
80+
run: just test
81+
env:
82+
TEST_SEQUENTIAL: 1

Makefile

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

README.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,32 +341,39 @@ Contributing
341341
Contributions are most welcome.
342342
Feel free to send pull requests for anything you'd like to see, or open an issue if you'd like to discuss.
343343

344-
Running the tests can be done via the ``Makefile``:
344+
Running the tests can be done via `just <https://github.com/casey/just>`_ using the adjacent `justfile <../justfile>`_:
345345

346346
.. code:: sh
347347
348-
$ make test
348+
$ just
349349
350-
which will execute against a minimal ``vimrc`` isolated from your own setup.
350+
which will execute against a minimal ``init.lua`` isolated from your own setup.
351+
352+
After running the test suite once, you can save some time re-cloning dependencies by instead now running:
351353

352354
.. code:: sh
353355
354-
$ TEST_FILE=lua/tests/foo_spec.lua make test
356+
$ just retest
357+
358+
You can also run single test files by running:
359+
360+
.. code:: sh
355361
356-
can be used to run just one specific test file, which can be faster.
362+
$ just retest lua/tests/ft_spec.lua
357363
358364
Some linting and style checking is done via `pre-commit <https://pre-commit.com/#install>`_, which once installed (via the linked instructions) is run via:
359365

360366
.. code:: sh
361367
362-
$ make lint
368+
$ just lint
363369
364370
or on each commit automatically if you have run ``pre-commit install`` in your repository checkout.
365371

366372
You can also use
367373

368374
.. code:: sh
369375
370-
$ make nvim SETUP_TABLE='{ lsp = { enable = true }, mappings = true }'
376+
$ just nvim '{ lsp = { enable = true }, mappings = true }'
371377
372-
to get a normal running neovim (again isolated from your own configuration), where ``SETUP_TABLE`` is a (Lua) table like one would pass to ``lean.setup``.
378+
to get a normal running neovim (again isolated from your own configuration), where the provided argument is a (Lua) table like one would pass to ``lean.setup``.
379+
Any further arguments will be passed to ``nvim``.

justfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
has_lean3 := if `leanpkg help 2>&1 >/dev/null; echo $?` == "0" { "true" } else { "false" }
2+
3+
packpath := justfile_directory() + "/packpath"
4+
scripts := justfile_directory() + "/scripts"
5+
tests := justfile_directory() + "/lua/tests"
6+
fixtures := tests + "/fixtures"
7+
8+
init_lua := scripts + "/minimal_init.lua"
9+
runner := scripts + "/run_tests.lua"
10+
11+
# Run the lean.nvim test suite.
12+
test: _rebuild-test-fixtures _clone-test-dependencies
13+
@just retest
14+
15+
# Run the test suite without rebuilding or recloning any dependencies.
16+
retest *test_files=tests:
17+
nvim --headless -u {{ init_lua }} -l {{ runner }} {{ test_files }}
18+
19+
# Run an instance of neovim with the same minimal init used to run tests.
20+
nvim setup_table='{}' *ARGS='':
21+
nvim -u {{ init_lua }} -c "lua require('lean').setup{{ setup_table }}" {{ ARGS }}
22+
23+
# Coarsely profile how long the whole test suite takes to run.
24+
profile-test *ARGS: _rebuild-test-fixtures _clone-test-dependencies
25+
hyperfine --warmup 2 {{ ARGS }} "just retest"
26+
27+
# Lint lean.nvim for style and typing issues.
28+
lint:
29+
pre-commit run --all-files
30+
@echo
31+
{{ if `lua-language-server --version 2>&1 >/dev/null; echo $?` != "0" { error('lua-language-server not found') } else { "" } }}
32+
lua-language-server --check lua/lean --checklevel=Warning --configpath "{{ justfile_directory() }}/.luarc.json"
33+
34+
# Update the versions of test fixtures used in CI.
35+
bump-test-fixtures:
36+
cd {{ fixtures }}/example-lean3-project/; {{ if `leanpkg help 2>&1 >/dev/null; echo $?` != "0" { "" } else { `leanproject up` } }}
37+
cd {{ fixtures }}/example-lean4-project/; gh api -H 'Accept: application/vnd.github.raw' '/repos/leanprover-community/Mathlib4/contents/lean-toolchain' >lean-toolchain
38+
git add --all
39+
git commit -m "Bump the Lean versions in CI."
40+
41+
# Delete any previously cloned test dependencies.
42+
_clean-test-dependencies:
43+
rm -rf '{{ packpath }}'
44+
mkdir '{{ packpath }}'
45+
46+
# Clone any neovim dependencies required for the plugin + test suite.
47+
_clone-test-dependencies: _clean-test-dependencies
48+
for dependency in AndrewRadev/switch.vim Julian/inanis.nvim neovim/nvim-lspconfig nvim-lua/plenary.nvim tomtom/tcomment_vim; do \
49+
git clone --quiet --filter=blob:none "https://github.com/$dependency" "{{ packpath }}/$(basename $dependency)"; \
50+
done
51+
52+
# Rebuild some test fixtures used in the test suite.
53+
_rebuild-test-fixtures:
54+
cd "{{ justfile_directory() }}/lua/tests/fixtures/example-lean3-project/" {{ if `leanpkg help 2>&1 >/dev/null; echo $?` != "0" { "" } else { `leanpkg build` } }}
55+
cd "{{ justfile_directory() }}/lua/tests/fixtures/example-lean4-project/"; lake build

scripts/run_tests.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ local opts = {
44
sequential = vim.env.TEST_SEQUENTIAL ~= nil,
55
}
66

7-
local test_file = vim.env.TEST_FILE or './lua/tests/'
8-
if vim.fn.isdirectory(test_file) == 1 then
9-
harness.test_directory(test_file, opts)
10-
else
11-
harness.test_file(test_file, opts)
7+
for _, test_file in ipairs(arg) do
8+
if vim.fn.isdirectory(test_file) == 1 then
9+
harness.test_directory(test_file, opts)
10+
else
11+
harness.test_file(test_file, opts)
12+
end
1213
end

0 commit comments

Comments
 (0)