aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSteven Arcangeli <506791+stevearc@users.noreply.github.com>2023-09-15 08:35:28 -0700
committerGitHub <noreply@github.com>2023-09-15 08:35:28 -0700
commitfbb18a5b92e2f11aaaef379d74d4a1132a138cb3 (patch)
tree8a9193f0be376d9317f447790f23a5a0f1554a7c /tests
parent3f855f3675a22cb52a6754f3ab073d13528ce0ca (diff)
feat: allow running commands in a shell (#49)
Diffstat (limited to 'tests')
-rw-r--r--tests/runner_spec.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/runner_spec.lua b/tests/runner_spec.lua
index 10ea075..56cf8e2 100644
--- a/tests/runner_spec.lua
+++ b/tests/runner_spec.lua
@@ -102,6 +102,49 @@ describe("runner", function()
local cmd = runner.build_cmd(ctx, config)
assert.are.same({ "echo", "--stdin" }, cmd)
end)
+
+ it("replaces $FILENAME in string args", function()
+ vim.cmd.edit({ args = { "README.md" } })
+ local bufnr = vim.api.nvim_get_current_buf()
+ conform.formatters.test = {
+ meta = { url = "", description = "" },
+ command = "echo",
+ args = "$FILENAME | patch",
+ }
+ 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)
+ end)
+
+ it("replaces $DIRNAME in string args", function()
+ vim.cmd.edit({ args = { "README.md" } })
+ local bufnr = vim.api.nvim_get_current_buf()
+ conform.formatters.test = {
+ meta = { url = "", description = "" },
+ command = "echo",
+ args = "$DIRNAME | patch",
+ }
+ 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)
+ end)
+
+ it("resolves arg function with string results", function()
+ vim.cmd.edit({ args = { "README.md" } })
+ conform.formatters.test = {
+ meta = { url = "", description = "" },
+ command = "echo",
+ args = function()
+ return "| patch"
+ end,
+ }
+ 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)
+ end)
end)
describe("e2e", function()