aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mason-core
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-06-28 19:26:23 +0200
committerGitHub <noreply@github.com>2023-06-28 19:26:23 +0200
commit758ac5b35e823eee74a90f855b2a66afc51ec92d (patch)
tree100dc05b4b2e337960167cf5f8c9a94b79420f59 /tests/mason-core
parentchore(ci): add nvim v0.9.1 to test matrix (#1378) (diff)
downloadmason-758ac5b35e823eee74a90f855b2a66afc51ec92d.tar
mason-758ac5b35e823eee74a90f855b2a66afc51ec92d.tar.gz
mason-758ac5b35e823eee74a90f855b2a66afc51ec92d.tar.bz2
mason-758ac5b35e823eee74a90f855b2a66afc51ec92d.tar.lz
mason-758ac5b35e823eee74a90f855b2a66afc51ec92d.tar.xz
mason-758ac5b35e823eee74a90f855b2a66afc51ec92d.tar.zst
mason-758ac5b35e823eee74a90f855b2a66afc51ec92d.zip
feat(installer): write more installation output to stdout (#1376)
This should give better insights into the installation progress.
Diffstat (limited to 'tests/mason-core')
-rw-r--r--tests/mason-core/installer/managers/cargo_spec.lua28
-rw-r--r--tests/mason-core/installer/managers/composer_spec.lua12
-rw-r--r--tests/mason-core/installer/managers/gem_spec.lua11
-rw-r--r--tests/mason-core/installer/managers/golang_spec.lua13
-rw-r--r--tests/mason-core/installer/managers/luarocks_spec.lua12
-rw-r--r--tests/mason-core/installer/managers/npm_spec.lua12
-rw-r--r--tests/mason-core/installer/managers/nuget_spec.lua12
-rw-r--r--tests/mason-core/installer/managers/opam_spec.lua13
-rw-r--r--tests/mason-core/installer/managers/pypi_spec.lua13
9 files changed, 116 insertions, 10 deletions
diff --git a/tests/mason-core/installer/managers/cargo_spec.lua b/tests/mason-core/installer/managers/cargo_spec.lua
index efc6fc84..475c2c86 100644
--- a/tests/mason-core/installer/managers/cargo_spec.lua
+++ b/tests/mason-core/installer/managers/cargo_spec.lua
@@ -1,10 +1,11 @@
local cargo = require "mason-core.installer.managers.cargo"
local installer = require "mason-core.installer"
+local spy = require "luassert.spy"
describe("cargo manager", function()
it("should install", function()
- local handle = InstallHandleGenerator "dummy"
- local ctx = InstallContextGenerator(handle)
+ local ctx = create_dummy_context()
+
installer.exec_in_context(ctx, function()
cargo.install("my-crate", "1.0.0")
end)
@@ -21,9 +22,19 @@ describe("cargo manager", function()
}
end)
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+
+ installer.exec_in_context(ctx, function()
+ cargo.install("my-crate", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing crate my-crate@1.0.0…\n"
+ end)
+
it("should install locked", function()
- local handle = InstallHandleGenerator "dummy"
- local ctx = InstallContextGenerator(handle)
+ local ctx = create_dummy_context()
installer.exec_in_context(ctx, function()
cargo.install("my-crate", "1.0.0", {
locked = true,
@@ -43,8 +54,7 @@ describe("cargo manager", function()
end)
it("should install provided features", function()
- local handle = InstallHandleGenerator "dummy"
- local ctx = InstallContextGenerator(handle)
+ local ctx = create_dummy_context()
installer.exec_in_context(ctx, function()
cargo.install("my-crate", "1.0.0", {
features = "lsp,cli",
@@ -64,8 +74,7 @@ describe("cargo manager", function()
end)
it("should install git tag source", function()
- local handle = InstallHandleGenerator "dummy"
- local ctx = InstallContextGenerator(handle)
+ local ctx = create_dummy_context()
installer.exec_in_context(ctx, function()
cargo.install("my-crate", "1.0.0", {
git = {
@@ -87,8 +96,7 @@ describe("cargo manager", function()
end)
it("should install git rev source", function()
- local handle = InstallHandleGenerator "dummy"
- local ctx = InstallContextGenerator(handle)
+ local ctx = create_dummy_context()
installer.exec_in_context(ctx, function()
cargo.install("my-crate", "16dfc89abd413c391e5b63ae5d132c22843ce9a7", {
git = {
diff --git a/tests/mason-core/installer/managers/composer_spec.lua b/tests/mason-core/installer/managers/composer_spec.lua
index 733517c9..a8ccaffb 100644
--- a/tests/mason-core/installer/managers/composer_spec.lua
+++ b/tests/mason-core/installer/managers/composer_spec.lua
@@ -1,5 +1,6 @@
local composer = require "mason-core.installer.managers.composer"
local installer = require "mason-core.installer"
+local spy = require "luassert.spy"
describe("composer manager", function()
it("should install", function()
@@ -19,4 +20,15 @@ describe("composer manager", function()
"my-package:1.0.0",
}
end)
+
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+
+ installer.exec_in_context(ctx, function()
+ composer.install("my-package", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing composer package my-package@1.0.0…\n"
+ end)
end)
diff --git a/tests/mason-core/installer/managers/gem_spec.lua b/tests/mason-core/installer/managers/gem_spec.lua
index 149efb00..7ac8c33e 100644
--- a/tests/mason-core/installer/managers/gem_spec.lua
+++ b/tests/mason-core/installer/managers/gem_spec.lua
@@ -1,5 +1,6 @@
local gem = require "mason-core.installer.managers.gem"
local installer = require "mason-core.installer"
+local spy = require "luassert.spy"
describe("gem manager", function()
it("should install", function()
@@ -24,6 +25,16 @@ describe("gem manager", function()
}
end)
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+ installer.exec_in_context(ctx, function()
+ gem.install("my-gem", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing gem my-gem@1.0.0…\n"
+ end)
+
it("should install extra packages", function()
local ctx = create_dummy_context()
installer.exec_in_context(ctx, function()
diff --git a/tests/mason-core/installer/managers/golang_spec.lua b/tests/mason-core/installer/managers/golang_spec.lua
index 4c3c4517..58e4c4b8 100644
--- a/tests/mason-core/installer/managers/golang_spec.lua
+++ b/tests/mason-core/installer/managers/golang_spec.lua
@@ -1,9 +1,11 @@
local golang = require "mason-core.installer.managers.golang"
local installer = require "mason-core.installer"
+local spy = require "luassert.spy"
describe("golang manager", function()
it("should install", function()
local ctx = create_dummy_context()
+
installer.exec_in_context(ctx, function()
golang.install("my-golang", "1.0.0")
end)
@@ -19,6 +21,17 @@ describe("golang manager", function()
}
end)
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+
+ installer.exec_in_context(ctx, function()
+ golang.install("my-golang", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing go package my-golang@1.0.0…\n"
+ end)
+
it("should install extra packages", function()
local ctx = create_dummy_context()
installer.exec_in_context(ctx, function()
diff --git a/tests/mason-core/installer/managers/luarocks_spec.lua b/tests/mason-core/installer/managers/luarocks_spec.lua
index 6dcc1b4f..3be963a8 100644
--- a/tests/mason-core/installer/managers/luarocks_spec.lua
+++ b/tests/mason-core/installer/managers/luarocks_spec.lua
@@ -1,5 +1,6 @@
local installer = require "mason-core.installer"
local luarocks = require "mason-core.installer.managers.luarocks"
+local spy = require "luassert.spy"
local stub = require "luassert.stub"
describe("luarocks manager", function()
@@ -60,4 +61,15 @@ describe("luarocks manager", function()
{ "my-rock", "1.0.0" },
}
end)
+
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ stub(ctx, "promote_cwd")
+ spy.on(ctx.stdio_sink, "stdout")
+ installer.exec_in_context(ctx, function()
+ luarocks.install("my-rock", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing luarocks package my-rock@1.0.0…\n"
+ end)
end)
diff --git a/tests/mason-core/installer/managers/npm_spec.lua b/tests/mason-core/installer/managers/npm_spec.lua
index 4f81132b..59a8c84f 100644
--- a/tests/mason-core/installer/managers/npm_spec.lua
+++ b/tests/mason-core/installer/managers/npm_spec.lua
@@ -3,6 +3,7 @@ local installer = require "mason-core.installer"
local match = require "luassert.match"
local npm = require "mason-core.installer.managers.npm"
local spawn = require "mason-core.spawn"
+local spy = require "luassert.spy"
local stub = require "luassert.stub"
describe("npm manager", function()
@@ -78,4 +79,15 @@ describe("npm manager", function()
{ "extra-package" },
}
end)
+
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+
+ installer.exec_in_context(ctx, function()
+ npm.install("my-package", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing npm package my-package@1.0.0…\n"
+ end)
end)
diff --git a/tests/mason-core/installer/managers/nuget_spec.lua b/tests/mason-core/installer/managers/nuget_spec.lua
index 1bdecf37..8d4b0e87 100644
--- a/tests/mason-core/installer/managers/nuget_spec.lua
+++ b/tests/mason-core/installer/managers/nuget_spec.lua
@@ -1,5 +1,6 @@
local installer = require "mason-core.installer"
local nuget = require "mason-core.installer.managers.nuget"
+local spy = require "luassert.spy"
describe("nuget manager", function()
it("should install", function()
@@ -18,4 +19,15 @@ describe("nuget manager", function()
"nuget-package",
}
end)
+
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+
+ installer.exec_in_context(ctx, function()
+ nuget.install("nuget-package", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing nuget package nuget-package@1.0.0…\n"
+ end)
end)
diff --git a/tests/mason-core/installer/managers/opam_spec.lua b/tests/mason-core/installer/managers/opam_spec.lua
index c1fe59f6..cc552114 100644
--- a/tests/mason-core/installer/managers/opam_spec.lua
+++ b/tests/mason-core/installer/managers/opam_spec.lua
@@ -1,9 +1,11 @@
local installer = require "mason-core.installer"
local opam = require "mason-core.installer.managers.opam"
+local spy = require "luassert.spy"
describe("opam manager", function()
it("should install", function()
local ctx = create_dummy_context()
+
installer.exec_in_context(ctx, function()
opam.install("opam-package", "1.0.0")
end)
@@ -17,4 +19,15 @@ describe("opam manager", function()
"opam-package.1.0.0",
}
end)
+
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+
+ installer.exec_in_context(ctx, function()
+ opam.install("opam-package", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing opam package opam-package@1.0.0…\n"
+ end)
end)
diff --git a/tests/mason-core/installer/managers/pypi_spec.lua b/tests/mason-core/installer/managers/pypi_spec.lua
index 45b63d26..cb4bc2b3 100644
--- a/tests/mason-core/installer/managers/pypi_spec.lua
+++ b/tests/mason-core/installer/managers/pypi_spec.lua
@@ -1,6 +1,7 @@
local installer = require "mason-core.installer"
local path = require "mason-core.path"
local pypi = require "mason-core.installer.managers.pypi"
+local spy = require "luassert.spy"
local stub = require "luassert.stub"
---@param ctx InstallContext
@@ -17,6 +18,7 @@ describe("pypi manager", function()
it("should init venv without upgrading pip", function()
local ctx = create_dummy_context()
stub(ctx, "promote_cwd")
+
installer.exec_in_context(ctx, function()
pypi.init { upgrade_pip = false }
end)
@@ -77,6 +79,17 @@ describe("pypi manager", function()
}
end)
+ it("should write output", function()
+ local ctx = create_dummy_context()
+ spy.on(ctx.stdio_sink, "stdout")
+
+ installer.exec_in_context(ctx, function()
+ pypi.install("pypi-package", "1.0.0")
+ end)
+
+ assert.spy(ctx.stdio_sink.stdout).was_called_with "Installing pip package pypi-package@1.0.0…\n"
+ end)
+
it("should install extra specifier", function()
local ctx = create_dummy_context()
installer.exec_in_context(ctx, function()