Skip to content

Commit

Permalink
test: make tests use vim.fn.exepath
Browse files Browse the repository at this point in the history
  • Loading branch information
lopi-py committed Aug 14, 2024
1 parent 66a1c4b commit 031b05a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/runner_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe("runner", function()
local config = assert(conform.get_formatter_config("test"))
local ctx = runner.build_context(0, config)
local cmd = runner.build_cmd("", ctx, config)
assert.are.same({ "echo", vim.api.nvim_buf_get_name(bufnr) }, cmd)
assert.are.same({ vim.fn.exepath("echo"), vim.api.nvim_buf_get_name(bufnr) }, cmd)
end)

it("replaces $DIRNAME in args", function()
Expand All @@ -135,7 +135,10 @@ describe("runner", function()
local config = assert(conform.get_formatter_config("test"))
local ctx = runner.build_context(0, config)
local cmd = runner.build_cmd("", ctx, config)
assert.are.same({ "echo", vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr)) }, cmd)
assert.are.same(
{ vim.fn.exepath("echo"), vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr)) },
cmd
)
end)

it("resolves arg function", function()
Expand All @@ -150,7 +153,7 @@ describe("runner", function()
local config = assert(conform.get_formatter_config("test"))
local ctx = runner.build_context(0, config)
local cmd = runner.build_cmd("", ctx, config)
assert.are.same({ "echo", "--stdin" }, cmd)
assert.are.same({ vim.fn.exepath("echo"), "--stdin" }, cmd)
end)

it("replaces $FILENAME in string args", function()
Expand All @@ -164,7 +167,10 @@ describe("runner", function()
local config = assert(conform.get_formatter_config("test"))
local ctx = runner.build_context(0, config)
local cmd = runner.build_cmd("", ctx, config)
assert.equal("echo " .. vim.api.nvim_buf_get_name(bufnr) .. " | patch", cmd)
assert.equal(
vim.fn.exepath("echo") .. " " .. vim.api.nvim_buf_get_name(bufnr) .. " | patch",
cmd
)
end)

it("replaces $DIRNAME in string args", function()
Expand All @@ -178,7 +184,13 @@ describe("runner", function()
local config = assert(conform.get_formatter_config("test"))
local ctx = runner.build_context(0, config)
local cmd = runner.build_cmd("", ctx, config)
assert.equal("echo " .. vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr)) .. " | patch", cmd)
assert.equal(
vim.fn.exepath("echo")
.. " "
.. vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr))
.. " | patch",
cmd
)
end)

it("resolves arg function with string results", function()
Expand All @@ -193,7 +205,7 @@ describe("runner", function()
local config = assert(conform.get_formatter_config("test"))
local ctx = runner.build_context(0, config)
local cmd = runner.build_cmd("", ctx, config)
assert.equal("echo | patch", cmd)
assert.equal(vim.fn.exepath("echo") .. " | patch", cmd)
end)
end)

Expand Down

0 comments on commit 031b05a

Please sign in to comment.