diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-08-16 10:10:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-16 10:10:10 +0200 |
commit | 812ed5372462cb1bd892acb8d17922b1fa3d7e7b (patch) | |
tree | 8e16d3f66a43a4e0854d11d544e58a64b83e68a7 | |
parent | 1852dfdf9aede9f3f8bc670e39c5830c644a9bbc (diff) | |
parent | 85edb33fd181d90ec8187c876372b92e2feb1b69 (diff) | |
download | rneovim-812ed5372462cb1bd892acb8d17922b1fa3d7e7b.tar.gz rneovim-812ed5372462cb1bd892acb8d17922b1fa3d7e7b.tar.bz2 rneovim-812ed5372462cb1bd892acb8d17922b1fa3d7e7b.zip |
Merge #10783 from erw7/debug-job-spec
fix #10762 flaky 'jobstop() kills entire process tree #6530'
-rw-r--r-- | test/functional/core/job_spec.lua | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua index a1d9f50720..2531b45521 100644 --- a/test/functional/core/job_spec.lua +++ b/test/functional/core/job_spec.lua @@ -768,16 +768,79 @@ describe('jobs', function() -- ..c.."', '-c', '"..c.."'])") -- Create child with several descendants. + if iswin() then + source([[ + function! s:formatprocs(pid, prefix) + let result = '' + let result .= a:prefix . printf("%-24.24s%6s %12.12s %s\n", + \ s:procs[a:pid]['name'], + \ a:pid, + \ s:procs[a:pid]['Session Name'], + \ s:procs[a:pid]['Session']) + if has_key(s:procs[a:pid], 'children') + for pid in s:procs[a:pid]['children'] + let result .= s:formatprocs(pid, a:prefix . ' ') + endfor + endif + return result + endfunction + + function! PsTree() abort + let s:procs = {} + for proc in map( + \ map( + \ systemlist('tasklist /NH'), + \ 'substitute(v:val, "\r", "", "")'), + \ 'split(v:val, "\\s\\+")') + if len(proc) == 6 + let s:procs[proc[1]] ..']]'..[[= {'name': proc[0], + \ 'Session Name': proc[2], + \ 'Session': proc[3]} + endif + endfor + for pid in keys(s:procs) + let children = nvim_get_proc_children(str2nr(pid)) + if !empty(children) + let s:procs[pid]['children'] = children + for cpid in children + let s:procs[printf('%d', cpid)]['parent'] = str2nr(pid) + endfor + endif + endfor + let result = '' + for pid in sort(keys(s:procs), {i1, i2 -> i1 - i2}) + if !has_key(s:procs[pid], 'parent') + let result .= s:formatprocs(pid, '') + endif + endfor + return result + endfunction + ]]) + end local sleep_cmd = (iswin() and 'ping -n 31 127.0.0.1' or 'sleep 30') local j = eval("jobstart('"..sleep_cmd..' | '..sleep_cmd..' | '..sleep_cmd.."')") local ppid = funcs.jobpid(j) local children - retry(nil, nil, function() - children = meths.get_proc_children(ppid) - eq((iswin() and 4 or 3), #children) - end) + if iswin() then + local status, result = pcall(retry, nil, nil, function() + children = meths.get_proc_children(ppid) + -- On Windows conhost.exe may exist, and + -- e.g. vctip.exe might appear. #10783 + ok(#children >= 3 and #children <= 5) + end) + if not status then + print('') + print(eval('PsTree()')) + error(result) + end + else + retry(nil, nil, function() + children = meths.get_proc_children(ppid) + eq(3, #children) + end) + end -- Assert that nvim_get_proc() sees the children. for _, child_pid in ipairs(children) do local info = meths.get_proc(child_pid) |