diff options
author | ZyX <kp-pav@yandex.ru> | 2017-04-01 13:16:25 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-04-01 13:16:25 +0300 |
commit | 708a55ee1584c22caadd6b17de8cfc1760b2dba3 (patch) | |
tree | 41e21726d747a37d8ae893e4f762b732150fb75a /test/unit/helpers.lua | |
parent | 9dd0d4f8b9217f711fff32e9f47674e556a8fab0 (diff) | |
download | rneovim-708a55ee1584c22caadd6b17de8cfc1760b2dba3.tar.gz rneovim-708a55ee1584c22caadd6b17de8cfc1760b2dba3.tar.bz2 rneovim-708a55ee1584c22caadd6b17de8cfc1760b2dba3.zip |
unittests: Disable non-C-calls
Some benchmarks:
TRACE_EVERYTHING: 79.45s user 12.68s system 124% cpu 1:13.94 total
(default): 30.26s user 5.30s system 89% cpu 39.663 total
Diffstat (limited to 'test/unit/helpers.lua')
-rw-r--r-- | test/unit/helpers.lua | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua index 048027692a..7ef2fa22fc 100644 --- a/test/unit/helpers.lua +++ b/test/unit/helpers.lua @@ -542,19 +542,27 @@ local function child_sethook(wr) if os.getenv('NVIM_TEST_NO_TRACE') == '1' then return end + local trace_only_c = (os.getenv('NVIM_TEST_TRACE_EVERYTHING') ~= '1') local function hook(reason, lnum) - local msgchar = reason:sub(1, 1) - if reason == 'count' then - msgchar = 'C' - end local info = nil if reason ~= 'tail return' then -- tail return info = debug.getinfo(2, 'nSl') end + + if trace_only_c and (not info or info.what ~= 'C') then + return + end + local whatchar = ' ' local namewhatchar = ' ' local funcname = '' local source = '' + local msgchar = reason:sub(1, 1) + + if reason == 'count' then + msgchar = 'C' + end + if info then funcname = (info.name or ''):sub(1, hook_fnamelen) whatchar = info.what:sub(1, 1) @@ -595,9 +603,11 @@ local function child_sethook(wr) -- eq(hook_msglen, #msg) sc.write(wr, msg) end - debug.sethook(hook, 'crl') + debug.sethook(hook, trace_only_c and 'cr' or 'crl') end +local trace_end_msg = ('E%s\n'):format((' '):rep(hook_msglen - 2)) + local function itp_child(wr, func) init() collectgarbage('stop') @@ -606,7 +616,7 @@ local function itp_child(wr, func) debug.sethook() collectgarbage('restart') emsg = tostring(emsg) - sc.write(wr, ('E%s\n'):format((' '):rep(hook_msglen - 2))) + sc.write(wr, trace_end_msg) if not err then if #emsg > 99999 then emsg = emsg:sub(1, 99999) @@ -634,7 +644,7 @@ local function check_child_err(rd) trace[#trace + 1] = 'Partial read: <' .. trace .. '>\n' end end - if traceline:sub(1, 1) == 'E' then + if traceline == trace_end_msg then break end trace[#trace + 1] = traceline |