aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/mason-core/installer/installer_spec.lua44
-rw-r--r--tests/mason-core/managers/cargo_spec.lua12
-rw-r--r--tests/mason-core/managers/composer_spec.lua4
-rw-r--r--tests/mason-core/managers/dotnet_spec.lua4
-rw-r--r--tests/mason-core/managers/gem_spec.lua4
-rw-r--r--tests/mason-core/managers/git_spec.lua8
-rw-r--r--tests/mason-core/managers/github_spec.lua8
-rw-r--r--tests/mason-core/managers/go_spec.lua4
-rw-r--r--tests/mason-core/managers/luarocks_spec.lua13
-rw-r--r--tests/mason-core/managers/npm_spec.lua8
-rw-r--r--tests/mason-core/managers/opam_spec.lua4
-rw-r--r--tests/mason-core/managers/pip3_spec.lua15
-rw-r--r--tests/mason-core/terminator_spec.lua25
-rw-r--r--tests/minimal_init.vim5
14 files changed, 107 insertions, 51 deletions
diff --git a/tests/mason-core/installer/installer_spec.lua b/tests/mason-core/installer/installer_spec.lua
index 4a45e997..23eeb69e 100644
--- a/tests/mason-core/installer/installer_spec.lua
+++ b/tests/mason-core/installer/installer_spec.lua
@@ -167,4 +167,48 @@ describe("installer", function()
assert.equals("spawn: bash failed with exit code 42 and signal 0. ", tostring(result:err_or_nil()))
end)
)
+
+ it(
+ "should lock package",
+ async_test(function()
+ local handle = InstallHandleGenerator "dummy"
+ local callback = spy.new()
+ stub(handle.package.spec, "install", function()
+ a.sleep(3000)
+ end)
+
+ a.run(function()
+ return installer.execute(handle, { debug = true })
+ end, callback)
+
+ assert.wait_for(function()
+ assert.is_true(fs.sync.file_exists(path.package_lock "dummy"))
+ end)
+ handle:terminate()
+ assert.wait_for(function()
+ assert.spy(callback).was_called(1)
+ end)
+ assert.is_false(fs.sync.file_exists(path.package_lock "dummy"))
+ end)
+ )
+
+ it(
+ "should not run installer if package lock exists",
+ async_test(function()
+ local handle = InstallHandleGenerator "dummy"
+ local install = spy.new()
+ stub(handle.package.spec, "install", install)
+
+ fs.sync.write_file(path.package_lock "dummy", "dummypid")
+ local result = installer.execute(handle, { debug = true })
+ assert.is_true(fs.sync.file_exists(path.package_lock "dummy"))
+ fs.sync.unlink(path.package_lock "dummy")
+
+ assert.spy(install).was_not_called()
+ assert.equals(
+ "Lockfile exists, installation is already running in another process (pid: dummypid). Run with :MasonInstall --force to bypass.",
+ result:err_or_nil()
+ )
+ end)
+ )
end)
diff --git a/tests/mason-core/managers/cargo_spec.lua b/tests/mason-core/managers/cargo_spec.lua
index 9f43d517..92d04588 100644
--- a/tests/mason-core/managers/cargo_spec.lua
+++ b/tests/mason-core/managers/cargo_spec.lua
@@ -18,7 +18,7 @@ describe("cargo manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, cargo.crate "my-crate")
assert.spy(ctx.spawn.cargo).was_called(1)
assert.spy(ctx.spawn.cargo).was_called_with {
@@ -39,7 +39,7 @@ describe("cargo manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, cargo.crate("my-crate", { git = { url = "https://my-crate.git" } }))
assert.spy(ctx.spawn.cargo).was_called(1)
assert.spy(ctx.spawn.cargo).was_called_with {
@@ -60,7 +60,7 @@ describe("cargo manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, cargo.crate("crate-name", { git = { url = "https://my-crate.git" } }))
assert.spy(ctx.spawn.cargo).was_called(1)
assert.spy(ctx.spawn.cargo).was_called_with {
@@ -81,7 +81,7 @@ describe("cargo manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, cargo.crate("my-crate", { features = "lsp" }))
assert.spy(ctx.spawn.cargo).was_called(1)
assert.spy(ctx.spawn.cargo).was_called_with {
@@ -104,7 +104,7 @@ describe("cargo manager", function()
stub(github, "tag")
github.tag.returns { tag = "v2.1.1", with_receipt = mockx.just_runs }
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(
ctx,
cargo.crate("my-crate", {
@@ -133,7 +133,7 @@ describe("cargo manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, cargo.crate "main-package")
assert.same({
type = "cargo",
diff --git a/tests/mason-core/managers/composer_spec.lua b/tests/mason-core/managers/composer_spec.lua
index 577becaa..5e5b97ba 100644
--- a/tests/mason-core/managers/composer_spec.lua
+++ b/tests/mason-core/managers/composer_spec.lua
@@ -14,7 +14,7 @@ describe("composer manager", function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
ctx.fs.file_exists = spy.new(mockx.returns(false))
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(
ctx,
composer.packages { "main-package", "supporting-package", "supporting-package2" }
@@ -41,7 +41,7 @@ describe("composer manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(
ctx,
composer.packages { "main-package", "supporting-package", "supporting-package2" }
diff --git a/tests/mason-core/managers/dotnet_spec.lua b/tests/mason-core/managers/dotnet_spec.lua
index 441b6a97..b6e0f8c0 100644
--- a/tests/mason-core/managers/dotnet_spec.lua
+++ b/tests/mason-core/managers/dotnet_spec.lua
@@ -7,7 +7,7 @@ describe("dotnet manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, dotnet.package "main-package")
assert.spy(ctx.spawn.dotnet).was_called(1)
assert.spy(ctx.spawn.dotnet).was_called_with {
@@ -27,7 +27,7 @@ describe("dotnet manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, dotnet.package "main-package")
assert.same({
type = "dotnet",
diff --git a/tests/mason-core/managers/gem_spec.lua b/tests/mason-core/managers/gem_spec.lua
index 94443c2e..a99bf5e9 100644
--- a/tests/mason-core/managers/gem_spec.lua
+++ b/tests/mason-core/managers/gem_spec.lua
@@ -15,7 +15,7 @@ describe("gem manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, gem.packages { "main-package", "supporting-package", "supporting-package2" })
assert.spy(ctx.spawn.gem).was_called(1)
assert.spy(ctx.spawn.gem).was_called_with(match.tbl_containing {
@@ -39,7 +39,7 @@ describe("gem manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, gem.packages { "main-package", "supporting-package", "supporting-package2" })
assert.same({
type = "gem",
diff --git a/tests/mason-core/managers/git_spec.lua b/tests/mason-core/managers/git_spec.lua
index 9c1b8a72..50d2470f 100644
--- a/tests/mason-core/managers/git_spec.lua
+++ b/tests/mason-core/managers/git_spec.lua
@@ -14,7 +14,7 @@ describe("git manager", function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
local err = assert.has_error(function()
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, function()
git.clone {}
end)
@@ -29,7 +29,7 @@ describe("git manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, function()
git.clone { "https://github.com/williamboman/mason.nvim.git" }
end)
@@ -50,7 +50,7 @@ describe("git manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "1337" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, function()
git.clone { "https://github.com/williamboman/mason.nvim.git" }
end)
@@ -79,7 +79,7 @@ describe("git manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, function()
git.clone({ "https://github.com/williamboman/mason.nvim.git" }).with_receipt()
end)
diff --git a/tests/mason-core/managers/github_spec.lua b/tests/mason-core/managers/github_spec.lua
index d0a88faa..852c3ff6 100644
--- a/tests/mason-core/managers/github_spec.lua
+++ b/tests/mason-core/managers/github_spec.lua
@@ -14,7 +14,7 @@ describe("github release file", function()
stub(providers.github, "get_latest_release")
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
local source = installer.exec_in_context(ctx, function()
return github.release_file {
repo = "williamboman/mason.nvim",
@@ -40,7 +40,7 @@ describe("github release file", function()
}))
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
local source = installer.exec_in_context(ctx, function()
return github.release_file {
repo = "williamboman/mason.nvim",
@@ -68,7 +68,7 @@ describe("github release version", function()
stub(providers.github, "get_latest_release")
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
local source = installer.exec_in_context(ctx, function()
return github.release_version {
repo = "williamboman/mason.nvim",
@@ -88,7 +88,7 @@ describe("github release version", function()
providers.github.get_latest_release.returns(Result.success { tag_name = "v42" })
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
local source = installer.exec_in_context(ctx, function()
return github.release_version {
repo = "williamboman/mason.nvim",
diff --git a/tests/mason-core/managers/go_spec.lua b/tests/mason-core/managers/go_spec.lua
index b4b0f892..fd3ca043 100644
--- a/tests/mason-core/managers/go_spec.lua
+++ b/tests/mason-core/managers/go_spec.lua
@@ -13,7 +13,7 @@ describe("go manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, go.packages { "main-package", "supporting-package", "supporting-package2" })
assert.spy(ctx.spawn.go).was_called(3)
assert.spy(ctx.spawn.go).was_called_with {
@@ -42,7 +42,7 @@ describe("go manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, go.packages { "main-package", "supporting-package", "supporting-package2" })
assert.same({
type = "go",
diff --git a/tests/mason-core/managers/luarocks_spec.lua b/tests/mason-core/managers/luarocks_spec.lua
index 67cddbc0..d89f65fa 100644
--- a/tests/mason-core/managers/luarocks_spec.lua
+++ b/tests/mason-core/managers/luarocks_spec.lua
@@ -1,14 +1,19 @@
+local a = require "mason-core.async"
local installer = require "mason-core.installer"
local luarocks = require "mason-core.managers.luarocks"
local path = require "mason-core.path"
describe("luarocks manager", function()
+ before_each(function()
+ a.run_blocking(installer.create_prefix_dirs)
+ end)
+
it(
"should install provided package",
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, luarocks.package "lua-cjson")
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
@@ -28,7 +33,7 @@ describe("luarocks manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "1.2.3" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, luarocks.package "lua-cjson")
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
@@ -48,7 +53,7 @@ describe("luarocks manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, luarocks.package("lua-cjson", { dev = true }))
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
@@ -68,7 +73,7 @@ describe("luarocks manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, luarocks.package("luaformatter", { server = "https://luarocks.org/dev" }))
assert.spy(ctx.spawn.luarocks).was_called(1)
assert.spy(ctx.spawn.luarocks).was_called_with {
diff --git a/tests/mason-core/managers/npm_spec.lua b/tests/mason-core/managers/npm_spec.lua
index 2eb4db26..31500ac7 100644
--- a/tests/mason-core/managers/npm_spec.lua
+++ b/tests/mason-core/managers/npm_spec.lua
@@ -15,7 +15,7 @@ describe("npm manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, npm.packages { "main-package", "supporting-package", "supporting-package2" })
assert.spy(ctx.spawn.npm).was_called_with(match.tbl_containing {
"install",
@@ -35,7 +35,7 @@ describe("npm manager", function()
local ctx = InstallContextGenerator(handle)
ctx.fs.file_exists = mockx.returns(false)
ctx.fs.dir_exists = mockx.returns(false)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, function()
npm.install { "main-package", "supporting-package", "supporting-package2" }
end)
@@ -53,7 +53,7 @@ describe("npm manager", function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
ctx.fs.append_file = spy.new(mockx.just_runs())
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, npm.packages { "main-package", "supporting-package", "supporting-package2" })
assert.spy(ctx.fs.append_file).was_called(1)
assert.spy(ctx.fs.append_file).was_called_with(ctx.fs, ".npmrc", "global-style=true")
@@ -65,7 +65,7 @@ describe("npm manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, npm.packages { "main-package", "supporting-package", "supporting-package2" })
assert.same({
type = "npm",
diff --git a/tests/mason-core/managers/opam_spec.lua b/tests/mason-core/managers/opam_spec.lua
index df14023f..297f9d8b 100644
--- a/tests/mason-core/managers/opam_spec.lua
+++ b/tests/mason-core/managers/opam_spec.lua
@@ -8,7 +8,7 @@ describe("opam manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(
ctx,
opam.packages { "main-package", "supporting-package", "supporting-package2" }
@@ -33,7 +33,7 @@ describe("opam manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(
ctx,
opam.packages { "main-package", "supporting-package", "supporting-package2" }
diff --git a/tests/mason-core/managers/pip3_spec.lua b/tests/mason-core/managers/pip3_spec.lua
index bff7eadd..cf7aff9b 100644
--- a/tests/mason-core/managers/pip3_spec.lua
+++ b/tests/mason-core/managers/pip3_spec.lua
@@ -15,6 +15,7 @@ local spawn = require "mason-core.spawn"
describe("pip3 manager", function()
before_each(function()
settings.set(settings._DEFAULT_SETTINGS)
+ a.run_blocking(installer.create_prefix_dirs)
end)
it("normalizes pip3 packages", function()
@@ -29,7 +30,7 @@ describe("pip3 manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(
ctx,
pip3.packages { "main-package", "supporting-package", "supporting-package2" }
@@ -69,7 +70,7 @@ describe("pip3 manager", function()
ctx.spawn.python = spy.new(mockx.throws())
ctx.spawn[vim.g.python3_host_prog] = spy.new(mockx.throws())
local err = assert.has_error(function()
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, pip3.packages { "package" })
end)
vim.g.python3_host_prog = nil
@@ -91,7 +92,7 @@ describe("pip3 manager", function()
ctx.spawn.python = spy.new(mockx.returns {})
ctx.spawn[vim.g.python3_host_prog] = spy.new(mockx.returns {})
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, pip3.packages { "package" })
vim.g.python3_host_prog = nil
assert.spy(ctx.spawn.python3).was_called(0)
@@ -109,7 +110,7 @@ describe("pip3 manager", function()
ctx.spawn.python = spy.new(mockx.returns {})
ctx.spawn[vim.env.HOME .. "/python3"] = spy.new(mockx.returns {})
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, pip3.packages { "package" })
a.scheduler()
vim.g.python3_host_prog = nil
@@ -127,7 +128,7 @@ describe("pip3 manager", function()
}
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, pip3.packages { "package" })
assert.spy(ctx.spawn.python).was_called(1)
assert.spy(ctx.spawn.python).was_called_with {
@@ -153,7 +154,7 @@ describe("pip3 manager", function()
}
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle)
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(ctx, pip3.packages { "package" })
assert.spy(ctx.spawn.python).was_called(2)
assert.spy(ctx.spawn.python).was_called_with {
@@ -184,7 +185,7 @@ describe("pip3 manager", function()
async_test(function()
local handle = InstallHandleGenerator "dummy"
local ctx = InstallContextGenerator(handle, { version = "42.13.37" })
- installer.prepare_installer(ctx)
+ installer.prepare_installer(ctx):get_or_throw()
installer.exec_in_context(
ctx,
pip3.packages { "main-package", "supporting-package", "supporting-package2" }
diff --git a/tests/mason-core/terminator_spec.lua b/tests/mason-core/terminator_spec.lua
index d8d0f2eb..66b48ba4 100644
--- a/tests/mason-core/terminator_spec.lua
+++ b/tests/mason-core/terminator_spec.lua
@@ -11,23 +11,25 @@ describe("terminator", function()
it(
"should terminate all active handles on nvim exit",
async_test(function()
- -- TODO: Tests on CI fail for some reason - sleeping helps
- a.sleep(500)
spy.on(InstallHandle, "terminate")
local dummy = registry.get_package "dummy"
local dummy2 = registry.get_package "dummy2"
for _, pkg in ipairs { dummy, dummy2 } do
- stub(pkg.spec, "install")
- pkg.spec.install.invokes(function()
+ stub(pkg.spec, "install", function()
a.sleep(10000)
end)
end
local dummy_handle = dummy:install()
local dummy2_handle = dummy2:install()
+
+ assert.wait_for(function()
+ assert.spy(dummy.spec.install).was_called()
+ assert.spy(dummy2.spec.install).was_called()
+ end)
+
terminator.terminate(5000)
- a.wait(vim.schedule)
assert.spy(InstallHandle.terminate).was_called(2)
assert.spy(InstallHandle.terminate).was_called_with(match.is_ref(dummy_handle))
assert.spy(InstallHandle.terminate).was_called_with(match.is_ref(dummy2_handle))
@@ -41,22 +43,25 @@ describe("terminator", function()
it(
"should print warning messages",
async_test(function()
- -- TODO: Tests on CI fail for some reason - sleeping helps
- a.sleep(500)
spy.on(vim.api, "nvim_echo")
spy.on(vim.api, "nvim_err_writeln")
spy.on(InstallHandle, "terminate")
local dummy = registry.get_package "dummy"
local dummy2 = registry.get_package "dummy2"
for _, pkg in ipairs { dummy, dummy2 } do
- stub(pkg.spec, "install")
- pkg.spec.install.invokes(function()
+ stub(pkg.spec, "install", function()
a.sleep(10000)
end)
end
local dummy_handle = dummy:install()
local dummy2_handle = dummy2:install()
+
+ assert.wait_for(function()
+ assert.spy(dummy.spec.install).was_called()
+ assert.spy(dummy2.spec.install).was_called()
+ end)
+
terminator.terminate(5000)
assert.spy(vim.api.nvim_echo).was_called(1)
@@ -85,8 +90,6 @@ describe("terminator", function()
it(
"should send SIGTERM and then SIGKILL after grace period",
async_test(function()
- -- TODO: Tests on CI fail for some reason - sleeping helps
- a.sleep(500)
spy.on(InstallHandle, "kill")
local dummy = registry.get_package "dummy"
stub(dummy.spec, "install")
diff --git a/tests/minimal_init.vim b/tests/minimal_init.vim
index 0d9fb211..abd07fa3 100644
--- a/tests/minimal_init.vim
+++ b/tests/minimal_init.vim
@@ -16,8 +16,11 @@ lua require("luassertx")
lua require("test_helpers")
lua <<EOF
+local path = require "mason-core.path"
+
require("mason").setup {
- install_root_dir = vim.env.INSTALL_ROOT_DIR,
+ log_level = vim.log.levels.DEBUG,
+ install_root_dir = vim.env.INSTALL_ROOT_DIR or path.concat { vim.loop.cwd(), "tests", "fixtures", "mason"},
registries = {
"lua:dummy-registry.index"
}