From 212d17a039da449043b67529c29851db37acc236 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sat, 26 Mar 2022 13:41:50 +0100 Subject: add async managers (#536) --- tests/luassertx/lua/luassertx.lua | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 tests/luassertx/lua/luassertx.lua (limited to 'tests/luassertx/lua/luassertx.lua') diff --git a/tests/luassertx/lua/luassertx.lua b/tests/luassertx/lua/luassertx.lua deleted file mode 100644 index 0722a6d7..00000000 --- a/tests/luassertx/lua/luassertx.lua +++ /dev/null @@ -1,38 +0,0 @@ -local a = require "nvim-lsp-installer.core.async" -local assert = require "luassert" - -local util = require "luassert.util" - -function async_test(suspend_fn) - return function() - local ok, err = pcall(a.run_blocking, suspend_fn) - if not ok then - error(err, util.errorlevel()) - end - end -end - -local function wait_for(_, arguments) - ---@type fun() @Function to execute until it does not error. - local assertions_fn = arguments[1] - ---@type number @Timeout in milliseconds. Defaults to 5000. - local timeout = arguments[2] - timeout = timeout or 15000 - - local start = vim.loop.hrtime() - local is_ok, err - repeat - is_ok, err = pcall(assertions_fn) - if not is_ok then - a.sleep(math.min(timeout, 100)) - end - until is_ok or ((vim.loop.hrtime() - start) / 1e6) > timeout - - if not is_ok then - error(err) - end - - return is_ok -end - -assert:register("assertion", "wait_for", wait_for) -- cgit v1.2.3-70-g09d2