diff options
| author | William Boman <william@redwill.se> | 2023-03-05 02:33:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-05 01:33:57 +0000 |
| commit | c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991 (patch) | |
| tree | fc51d2ede21b745e9810026281fe4fe427f12b8c /tests | |
| parent | chore: autogenerate (#1051) (diff) | |
| download | mason-c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991.tar mason-c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991.tar.gz mason-c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991.tar.bz2 mason-c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991.tar.lz mason-c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991.tar.xz mason-c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991.tar.zst mason-c1dbd9824ceb03f2e378cc5b732cd11ba0e4c991.zip | |
feat(InstallContext): add strict_mode flag (#1055)
Also add some more ctx.fs methods.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/helpers/lua/test_helpers.lua | 8 | ||||
| -rw-r--r-- | tests/mason-core/installer/context_spec.lua | 1 | ||||
| -rw-r--r-- | tests/mason-core/installer/installer_spec.lua | 20 |
3 files changed, 24 insertions, 5 deletions
diff --git a/tests/helpers/lua/test_helpers.lua b/tests/helpers/lua/test_helpers.lua index 17ec5ae5..08a0e91b 100644 --- a/tests/helpers/lua/test_helpers.lua +++ b/tests/helpers/lua/test_helpers.lua @@ -43,10 +43,10 @@ end ---@param opts PackageInstallOpts? function InstallContextGenerator(handle, opts) local context = InstallContext.new(handle, opts or {}) - context.spawn = setmetatable({}, { - __index = function(s, cmd) - s[cmd] = spy.new(mockx.just_runs()) - return s[cmd] + context.spawn = setmetatable({ strict_mode = false }, { + __index = function(self, cmd) + self[cmd] = spy.new(mockx.just_runs()) + return self[cmd] end, }) return context diff --git a/tests/mason-core/installer/context_spec.lua b/tests/mason-core/installer/context_spec.lua index 0a5b7410..e09ebd52 100644 --- a/tests/mason-core/installer/context_spec.lua +++ b/tests/mason-core/installer/context_spec.lua @@ -105,7 +105,6 @@ cmd.exe /C echo %GREETING% %*]] stub(ctx.cwd, "get") ctx.cwd.get.returns "/tmp/placeholder" stub(ctx, "write_shell_exec_wrapper") - stub(ctx.spawn, "python") ctx:write_pyvenv_exec_wrapper("my-wrapper-script", "my-module") diff --git a/tests/mason-core/installer/installer_spec.lua b/tests/mason-core/installer/installer_spec.lua index 094129f9..66cdb89b 100644 --- a/tests/mason-core/installer/installer_spec.lua +++ b/tests/mason-core/installer/installer_spec.lua @@ -4,6 +4,7 @@ local stub = require "luassert.stub" local fs = require "mason-core.fs" local a = require "mason-core.async" local path = require "mason-core.path" +local Result = require "mason-core.result" local installer = require "mason-core.installer" local InstallContext = require "mason-core.installer.context" @@ -147,4 +148,23 @@ describe("installer", function() .was_called_with(path.package_prefix "dummy/mason-debug.log", "Hello stdout!\nHello stderr!") end) ) + + it( + "should raise spawn errors in strict mode", + async_test(function() + local handle = InstallHandleGenerator "dummy" + stub(handle.package.spec, "install", function(ctx) + ctx.spawn.bash { "-c", "exit 42" } + end) + local result = installer.execute(handle, { debug = true }) + assert.same( + Result.failure { + exit_code = 42, + signal = 0, + }, + result + ) + assert.equals("spawn: bash failed with exit code 42 and signal 0. ", tostring(result:err_or_nil())) + end) + ) end) |
