diff options
| author | William Boman <william@redwill.se> | 2022-12-26 17:38:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-26 17:38:44 +0100 |
| commit | e3d469e7712b81b752cb63813fc7c79e18df279d (patch) | |
| tree | 354e52b175a5c138f99817bee8aba43f86302943 /tests | |
| parent | refactor(installer): write debug log file after installation finishes (#806) (diff) | |
| download | mason-e3d469e7712b81b752cb63813fc7c79e18df279d.tar mason-e3d469e7712b81b752cb63813fc7c79e18df279d.tar.gz mason-e3d469e7712b81b752cb63813fc7c79e18df279d.tar.bz2 mason-e3d469e7712b81b752cb63813fc7c79e18df279d.tar.lz mason-e3d469e7712b81b752cb63813fc7c79e18df279d.tar.xz mason-e3d469e7712b81b752cb63813fc7c79e18df279d.tar.zst mason-e3d469e7712b81b752cb63813fc7c79e18df279d.zip | |
feat(powershell): set $ErrorActionPreference = "Stop"; (#807)
Also write to stdin pipe asynchronously.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason-core/managers/powershell_spec.lua | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/mason-core/managers/powershell_spec.lua b/tests/mason-core/managers/powershell_spec.lua index 3cc78e5e..0d6851d1 100644 --- a/tests/mason-core/managers/powershell_spec.lua +++ b/tests/mason-core/managers/powershell_spec.lua @@ -60,23 +60,33 @@ describe("powershell manager", function() end) it("should provide default powershell options via script stdin", function() - local stdin = mock.new { write = mockx.just_runs, close = mockx.just_runs } + local stdin = mock.new { shutdown = mockx.just_runs } stub(spawn, "pwsh", function(args) args.on_spawn(nil, { stdin }) end) stub(vim.fn, "executable") + stub(vim.loop, "write", function(_, _, callback) + callback() + end) vim.fn.executable.on_call_with("pwsh").returns(1) powershell().script "echo 'Is this bash?'" assert.spy(spawn.pwsh).was_called(1) - assert.spy(stdin.write).was_called(3) - assert.spy(stdin.write).was_called_with(match.is_ref(stdin), " $ProgressPreference = 'SilentlyContinue'; ") + assert.spy(vim.loop.write).was_called(4) + assert + .spy(vim.loop.write) + .was_called_with(match.is_ref(stdin), [[ $ErrorActionPreference = "Stop"; ]], match.is_function()) assert - .spy(stdin.write) - .was_called_with(match.is_ref(stdin), " [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ") - assert.spy(stdin.write).was_called_with(match.is_ref(stdin), "echo 'Is this bash?'") - assert.spy(stdin.close).was_called(1) + .spy(vim.loop.write) + .was_called_with(match.is_ref(stdin), " $ProgressPreference = 'SilentlyContinue'; ", match.is_function()) + assert.spy(vim.loop.write).was_called_with( + match.is_ref(stdin), + " [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; ", + match.is_function() + ) + assert.spy(vim.loop.write).was_called_with(match.is_ref(stdin), "echo 'Is this bash?'", match.is_function()) + assert.spy(stdin.shutdown).was_called(1) end) it("should provide default powershell options via command interface", function() @@ -87,11 +97,10 @@ describe("powershell manager", function() powershell().command "echo 'Is this bash?'" assert.spy(spawn.pwsh).was_called(1) - vim.pretty_print(spawn.pwsh) assert.spy(spawn.pwsh).was_called_with(match.tbl_containing { "-NoProfile", "-Command", - " $ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; echo 'Is this bash?'", + [[ $ErrorActionPreference = "Stop"; $ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; echo 'Is this bash?']], }) end) end) |
