aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core/spawn_spec.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-12-21 13:44:10 +0100
committerGitHub <noreply@github.com>2022-12-21 13:44:10 +0100
commit28408c857a8f821ff504c9383c96af22b7ca66d9 (patch)
treeff4ec6d36d9a44fcc77f2ca7ec54781285b32de8 /tests/mason-core/spawn_spec.lua
parentfix(powershell): use pwsh if available (#782) (diff)
downloadmason-28408c857a8f821ff504c9383c96af22b7ca66d9.tar
mason-28408c857a8f821ff504c9383c96af22b7ca66d9.tar.gz
mason-28408c857a8f821ff504c9383c96af22b7ca66d9.tar.bz2
mason-28408c857a8f821ff504c9383c96af22b7ca66d9.tar.lz
mason-28408c857a8f821ff504c9383c96af22b7ca66d9.tar.xz
mason-28408c857a8f821ff504c9383c96af22b7ca66d9.tar.zst
mason-28408c857a8f821ff504c9383c96af22b7ca66d9.zip
Revert "fix(spawn): always expand cmd if PATH is not modified (#773)" (#783)
This reverts commit dd04b4105e84620685c37efb6ca935d282e11465.
Diffstat (limited to 'tests/mason-core/spawn_spec.lua')
-rw-r--r--tests/mason-core/spawn_spec.lua62
1 files changed, 15 insertions, 47 deletions
diff --git a/tests/mason-core/spawn_spec.lua b/tests/mason-core/spawn_spec.lua
index 59ccd533..f9f90411 100644
--- a/tests/mason-core/spawn_spec.lua
+++ b/tests/mason-core/spawn_spec.lua
@@ -66,7 +66,7 @@ describe("async spawn", function()
assert.equals("", result:get_or_nil().stderr)
assert.spy(process.spawn).was_called(1)
assert.spy(process.spawn).was_called_with(
- match.matches "bash$",
+ "bash",
match.tbl_containing {
stdio_sink = match.tbl_containing {
stdout = match.is_function(),
@@ -139,8 +139,7 @@ describe("async spawn", function()
callback(false)
end)
- local result = spawn.bash {}
- assert.spy(process.spawn).was_called(1)
+ local result = spawn.my_cmd {}
assert.is_true(result:is_failure())
assert.is_nil(result:err_or_nil().exit_code)
end)
@@ -156,40 +155,33 @@ describe("async spawn", function()
local result = spawn.bash {}
assert.is_true(result:is_failure())
- assert.is_true(
- match.matches "spawn: .+bash failed with exit code 127 and signal %-%. This is an error message for .+bash!"(
- tostring(result:err_or_nil())
- )
+ assert.equals(
+ "spawn: bash failed with exit code 127 and signal -. This is an error message for bash!",
+ tostring(result:err_or_nil())
)
end)
)
it(
- "should fail if unable to expand command",
+ "should check whether command is executable",
async_test(function()
- spy.on(process, "spawn")
- stub(vim.fn, "exepath", function()
- return ""
- end)
-
- local result = spawn.unexpand_cmd {}
+ local result = spawn.my_cmd {}
assert.is_true(result:is_failure())
- assert.is_true(
- match.matches "spawn: unexpand_cmd failed with exit code %- and signal %-%. unexpand_cmd is not executable"(
- tostring(result:err_or_nil())
- )
+ assert.equals(
+ "spawn: my_cmd failed with exit code - and signal -. my_cmd is not executable",
+ tostring(result:err_or_nil())
)
end)
)
it(
- "should not expand cmd if custom PATH is used",
+ "should skip checking whether command is executable",
async_test(function()
stub(process, "spawn", function(_, _, callback)
callback(false, 127)
end)
- local result = spawn.my_cmd { "arg1", env = { PATH = "/bin" } }
+ local result = spawn.my_cmd { "arg1", check_executable = false }
assert.is_true(result:is_failure())
assert.spy(process.spawn).was_called(1)
assert.spy(process.spawn).was_called_with(
@@ -203,17 +195,17 @@ describe("async spawn", function()
)
it(
- "should skip expanding command if with_paths is provided",
+ "should skip checking whether command is executable if with_paths is provided",
async_test(function()
stub(process, "spawn", function(_, _, callback)
callback(false, 127)
end)
- local result = spawn.custom_path { "arg1", with_paths = {} }
+ local result = spawn.my_cmd { "arg1", with_paths = {} }
assert.is_true(result:is_failure())
assert.spy(process.spawn).was_called(1)
assert.spy(process.spawn).was_called_with(
- "custom_path",
+ "my_cmd",
match.tbl_containing {
args = match.same { "arg1" },
},
@@ -221,28 +213,4 @@ describe("async spawn", function()
)
end)
)
-
- it(
- "should use expanded command path",
- async_test(function()
- stub(vim.fn, "exepath", function()
- return "/abs/path/to/cmd"
- end)
- stub(process, "spawn", function(_, _, callback)
- callback(false)
- end)
-
- spawn.the_command { "arg1", "arg2" }
- assert.spy(vim.fn.exepath).was_called(1)
- assert.spy(vim.fn.exepath).was_called_with "the_command"
- assert.spy(process.spawn).was_called(1)
- assert.spy(process.spawn).was_called_with(
- "/abs/path/to/cmd",
- match.tbl_containing {
- args = match.same { "arg1", "arg2" },
- },
- match.is_function()
- )
- end)
- )
end)