Skip to content

Commit

Permalink
Added make test
Browse files Browse the repository at this point in the history
  • Loading branch information
desdic committed Feb 25, 2024
1 parent c5bae08 commit c4335e4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/make/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.PHONY: all

all: lint test

test:
nvim --headless -u scripts/minimal_init.lua -c "PlenaryBustedDirectory tests/ { minimal_init = './scripts/minimal_init.lua' }"

lint:
luacheck lua/telescope

docgen:
nvim --headless --noplugin -u scripts/minimal_init.vim -c "luafile ./scripts/gendocs.lua" -c 'qa'
33 changes: 33 additions & 0 deletions tests/make_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe("make", function()
local core = require("agrolens.core")
local buffers = nil
local eq = assert.equals


it("load", function()
vim.cmd.edit("tests/make/Makefile")
buffers = vim.api.nvim_list_bufs()
eq(#buffers, 1)

local content = vim.api.nvim_buf_get_lines(buffers[1], 0, -1, false)

-- make sure buffer has content
eq(string.match(content[1], "all"), "all")

core.get_captures({ queries = { "labels" }, bufids = buffers })
end)

it("labels", function()
local entries = core.get_captures({ queries = { "labels" }, bufids = buffers })

eq(#entries, 5)
eq(entries[1].filename, "tests/make/Makefile")
eq(entries[1].lnum, 1)
eq(entries[1].col, 0)
eq(entries[1].line, ".PHONY: all")
eq(entries[2].line, "all: lint test")
eq(entries[3].line, "test:")
eq(entries[4].line, "lint:")
eq(entries[5].line, "docgen:")
end)
end)

0 comments on commit c4335e4

Please sign in to comment.