From 5c39b8fc967b1dec072d9dcd01bee4752f184044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 17 Mar 2021 20:52:05 +0800 Subject: fix tests --- test.lua | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) (limited to 'test.lua') diff --git a/test.lua b/test.lua index 5adf111f..bbc5f208 100644 --- a/test.lua +++ b/test.lua @@ -44,23 +44,23 @@ local function loadDocMetas() end end -local function main() - debug.setcstacklimit(1000) - require 'core.guide'.debugMode = true - require 'language' 'zh-cn' - require 'utility'.enableCloseFunction() - local function test(name) - local clock = os.clock() - print(('测试[%s]...'):format(name)) - require(name) - print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock)) +local function test(name) + local clock = os.clock() + print(('测试[%s]...'):format(name)) + local originRequire = require + require = function (n, ...) + local v, p = originRequire(n, ...) + if p and p:find 'test/' then + package.loaded[n] = nil + end + return v, p end + require(name) + require = originRequire + print(('测试[%s]用时[%.3f]'):format(name, os.clock() - clock)) +end - local config = require 'config' - config.config.runtime.version = 'Lua 5.4' - --config.config.intelliSense.searchDepth = 5 - loadDocMetas() - +local function testAll() test 'basic' test 'references' test 'definition' @@ -75,8 +75,28 @@ local function main() test 'code_action' test 'type_formatting' test 'crossfile' - test 'full' --test 'other' +end + +local function main() + debug.setcstacklimit(1000) + require 'core.guide'.debugMode = true + require 'language' 'zh-cn' + require 'utility'.enableCloseFunction() + + local config = require 'config' + config.config.runtime.version = 'Lua 5.4' + --config.config.intelliSense.searchDepth = 5 + loadDocMetas() + + require 'bee.platform'.OS = 'Windows' + testAll() + require 'bee.platform'.OS = 'Linux' + testAll() + require 'bee.platform'.OS = 'macOS' + testAll() + + test 'full' print('测试完成') end -- cgit v1.2.3