Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
linrongbin16 committed Dec 30, 2023
1 parent 7e5b522 commit 2249816
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
45 changes: 0 additions & 45 deletions lua/gentags/ctags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,51 +39,6 @@ M.load = function(ctx)
TAGS_LOADED_MAP[ctx.tags_file] = true

Check warning on line 39 in lua/gentags/ctags.lua

View check run for this annotation

Codecov / codecov/patch

lua/gentags/ctags.lua#L37-L39

Added lines #L37 - L39 were not covered by tests
end

--- @param fp any
M._close_file = function(fp)
if fp then
fp:close()
end
end

-- write src into dst
--- @param src string
--- @param dst string
M._dump_file = function(src, dst)
assert(strings.not_empty(src))
assert(strings.not_empty(dst))

local logger = logging.get("gentags") --[[@as commons.logging.Logger]]

local dst_fp = io.open(dst, "w")
local src_fp = io.open(src, "r")
if dst_fp == nil or src_fp == nil then
if dst_fp == nil then
logger:err("|_dump_file| failed to open dst file:%s", vim.inspect(dst))
end
if src_fp == nil then
logger:err("|_dump_file| failed to open src file:%s", vim.inspect(src))
end
M._close_file(dst_fp)
M._close_file(src_fp)
end

---@diagnostic disable-next-line: need-check-nil
local content = src_fp:read("*a")
if content then
---@diagnostic disable-next-line: need-check-nil
dst_fp:write(content)
end

M._close_file(dst_fp)
M._close_file(src_fp)
logger:debug(
"|_dump_file| dump src %s to dst %s",
vim.inspect(src),
vim.inspect(dst)
)
end

--- @param ctx gentags.Context
--- @param on_exit (fun():nil)|nil
--- @return table?
Expand Down
12 changes: 0 additions & 12 deletions test/gentags/ctags_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,4 @@ describe("gentags.ctags", function()
local ok, err = pcall(ctags.terminate, dispatcher.get_context())
end)
end)
describe("[utils]", function()
it("_close_file", function()
local fp = io.open("test.txt", "w+")
ctags._close_file(fp)
end)
it("_dump_file", function()
ctags._dump_file("README.md", "test.txt")
if vim.fn.filereadable("test.txt") > 0 then
vim.cmd([[!rm test.txt]])
end
end)
end)
end)

0 comments on commit 2249816

Please sign in to comment.