Skip to content

Commit f4fb957

Browse files
committed
chore: don't hardcode bufnr in assertion
1 parent 826b44c commit f4fb957

9 files changed

Lines changed: 22 additions & 50 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('selene', function()
4848
require('guard').setup()
4949
-- Giving example input to the helper
5050
-- the helper creates a new buffer with it, requires lint, and returns the diagnostics
51-
local diagnostics = require('test.linter.helper').test_with('lua', {
51+
local buf, diagnostics = require('test.linter.helper').test_with('lua', {
5252
-- Make sure the input actually has some problems that the linter detects
5353
[[local M = {}]],
5454
[[function M.foo()]],
@@ -60,7 +60,7 @@ describe('selene', function()
6060
-- Show that the diagnostics is indeed valid
6161
assert.are.same({
6262
{
63-
bufnr = 3,
63+
bufnr = buf,
6464
col = 0,
6565
end_col = 0,
6666
end_lnum = 4,

test/linter/clang-tidy_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('clang-tidy', function()
55
local ft = require('guard.filetype')
66
ft('c'):lint('clang-tidy')
77

8-
local diagnostics = helper.test_with('c', {
8+
local buf, diagnostics = helper.test_with('c', {
99
[[#include <stdio.h>]],
1010
[[int main() {]],
1111
[[ int x = 10;]],
@@ -16,7 +16,7 @@ describe('clang-tidy', function()
1616
})
1717
assert.are.same({
1818
{
19-
bufnr = 3,
19+
bufnr = buf,
2020
col = 19,
2121
end_col = 19,
2222
end_lnum = 4,

test/linter/flake8_spec.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('flake8', function()
55
local ft = require('guard.filetype')
66
ft('python'):lint('flake8')
77

8-
local diagnostics = helper.test_with('python', {
8+
local buf, diagnostics = helper.test_with('python', {
99
[[import os]],
1010
[[]],
1111
[[def foo(n):]],
@@ -15,7 +15,7 @@ describe('flake8', function()
1515
})
1616
assert.are.same({
1717
{
18-
bufnr = 3,
18+
bufnr = buf,
1919
col = 0,
2020
end_col = 0,
2121
end_lnum = 0,
@@ -26,7 +26,7 @@ describe('flake8', function()
2626
source = 'flake8',
2727
},
2828
{
29-
bufnr = 3,
29+
bufnr = buf,
3030
col = 0,
3131
end_col = 0,
3232
end_lnum = 2,
@@ -37,7 +37,7 @@ describe('flake8', function()
3737
source = 'flake8',
3838
},
3939
{
40-
bufnr = 3,
40+
bufnr = buf,
4141
col = 9,
4242
end_col = 9,
4343
end_lnum = 4,
@@ -48,7 +48,7 @@ describe('flake8', function()
4848
source = 'flake8',
4949
},
5050
{
51-
bufnr = 3,
51+
bufnr = buf,
5252
col = 9,
5353
end_col = 9,
5454
end_lnum = 4,
@@ -59,7 +59,7 @@ describe('flake8', function()
5959
source = 'flake8',
6060
},
6161
{
62-
bufnr = 3,
62+
bufnr = buf,
6363
col = 15,
6464
end_col = 15,
6565
end_lnum = 4,
@@ -70,7 +70,7 @@ describe('flake8', function()
7070
source = 'flake8',
7171
},
7272
{
73-
bufnr = 3,
73+
bufnr = buf,
7474
col = 17,
7575
end_col = 17,
7676
end_lnum = 4,
@@ -81,7 +81,7 @@ describe('flake8', function()
8181
source = 'flake8',
8282
},
8383
{
84-
bufnr = 3,
84+
bufnr = buf,
8585
col = 0,
8686
end_col = 0,
8787
end_lnum = 5,
@@ -92,7 +92,7 @@ describe('flake8', function()
9292
source = 'flake8',
9393
},
9494
{
95-
bufnr = 3,
95+
bufnr = buf,
9696
col = 79,
9797
end_col = 79,
9898
end_lnum = 5,

test/linter/helper.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function M.test_with(ft, input)
1616

1717
lint.do_lint(bufnr)
1818
vim.wait(3000)
19-
return vim.diagnostic.get(bufnr)
19+
return bufnr, vim.diagnostic.get(bufnr)
2020
end
2121

2222
return M

test/linter/hlint_spec.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ describe('hlint', function()
55
local ft = require('guard.filetype')
66
ft('haskell'):lint('hlint')
77

8-
local diagnostics = helper.test_with('haskell', {
8+
local buf, diagnostics = helper.test_with('haskell', {
99
[[concat $ map escapeC s]],
1010
[[ftable ++ (map (\ (c, x) -> (toUpper c, urlEncode x)) ftable)]],
1111
[[mapM (delete_line (fn2fp f) line) old]],
1212
})
1313
assert.are.same({
1414
{
15-
bufnr = 3,
15+
bufnr = buf,
1616
col = 0,
1717
end_col = 0,
1818
end_lnum = 0,
@@ -23,7 +23,7 @@ describe('hlint', function()
2323
source = 'hlint',
2424
},
2525
{
26-
bufnr = 3,
26+
bufnr = buf,
2727
col = 10,
2828
end_col = 10,
2929
end_lnum = 1,
@@ -34,7 +34,7 @@ describe('hlint', function()
3434
source = 'hlint',
3535
},
3636
{
37-
bufnr = 3,
37+
bufnr = buf,
3838
col = 16,
3939
end_col = 16,
4040
end_lnum = 1,

test/linter/luacheck_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ describe('luacheck', function()
55
local ft = require('guard.filetype')
66
ft('lua'):lint('luacheck')
77

8-
local diagnostics = helper.test_with('lua', {
8+
local buf, diagnostics = helper.test_with('lua', {
99
[[local M = {}]],
1010
[[function M.foo()]],
1111
[[ print("foo")]],
@@ -15,7 +15,7 @@ describe('luacheck', function()
1515
})
1616
assert.are.same({
1717
{
18-
bufnr = 3,
18+
bufnr = buf,
1919
col = 0,
2020
end_col = 0,
2121
end_lnum = 4,

test/linter/pylint_spec.lua

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

test/linter/ruff_spec.lua

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

test/linter/selene_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ describe('selene', function()
55
local ft = require('guard.filetype')
66
ft('lua'):lint('selene')
77

8-
local diagnostics = helper.test_with('lua', {
8+
local buf, diagnostics = helper.test_with('lua', {
99
[[print(a)]],
1010
})
1111
assert.are.same({
1212
{
13-
bufnr = 3,
13+
bufnr = buf,
1414
col = 6,
1515
end_col = 0,
1616
end_lnum = 0,

0 commit comments

Comments
 (0)