Skip to content

Commit d58e669

Browse files
committed
Update state and repaint multiple NUnit sources
1 parent b275903 commit d58e669

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

autoload/OmniSharp/actions/test.vim

+29-14
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ function! s:debug.prepare(testName, bufferTests) abort
2626
let bufnr = a:bufferTests[0].bufnr
2727
let tests = a:bufferTests[0].tests
2828
let currentTest = s:utils.findTest(tests, a:testName)
29-
if type(currentTest) != type({})
29+
if type(currentTest) != type([]) || len(currentTest) == 0
3030
return s:utils.log.warn('No test found')
3131
endif
32+
let currentTest = currentTest[0]
3233
let project = OmniSharp#GetHost(bufnr).project
3334
let targetFramework = project.MsBuildProject.TargetFramework
3435
let opts = {
@@ -120,18 +121,21 @@ function! s:run.single.test(testName, bufferTests) abort
120121
let bufnr = a:bufferTests[0].bufnr
121122
let tests = a:bufferTests[0].tests
122123
let currentTest = s:utils.findTest(tests, a:testName)
123-
if type(currentTest) != type({})
124+
if type(currentTest) != type([]) || len(currentTest) == 0
124125
return s:utils.log.warn('No test found')
125126
endif
126127
let s:run.running = 1
127-
call OmniSharp#testrunner#StateRunning(bufnr, currentTest.name)
128+
for ct in currentTest
129+
call OmniSharp#testrunner#StateRunning(bufnr, ct.name)
130+
endfor
131+
let currentTest = currentTest[0]
128132
let project = OmniSharp#GetHost(bufnr).project
129133
let targetFramework = project.MsBuildProject.TargetFramework
130134
let opts = {
131135
\ 'ResponseHandler': funcref('s:run.process', [s:run.single.complete, bufnr, tests]),
132136
\ 'BufNum': bufnr,
133137
\ 'Parameters': {
134-
\ 'MethodName': currentTest.name,
138+
\ 'MethodName': substitute(currentTest.name, '(.*)$', '', ''),
135139
\ 'NoBuild': get(s:, 'nobuild', 0),
136140
\ 'TestFrameworkName': currentTest.framework,
137141
\ 'TargetFrameworkVersion': targetFramework
@@ -143,6 +147,13 @@ function! s:run.single.test(testName, bufferTests) abort
143147
endfunction
144148

145149
function! s:run.single.complete(summary) abort
150+
if len(a:summary.locations) > 1
151+
" A single test was run, but multiple test results were returned. This can
152+
" happen when using e.g. NUnit TestCaseSources which re-run the test using
153+
" different arguments.
154+
call s:run.multiple.complete([a:summary])
155+
return
156+
endif
146157
if a:summary.pass && len(a:summary.locations) == 0
147158
echomsg 'No tests were run'
148159
" Do we ever reach here?
@@ -357,9 +368,9 @@ function! s:run.process(Callback, bufnr, tests, response) abort
357368
if !has_key(location, 'lnum')
358369
" Success, or unexpected test failure.
359370
let test = s:utils.findTest(a:tests, result.MethodName)
360-
if type(test) == type({})
361-
let location.lnum = test.nameRange.Start.Line
362-
let location.col = test.nameRange.Start.Column
371+
if type(test) == type([]) && len(test) > 0
372+
let location.lnum = test[0].nameRange.Start.Line
373+
let location.col = test[0].nameRange.Start.Column
363374
let location.vcol = 0
364375
endif
365376
endif
@@ -433,17 +444,21 @@ endfunction
433444

434445
" Find the test in a list of tests that matches the current cursor position
435446
function! s:utils.findTest(tests, testName) abort
436-
for test in a:tests
437-
if a:testName !=# ''
447+
if a:testName !=# ''
448+
for test in a:tests
438449
if test.name ==# a:testName
439-
return test
450+
return [test]
440451
endif
441-
else
452+
endfor
453+
else
454+
let found = []
455+
for test in a:tests
442456
if line('.') >= test.range.Start.Line && line('.') <= test.range.End.Line
443-
return test
457+
call add(found, test)
444458
endif
445-
endif
446-
endfor
459+
endfor
460+
return found
461+
endif
447462
return 0
448463
endfunction
449464

0 commit comments

Comments
 (0)