all repos

olexsmir.xyz @ main

my site, yes, i like lua

olexsmir.xyz/lua/tests/testutils.lua(view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---@class testutils
local testutils = {}

local minit_path = vim.fn.expand "%:p:h" .. "minit.lua"

---@param mod string Module name for which to create a nested test set.
---@return MiniTest.child child
---@return table T
---@return table mod_name
function testutils.setup(mod)
  local child = MiniTest.new_child_neovim()
  local T = MiniTest.new_set {
    hooks = {
      post_once = child.stop,
      pre_case = function()
        child.restart { "-u", minit_path }
      end,
    },
  }

  T[mod] = MiniTest.new_set {}
  return child, T, T[mod]
end

---@generic T
---@param a T
---@param b T
function testutils.eq(a, b)
  return MiniTest.expect.equality(a, b)
end

---@param msg? string
function testutils.skip(msg)
  MiniTest.skip(msg)
end

return testutils