From 10b9123b7d09c6c1876ed24bda4905d3e8aa221c Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 27 Aug 2023 08:44:07 +0200 Subject: [PATCH] test: run busted in sync mode (#4342) * test: run busted in sync mode * ci: update stable release version * fix(mason): use recommended steps for sources sync --- .../ISSUE_TEMPLATE/general-issue-form.yaml | 4 ++-- .github/ISSUE_TEMPLATE/lsp-issue-form.yaml | 4 ++-- .github/workflows/install.yaml | 6 +++--- lua/lvim/lsp/utils.lua | 3 +++ tests/specs/bootstrap_spec.lua | 15 +++++++------ tests/specs/config_loader_spec.lua | 11 +++++----- tests/specs/lsp_spec.lua | 21 +++++++++++-------- tests/specs/plugins_load_spec.lua | 8 +++---- 8 files changed, 37 insertions(+), 35 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/general-issue-form.yaml b/.github/ISSUE_TEMPLATE/general-issue-form.yaml index 21512837..2e5b0a4d 100644 --- a/.github/ISSUE_TEMPLATE/general-issue-form.yaml +++ b/.github/ISSUE_TEMPLATE/general-issue-form.yaml @@ -34,10 +34,10 @@ body: - type: input id: nvim-version attributes: - label: Neovim version (>= 0.9.0) + label: Neovim version (>= 0.9.1) description: "Output of `nvim --version`" placeholder: | - NVIM v0.9.0-dev-983+g6dfabd014 + NVIM v0.10.0-dev-670+g2ecba65b4 validations: required: true - type: input diff --git a/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml b/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml index 88d4a180..837fb683 100644 --- a/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml +++ b/.github/ISSUE_TEMPLATE/lsp-issue-form.yaml @@ -27,10 +27,10 @@ body: - type: input id: nvim-version attributes: - label: Neovim version (>= 0.9.0) + label: Neovim version (>= 0.9.1) description: "Output of `nvim --version`" placeholder: | - NVIM v0.9.0-dev-983+g6dfabd014 + NVIM v0.10.0-dev-670+g2ecba65b4 validations: required: true - type: input diff --git a/.github/workflows/install.yaml b/.github/workflows/install.yaml index 6dc269fa..60c8890a 100644 --- a/.github/workflows/install.yaml +++ b/.github/workflows/install.yaml @@ -21,10 +21,10 @@ jobs: include: - runner: ubuntu-latest os: linux - neovim: v0.9.0 + neovim: v0.9.1 - runner: macos-latest os: osx - neovim: v0.9.0 + neovim: v0.9.1 - runner: ubuntu-22.04 os: linux neovim: nightly @@ -78,7 +78,7 @@ jobs: uses: rhysd/action-setup-vim@v1 with: neovim: true - version: v0.9.0 + version: v0.9.1 - name: Install LunarVim timeout-minutes: 4 diff --git a/lua/lvim/lsp/utils.lua b/lua/lvim/lsp/utils.lua index 2fdf52ef..95169b34 100644 --- a/lua/lvim/lsp/utils.lua +++ b/lua/lvim/lsp/utils.lua @@ -55,7 +55,10 @@ end ---@param filter { filetype: string | string[] }?: (optional) Used to filter the list of server names. ---@return string[] list of names of supported servers function M.get_supported_servers(filter) + -- force synchronous mode, see: |mason-registry.refresh()| require("mason-registry").refresh() + require("mason-registry").get_all_packages() + local _, supported_servers = pcall(function() return require("mason-lspconfig").get_available_servers(filter) end) diff --git a/tests/specs/bootstrap_spec.lua b/tests/specs/bootstrap_spec.lua index 3479ce5d..bb529553 100644 --- a/tests/specs/bootstrap_spec.lua +++ b/tests/specs/bootstrap_spec.lua @@ -1,8 +1,7 @@ -local a = require "plenary.async_lib.tests" local uv = vim.loop local home_dir = uv.os_homedir() -a.describe("initial start", function() +describe("initial start", function() before_each(function() vim.cmd [[ let v:errmsg = "" @@ -23,31 +22,31 @@ a.describe("initial start", function() local lvim_runtime_path = get_runtime_dir() local lvim_cache_path = get_cache_dir() - a.it("should be able to detect test environment", function() + it("should be able to detect test environment", function() assert.truthy(os.getenv "LVIM_TEST_ENV") assert.falsy(package.loaded["lvim.impatient"]) end) - a.it("should be able to use lunarvim cache directory using vim.fn", function() + it("should be able to use lunarvim cache directory using vim.fn", function() assert.equal(lvim_cache_path, vim.fn.stdpath "cache") end) - a.it("should be to retrieve default neovim directories", function() + it("should be to retrieve default neovim directories", function() local xdg_config = os.getenv "XDG_CONFIG_HOME" or join_paths(home_dir, ".config") assert.equal(join_paths(xdg_config, "nvim"), vim.call("stdpath", "config")) end) - a.it("should be able to read lunarvim directories", function() + it("should be able to read lunarvim directories", function() local rtp_list = vim.opt.rtp:get() assert.truthy(vim.tbl_contains(rtp_list, lvim_runtime_path .. "/lvim")) assert.truthy(vim.tbl_contains(rtp_list, lvim_config_path)) end) - a.it("should be able to run treesitter without errors", function() + 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() + it("should be able to pass basic checkhealth without errors", function() vim.cmd "set cmdheight&" vim.cmd "silent checkhealth nvim" local errmsg = vim.fn.eval "v:errmsg" diff --git a/tests/specs/config_loader_spec.lua b/tests/specs/config_loader_spec.lua index 9ffeb4fc..565f1a5d 100644 --- a/tests/specs/config_loader_spec.lua +++ b/tests/specs/config_loader_spec.lua @@ -1,8 +1,7 @@ -local a = require "plenary.async_lib.tests" local config = require "lvim.config" local fmt = string.format -a.describe("config-loader", function() +describe("config-loader", function() local user_config_path = join_paths(get_config_dir(), "config.lua") local default_config_path = join_paths(get_lvim_base_dir(), "utils", "installer", "config.example.lua") @@ -23,15 +22,15 @@ a.describe("config-loader", function() assert.True(vim.tbl_isempty(errors)) end) - a.it("should be able to find user-config", function() + it("should be able to find user-config", function() assert.equal(user_config_path, get_config_dir() .. "/config.lua") end) - a.it("should be able to load user-config without errors", function() + it("should be able to load user-config without errors", function() config:load(user_config_path) end) - a.it("should be able to reload user-config without errors", function() + it("should be able to reload user-config without errors", function() config:load(user_config_path) local test_path = "/tmp/lvim" os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path)) @@ -41,7 +40,7 @@ a.describe("config-loader", function() end) end) - a.it("should not get interrupted by errors in user-config", function() + it("should not get interrupted by errors in user-config", function() local test_path = "/tmp/lunarvim" os.execute(string.format([[echo "vim.opt.undodir = '%s'" >> %s]], test_path, user_config_path)) config:load(user_config_path) diff --git a/tests/specs/lsp_spec.lua b/tests/specs/lsp_spec.lua index 997bbf48..35dca2c1 100644 --- a/tests/specs/lsp_spec.lua +++ b/tests/specs/lsp_spec.lua @@ -1,9 +1,8 @@ -local a = require "plenary.async_lib.tests" local utils = require "lvim.utils" local helpers = require "tests.lvim.helpers" local spy = require "luassert.spy" -a.describe("lsp workflow", function() +describe("lsp workflow", function() before_each(function() vim.cmd [[ let v:errmsg = "" @@ -25,24 +24,26 @@ a.describe("lsp workflow", function() local plugins = require "lvim.plugins" require("lvim.plugin-loader").load { plugins, lvim.plugins } - a.it("should be able to delete ftplugin templates", function() + it("should be able to delete ftplugin templates", function() if utils.is_directory(lvim.lsp.templates_dir) then assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0) end assert.False(utils.is_directory(lvim.lsp.templates_dir)) end) - a.it("should be able to generate ftplugin templates", function() + it("should be able to generate ftplugin templates", function() if utils.is_directory(lvim.lsp.templates_dir) then assert.equal(vim.fn.delete(lvim.lsp.templates_dir, "rf"), 0) end require("lvim.lsp").setup() + vim.wait(500) - assert.True(#vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1) > 0) + local template_files = vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1) + assert.False(vim.tbl_isempty(template_files)) end) - a.it("should not include blacklisted servers in the generated templates", function() + it("should not include blacklisted servers in the generated templates", function() require("lvim.lsp").setup() for _, server_name in ipairs(lvim.lsp.automatic_configuration.skipped_servers) do @@ -52,11 +53,13 @@ a.describe("lsp workflow", function() end end) - a.it("should only include one server per generated template", function() + it("should only include one server per generated template", function() require("lvim.lsp").setup() + vim.wait(500) local allowed_dupes = { "tailwindcss" } - for _, file in ipairs(vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1)) do + local template_files = vim.fn.glob(lvim.lsp.templates_dir .. "/*.lua", 1, 1) + for _, file in ipairs(template_files) do local content = {} for entry in io.lines(file) do local server_name = entry:match [[.*setup%("(.*)"%)]] @@ -76,7 +79,7 @@ a.describe("lsp workflow", function() end end) - a.it("should not attempt to re-generate ftplugin templates", function() + it("should not attempt to re-generate ftplugin templates", function() local s = spy.on(require "lvim.lsp.templates", "generate_templates") require("lvim.lsp").setup() diff --git a/tests/specs/plugins_load_spec.lua b/tests/specs/plugins_load_spec.lua index 37294c2e..94896d22 100644 --- a/tests/specs/plugins_load_spec.lua +++ b/tests/specs/plugins_load_spec.lua @@ -1,6 +1,4 @@ -local a = require "plenary.async_lib.tests" - -a.describe("plugin-loader", function() +describe("plugin-loader", function() local plugins = require "lvim.plugins" local loader = require "lvim.plugin-loader" @@ -9,7 +7,7 @@ a.describe("plugin-loader", function() package.loaded["lvim.core.log"] = nil end) - a.it("should be able to load default packages without errors", function() + it("should be able to load default packages without errors", function() vim.go.loadplugins = true loader.load { plugins, lvim.plugins } @@ -23,7 +21,7 @@ a.describe("plugin-loader", function() end end) - a.it("should be able to load lsp packages without errors", function() + it("should be able to load lsp packages without errors", function() require("lvim.lsp").setup() local lsp_packages = {