|
| 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 |
0 commit comments