Skip to content

Commit

Permalink
test: migrate testing to busted
Browse files Browse the repository at this point in the history
  • Loading branch information
ckipp01 committed Jan 30, 2025
1 parent e6b02c9 commit a492be2
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 27 deletions.
13 changes: 13 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
return {
_all = {
coverage = false,
lpath = "lua/?.lua;lua/?/init.lua",
lua = "~/.luarocks/bin/nlua",
},
default = {
verbose = true
},
tests = {
verbose = true
},
}
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ jobs:
neovim: true
version: ${{ matrix.neovim_version }}

- name: Prepare plenary
run: |
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: Install Lua
uses: leso-kn/gh-actions-lua@master
with:
luaVersion: "5.1"

- name: Run setup tests
run: make test-setup
- name: Install Luarocks
uses: hishamhm/gh-actions-luarocks@master
with:
luarocksVersion: "3.11.0"

- name: Run tests
run: make test
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
format:
stylua lua/ tests/
stylua lua/ spec/

format-check:
stylua --check lua/ tests/
stylua --check lua/ spec/

lint:
selene lua/ tests/
selene lua/ spec/

local-test-setup:
git clone https://github.com/ckipp01/multiple-build-file-example.git
git clone https://github.com/ckipp01/mill-minimal.git
git clone https://github.com/ckipp01/minimal-scala-cli-test.git

test-setup:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/setup/ { minimal = true, sequential = true }"
luarocks test spec/setup --local

test:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/tests/ { minimal = true, sequential = true }"
luarocks test --local

test-handlers:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/tests/handlers/ { minimal = true, sequential = true }"
luarocks test spec/tests/test-handlers --local

clean:
rm -rf mill-minimal
Expand Down
28 changes: 16 additions & 12 deletions lua/metals/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ local log = require("metals.log")

-- @param status (string) a new status to be displayed
local function set_status(status, type)
-- Scaping the status to prevent % characters breaking the statusline
local scaped_status = status:gsub("[%%]", "%%%1")
local _status = "_status"
local metals = "metals"
local status_var = nil
if type and type == metals then
status_var = type .. _status
elseif type then
status_var = "metals_" .. type .. _status
else
status_var = metals .. _status
-- Not really sure why but this is at times getting called when status is nil
-- so in that scenario we just do nothing
if status ~= nil then
-- Scaping the status to prevent % characters breaking the statusline
local scaped_status = status:gsub("[%%]", "%%%1")
local _status = "_status"
local metals = "metals"
local status_var = nil
if type and type == metals then
status_var = type .. _status
elseif type then
status_var = "metals_" .. type .. _status
else
status_var = metals .. _status
end
vim.api.nvim_set_var(status_var, scaped_status)
end
vim.api.nvim_set_var(status_var, scaped_status)
end

-- Used to handle the full status response from Metals
Expand Down
18 changes: 18 additions & 0 deletions nvim-metals-scm-1.rockspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rockspec_format = '3.0'
package = 'nvim-metals'
version = 'scm-1'

test_dependencies = {
'lua >= 5.1',
'nlua',
'nui.nvim',
'plenary.nvim'
}

source = {
url = 'git://github.com/scalameta/' .. package,
}

build = {
type = 'builtin',
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions tests/minimal.vim

This file was deleted.

0 comments on commit a492be2

Please sign in to comment.