Skip to content

Commit bdfcf86

Browse files
committed
test: add tests for fixed tool definitions
Problem: the config fixes in the previous commit had no test coverage proving the definitions produce valid commands. Solution: add opts (cwd, tmpdir) and assert_diag to the test helper. Add tests for all 8 fixed tools using run_fmt/run_lint to exercise the actual configs. Add pylint to pip.txt, hadolint to binary.txt, shellcheck to the binary CI job, and new test-dotnet and test-ruby CI jobs.
1 parent add140c commit bdfcf86

24 files changed

Lines changed: 547 additions & 43 deletions

.github/tools/binary.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
alejandra bin https://github.com/kamadorueda/alejandra/releases/download/4.0.0/alejandra-x86_64-unknown-linux-musl
22
buf bin https://github.com/bufbuild/buf/releases/download/v1.47.2/buf-Linux-x86_64
3+
hadolint bin https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
34
checkmake bin https://github.com/mrtazz/checkmake/releases/download/0.2.2/checkmake-0.2.2.linux.amd64
45
deno zip https://github.com/denoland/deno/releases/download/v2.1.4/deno-x86_64-unknown-linux-gnu.zip
6+
detekt jar https://github.com/detekt/detekt/releases/download/v1.23.7/detekt-cli-1.23.7-all.jar
57
hlint tar https://github.com/ndmitchell/hlint/releases/download/v3.10/hlint-3.10-x86_64-linux.tar.gz hlint-3.10/hlint
68
latexindent bin https://github.com/cmhughes/latexindent.pl/releases/download/V3.24.4/latexindent-linux
79
swiftformat zip https://github.com/nicklockwood/SwiftFormat/releases/download/0.55.3/swiftformat_linux.zip swiftformat_linux
10+
cbfmt tar https://github.com/lukas-reineke/cbfmt/releases/download/v0.2.0/cbfmt_linux-x86_64_v0.2.0.tar.gz cbfmt_linux-x86_64_v0.2.0/cbfmt
11+
dprint zip https://github.com/dprint/dprint/releases/download/0.49.0/dprint-x86_64-unknown-linux-gnu.zip
12+
ktlint bin https://github.com/pinterest/ktlint/releases/download/1.8.0/ktlint

.github/tools/npm.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ prettier
22
@biomejs/biome
33
sql-formatter
44
@taplo/cli
5+
eslint
6+
eslint_d
7+
stylelint

.github/tools/pip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cpplint
55
docformatter
66
flake8
77
mypy
8+
pylint
89
ruff
910
sqlfluff
1011
yapf

.github/workflows/ci.yaml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ jobs:
9090
- name: Install tools
9191
run: |
9292
xargs -L1 go install < .github/tools/go.txt
93+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.8
9394
luarocks install busted --local
9495
luarocks install nlua --local
9596
- name: Clone guard.nvim
@@ -163,13 +164,17 @@ jobs:
163164
with:
164165
neovim: true
165166
version: nightly
167+
- uses: actions/setup-java@v4
168+
with:
169+
distribution: temurin
170+
java-version: 21
166171
- uses: leso-kn/gh-actions-lua@master
167172
with:
168173
luaVersion: "5.1"
169174
- uses: hishamhm/gh-actions-luarocks@master
170175
- name: Install tools
171176
run: |
172-
sudo apt-get install -y zsh
177+
sudo apt-get install -y zsh shellcheck
173178
luarocks install busted --local
174179
luarocks install nlua --local
175180
bash .github/scripts/install-binary-tools.sh "$HOME/.local/bin"
@@ -205,3 +210,62 @@ jobs:
205210
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
206211
busted --lua nlua test/apt/*_spec.lua
207212
213+
test-dotnet:
214+
runs-on: ubuntu-latest
215+
steps:
216+
- uses: actions/checkout@v4
217+
- uses: rhysd/action-setup-vim@v1
218+
with:
219+
neovim: true
220+
version: nightly
221+
- uses: actions/setup-dotnet@v4
222+
with:
223+
dotnet-version: '8.0'
224+
- uses: leso-kn/gh-actions-lua@master
225+
with:
226+
luaVersion: "5.1"
227+
- uses: hishamhm/gh-actions-luarocks@master
228+
- name: Install tools
229+
run: |
230+
dotnet tool install -g csharpier
231+
luarocks install busted --local
232+
luarocks install nlua --local
233+
- name: Clone guard.nvim
234+
run: git clone --depth 1 https://github.com/nvimdev/guard.nvim && mv guard.nvim/lua/guard lua/
235+
- name: Run tests
236+
run: |
237+
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
238+
busted --lua nlua test/dotnet/*_spec.lua
239+
240+
test-ruby:
241+
runs-on: ubuntu-latest
242+
steps:
243+
- uses: actions/checkout@v4
244+
- uses: rhysd/action-setup-vim@v1
245+
with:
246+
neovim: true
247+
version: nightly
248+
- uses: ruby/setup-ruby@v1
249+
with:
250+
ruby-version: '3.3'
251+
- uses: leso-kn/gh-actions-lua@master
252+
with:
253+
luaVersion: "5.1"
254+
- uses: hishamhm/gh-actions-luarocks@master
255+
- name: Install tools
256+
run: |
257+
gem install rubocop bundler
258+
luarocks install busted --local
259+
luarocks install nlua --local
260+
- name: Setup rubocop Gemfile
261+
run: |
262+
mkdir -p /tmp/rubocop-test
263+
printf "source 'https://rubygems.org'\ngem 'rubocop'\n" > /tmp/rubocop-test/Gemfile
264+
cd /tmp/rubocop-test && bundle install
265+
- name: Clone guard.nvim
266+
run: git clone --depth 1 https://github.com/nvimdev/guard.nvim && mv guard.nvim/lua/guard lua/
267+
- name: Run tests
268+
run: |
269+
export LUA_PATH="lua/?.lua;lua/?/init.lua;$LUA_PATH"
270+
busted --lua nlua test/ruby/*_spec.lua
271+

test/binary/buf_spec.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
describe('buf', function()
2+
local tmpdir = vim.fn.getcwd() .. '/tmp-buf-test'
3+
4+
setup(function()
5+
vim.fn.mkdir(tmpdir, 'p')
6+
end)
7+
8+
teardown(function()
9+
vim.fn.delete(tmpdir, 'rf')
10+
end)
11+
12+
it('can format', function()
13+
local formatted = require('test.helper').run_fmt('buf', 'proto', {
14+
'syntax="proto3";',
15+
'package test;',
16+
'message Foo{string bar=1;}',
17+
}, { tmpdir = tmpdir })
18+
assert.is_true(#formatted > 3)
19+
end)
20+
end)

test/binary/cbfmt_spec.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
describe('cbfmt', function()
2+
local tmpdir = vim.fn.getcwd() .. '/tmp-cbfmt-test'
3+
4+
setup(function()
5+
vim.fn.mkdir(tmpdir, 'p')
6+
vim.fn.writefile({ '[languages]' }, tmpdir .. '/.cbfmt.toml')
7+
end)
8+
9+
teardown(function()
10+
vim.fn.delete(tmpdir, 'rf')
11+
end)
12+
13+
it('can format', function()
14+
local formatted = require('test.helper').run_fmt('cbfmt', 'md', {
15+
'# Title',
16+
'',
17+
'Some text.',
18+
}, { cwd = tmpdir })
19+
assert.are.same({
20+
'# Title',
21+
'',
22+
'Some text.',
23+
}, formatted)
24+
end)
25+
end)

test/binary/detekt_spec.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
describe('detekt', function()
2+
it('can lint', function()
3+
local helper = require('test.helper')
4+
local bufnr, diagnostics = helper.run_lint('detekt', 'kt', {
5+
[[fun main() {]],
6+
[[ val x = 42]],
7+
[[ if (x > 0) {]],
8+
[[ println(x)]],
9+
[[ }]],
10+
[[}]],
11+
})
12+
assert.is_true(#diagnostics > 0)
13+
helper.assert_diag(diagnostics[1], {
14+
bufnr = bufnr,
15+
source = 'detekt',
16+
})
17+
for _, d in ipairs(diagnostics) do
18+
assert.equal(bufnr, d.bufnr)
19+
assert.equal('detekt', d.source)
20+
assert.is_number(d.lnum)
21+
assert.is_string(d.message)
22+
end
23+
end)
24+
end)

test/binary/dprint_spec.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
describe('dprint', function()
2+
local tmpdir = vim.fn.getcwd() .. '/tmp-dprint-test'
3+
4+
setup(function()
5+
vim.fn.mkdir(tmpdir, 'p')
6+
vim.fn.writefile({
7+
'{',
8+
' "typescript": {},',
9+
' "plugins": [',
10+
' "https://plugins.dprint.dev/typescript-0.93.3.wasm"',
11+
' ]',
12+
'}',
13+
}, tmpdir .. '/dprint.json')
14+
end)
15+
16+
teardown(function()
17+
vim.fn.delete(tmpdir, 'rf')
18+
end)
19+
20+
it('can format', function()
21+
local formatted = require('test.helper').run_fmt('dprint', 'ts', {
22+
'const x=1;',
23+
'function foo( ){return x}',
24+
}, { cwd = tmpdir, tmpdir = tmpdir })
25+
assert.is_true(#formatted > 0)
26+
assert.is_truthy(formatted[1]:find('const x'))
27+
end)
28+
end)

test/binary/hadolint_spec.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
describe('hadolint', function()
2+
it('can lint', function()
3+
local helper = require('test.helper')
4+
local bufnr, diagnostics = helper.run_lint('hadolint', 'dockerfile', {
5+
[[FROM ubuntu]],
6+
[[RUN apt-get install python]],
7+
})
8+
assert.is_true(#diagnostics > 0)
9+
helper.assert_diag(diagnostics[1], {
10+
bufnr = bufnr,
11+
source = 'hadolint',
12+
severity = vim.diagnostic.severity.WARN,
13+
})
14+
for _, d in ipairs(diagnostics) do
15+
assert.equal(bufnr, d.bufnr)
16+
assert.equal('hadolint', d.source)
17+
assert.is_number(d.lnum)
18+
assert.is_string(d.message)
19+
end
20+
end)
21+
end)

test/binary/ktlint_spec.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
describe('ktlint', function()
2+
it('can lint', function()
3+
local helper = require('test.helper')
4+
local bufnr, diagnostics = helper.run_lint('ktlint', 'kt', {
5+
'fun main() {',
6+
' val x=1',
7+
' println(x)',
8+
'}',
9+
})
10+
assert.is_true(#diagnostics > 0)
11+
helper.assert_diag(diagnostics[1], {
12+
bufnr = bufnr,
13+
source = 'ktlint',
14+
})
15+
for _, d in ipairs(diagnostics) do
16+
assert.equal(bufnr, d.bufnr)
17+
assert.equal('ktlint', d.source)
18+
assert.is_number(d.lnum)
19+
assert.is_string(d.message)
20+
end
21+
end)
22+
end)

0 commit comments

Comments
 (0)