summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-11-02 17:03:21 +0100
committerkylo252 <[email protected]>2021-11-02 17:03:21 +0100
commitb04bb9b79864e846af8936d6cee6ced0dd0bf93e (patch)
tree1d4d0a40330f426b51b8d62409d23869887bf7dd /tests
parent17648e5a07f8c4fe851b09f3037db58c73fe292f (diff)
parent32ca5afa4ad21f1a616cc30323c272191e7548c1 (diff)
Merge remote-tracking branch 'origin/rolling'
Diffstat (limited to 'tests')
-rw-r--r--tests/bootstrap_spec.lua8
-rw-r--r--tests/config_loader_spec.lua8
-rw-r--r--tests/lsp_spec.lua36
-rw-r--r--tests/minimal_lsp.lua25
4 files changed, 47 insertions, 30 deletions
diff --git a/tests/bootstrap_spec.lua b/tests/bootstrap_spec.lua
index d92e213d..c86d22d4 100644
--- a/tests/bootstrap_spec.lua
+++ b/tests/bootstrap_spec.lua
@@ -25,4 +25,12 @@ a.describe("initial start", function()
a.it("should be able to run treesitter without errors", function()
assert.truthy(vim.treesitter.highlighter.active)
end)
+
+ a.it("should be able to pass basic checkhealth without errors", function()
+ vim.cmd "checkhealth nvim"
+ local errmsg = vim.fn.eval "v:errmsg"
+ local exception = vim.fn.eval "v:exception"
+ assert.equal("", errmsg) -- v:errmsg was not updated.
+ assert.equal("", exception)
+ end)
end)
diff --git a/tests/config_loader_spec.lua b/tests/config_loader_spec.lua
index 8e7ab339..1aef0974 100644
--- a/tests/config_loader_spec.lua
+++ b/tests/config_loader_spec.lua
@@ -1,5 +1,6 @@
local a = require "plenary.async_lib.tests"
local config = require "lvim.config"
+local utils = require "lvim.utils"
a.describe("config-loader", function()
local user_config_path = config:get_user_config_path()
@@ -20,18 +21,19 @@ a.describe("config-loader", function()
vim.opt.undodir = "/tmp"
assert.equal(vim.opt.undodir:get()[1], "/tmp")
config:reload()
- assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo")
+ assert.equal(vim.opt.undodir:get()[1], utils.join_paths(get_cache_dir(), "undo"))
end)
a.it("should not get interrupted by errors in user-config", function()
vim.opt.undodir = "/tmp"
assert.equal(vim.opt.undodir:get()[1], "/tmp")
- os.execute("echo bad_string_test >> " .. user_config_path)
+ os.execute(string.format("echo 'bad_string_test' >> %s", user_config_path))
local error_handler = function(msg)
return msg
end
local err = xpcall(config:reload(), error_handler)
assert.falsy(err)
- assert.equal(vim.opt.undodir:get()[1], get_cache_dir() .. "/undo")
+ assert.equal(vim.opt.undodir:get()[1], utils.join_paths(get_cache_dir(), "undo"))
+ os.execute(string.format("echo '' > %s", user_config_path))
end)
end)
diff --git a/tests/lsp_spec.lua b/tests/lsp_spec.lua
index 173810e0..b3bb59ab 100644
--- a/tests/lsp_spec.lua
+++ b/tests/lsp_spec.lua
@@ -44,29 +44,6 @@ a.describe("lsp workflow", function()
end)
end)
- a.it("shoud retrieve supported filetypes correctly", function()
- local ocaml = {
- name = "ocamlls",
- filetypes = { "ocaml", "reason" },
- }
- local ocaml_fts = require("lvim.lsp.utils").get_supported_filetypes(ocaml.name)
- assert.True(vim.deep_equal(ocaml.filetypes, ocaml_fts))
-
- local tsserver = {
- name = "tsserver",
- filetypes = {
- "javascript",
- "javascriptreact",
- "javascript.jsx",
- "typescript",
- "typescriptreact",
- "typescript.tsx",
- },
- }
- local tsserver_fts = require("lvim.lsp.utils").get_supported_filetypes(tsserver.name)
- assert.True(vim.deep_equal(tsserver.filetypes, tsserver_fts))
- end)
-
a.it("shoud not include blacklisted servers in the generated templates", function()
assert.True(utils.is_directory(lvim.lsp.templates_dir))
require("lvim.lsp").setup()
@@ -77,4 +54,17 @@ a.describe("lsp workflow", function()
end
end
end)
+
+ a.it("shoud only include one server per generated template", function()
+ assert.True(utils.is_directory(lvim.lsp.templates_dir))
+ require("lvim.lsp").setup()
+
+ for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do
+ local count = 0
+ for _ in io.lines(file) do
+ count = count + 1
+ end
+ assert.equal(count, 1)
+ end
+ end)
end)
diff --git a/tests/minimal_lsp.lua b/tests/minimal_lsp.lua
index a2b9ab57..9873e5ef 100644
--- a/tests/minimal_lsp.lua
+++ b/tests/minimal_lsp.lua
@@ -1,8 +1,25 @@
+local on_windows = vim.loop.os_uname().version:match "Windows"
+
+local function join_paths(...)
+ local path_sep = on_windows and "\\" or "/"
+ local result = table.concat({ ... }, path_sep)
+ return result
+end
+
vim.cmd [[set runtimepath=$VIMRUNTIME]]
-vim.cmd [[set packpath=/tmp/nvim/site]]
-local package_root = "/tmp/nvim/site/pack"
-local install_path = package_root .. "/packer/start/packer.nvim"
+local temp_dir
+if on_windows then
+ temp_dir = vim.loop.os_getenv "TEMP"
+else
+ temp_dir = "/tmp"
+end
+
+vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))
+
+local package_root = join_paths(temp_dir, "nvim", "site", "pack")
+local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
+local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")
-- Choose whether to use the executable that's managed by lsp-installer
local use_lsp_installer = true
@@ -16,7 +33,7 @@ local function load_plugins()
},
config = {
package_root = package_root,
- compile_path = install_path .. "/plugin/packer_compiled.lua",
+ compile_path = compile_path,
},
}
end