Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Test runner #789

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
4364a0b
Refactor test-running code for readability
nickspoons May 26, 2022
fa4a6c8
Namespace test functions in function dictionaries
nickspoons May 27, 2022
d768ddf
Refactor test extraction into initialisation
nickspoons May 29, 2022
42c9426
Add new test runner buffer
nickspoons Jun 2, 2022
b4bab8c
Add initial omnisharptest syntax file
nickspoons Jun 3, 2022
f1f0db9
Add testrunner Repaint function for updating state
nickspoons Jun 3, 2022
9acd572
Update test state when starting/completing a test
nickspoons Jun 4, 2022
0fba289
Add spinner for running tests
nickspoons Jun 5, 2022
3b2d256
Add option to disable quickfix for test results
nickspoons Jun 5, 2022
109d923
Update testrunner state when debugging test
nickspoons Jun 5, 2022
1b60e7f
Display Console output and fold syntax regions
nickspoons Jun 10, 2022
d5e247a
Display failure message and exception stack trace
nickspoons Jun 11, 2022
939147b
Add default utf-8 running spinner
nickspoons Jun 11, 2022
c4b0840
Clean up output and conceal namespaces
nickspoons Jun 12, 2022
2e3411a
Extend testrunner quick-help banner
nickspoons Jun 13, 2022
a831962
Add <F1> mapping and variable to toggle banner
nickspoons Jun 13, 2022
063b3b9
Handle server-side errors and failed builds
nickspoons Jun 14, 2022
f682f1e
Display diagnostic test output (build status)
nickspoons Jun 14, 2022
a3771d0
Add option for when to display build output
nickspoons Jun 15, 2022
ebbd022
Improve highlighting of concealed elements
nickspoons Jun 16, 2022
09e3f91
Navigate to test locations
nickspoons Jun 16, 2022
05a2fb5
Add <Plug> and default testrunner mappings
nickspoons Jun 16, 2022
2793374
Add space between projects to fix fold levels
nickspoons Jun 20, 2022
ca1da95
Run test/tests in file/tests in project
nickspoons Jun 23, 2022
7aafe93
Add F9 mapping to set breakpoints on stacktrace
nickspoons Jun 25, 2022
6450ab8
Add single break-point when error is under cursor
nickspoons Jun 25, 2022
4642e11
Debug test from test runner
nickspoons Jun 26, 2022
0f34524
Add mapping to remove test/file/proj from runner
nickspoons Jun 27, 2022
4d38a67
Refactor test dict from job.tests to s:tests
nickspoons Jun 29, 2022
7d3b690
Add foldtext for testrunner folds
nickspoons Jul 3, 2022
fe9bff8
Toggle banner without repainting buffer
nickspoons Jul 14, 2022
4719213
Update test without repainting buffer
nickspoons Jul 15, 2022
37967f6
Only repaint when initializing new tests
nickspoons Jul 15, 2022
7f561c7
Add success/failure glyph beside completed tests
nickspoons Jul 16, 2022
d95a041
Set g:OmniSharp_runtests_echo_output default to 0
nickspoons Jul 19, 2022
00f7b41
Namespace test functions in function dictionaries
nickspoons Jul 19, 2022
7a6b45a
Document g:OmniSharp_runtests_quickfix
nickspoons Jul 19, 2022
8cd8375
Add option not to automatically open testrunner
nickspoons Jul 19, 2022
e8221e3
Repaint project output/errors on UpdateState
nickspoons Jul 20, 2022
44c338e
Center banner title
nickspoons Jul 28, 2022
7df4b20
Repaint correctly after hiding (removing) project
nickspoons Jul 28, 2022
27dd928
Allow selection of running test
nickspoons Aug 13, 2022
a012145
Document the omnisharp-testrunner feature
nickspoons Aug 29, 2022
fc53ee2
Strip method signature from NUnit test name
nickspoons Sep 21, 2022
76d05a9
Add test Discover function
nickspoons Oct 4, 2022
9446021
"Discover" tests before calling test runners
nickspoons Oct 4, 2022
969c34a
Update state and repaint multiple NUnit sources
nickspoons Oct 4, 2022
034dea5
Correctly run multiple NUnit tests (RunInFile)
nickspoons Oct 29, 2022
4d2b315
Exclude quickfix stack locations from runner
nickspoons Feb 27, 2023
ce1c0f4
Allow opening test runner while test is running
nickspoons Feb 27, 2023
e97eab6
Add :OmniSharpTestRunnerReset command
nickspoons Apr 24, 2023
57f602a
Refactor documentation
nickspoons Apr 24, 2023
d5a1415
Wrap popups at word boundaries by default
nickspoons Apr 24, 2023
66a2d62
Fix incorrect help tag
nickspoons Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add mapping to remove test/file/proj from runner
nickspoons committed Oct 18, 2024
commit 0f34524a8e1864425dc4fc6c3454dbc070784f66
52 changes: 50 additions & 2 deletions autoload/OmniSharp/testrunner.vim
Original file line number Diff line number Diff line change
@@ -41,7 +41,9 @@ function! OmniSharp#testrunner#Run() abort
for sln_or_dir in OmniSharp#proc#ListRunningJobs()
let job = OmniSharp#proc#GetJob(sln_or_dir)
if has_key(job, 'tests') && has_key(job.tests, projectname)
call OmniSharp#actions#test#RunInFile(1, keys(job.tests[projectname]))
let filenames = filter(keys(job.tests[projectname]),
\ {_,f -> !get(job.tests[projectname][f], '__OmniSharp__removed')})
call OmniSharp#actions#test#RunInFile(1, filenames)
endif
endfor
elseif line =~# '^ \f'
@@ -58,6 +60,39 @@ function! OmniSharp#testrunner#Run() abort
endfunction


function! OmniSharp#testrunner#Remove() abort
let filename = ''
let line = getline('.')
if line =~# '^\a'
" Project selected - run all tests
let projectname = getline('.')
for sln_or_dir in OmniSharp#proc#ListRunningJobs()
let job = OmniSharp#proc#GetJob(sln_or_dir)
if has_key(job, 'tests') && has_key(job.tests, projectname)
let job.tests[projectname].__OmniSharp__removed = 1
break
endif
endfor
elseif line =~# '^ \f'
" File selected
let filename = fnamemodify(trim(line), ':p')
let projectline = search('^\a', 'bcnWz')
let projectname = matchlist(getline(projectline), '^\S\+')[0]
for sln_or_dir in OmniSharp#proc#ListRunningJobs()
let job = OmniSharp#proc#GetJob(sln_or_dir)
if has_key(job, 'tests') && has_key(job.tests, projectname)
let job.tests[projectname][filename].__OmniSharp__removed = 1
break
endif
endfor
else
let test = s:utils.findTest()
let test.__OmniSharp__removed = 1
endif
call s:Paint()
endfunction


function! OmniSharp#testrunner#Navigate() abort
if &filetype !=# 'omnisharptest' | return | endif
let bufnr = -1
@@ -185,6 +220,7 @@ function! s:Paint() abort
let job = OmniSharp#proc#GetJob(sln_or_dir)
if !has_key(job, 'tests') | continue | endif
for testproject in sort(keys(job.tests))
if get(job.tests[testproject], '__OmniSharp__removed') | continue | endif
let errors = get(get(job, 'testerrors', {}), testproject, [])
call add(lines, testproject . (len(errors) ? ' - ERROR' : ''))
for errorline in errors
@@ -204,10 +240,12 @@ function! s:Paint() abort
endif
endif
for testfile in sort(keys(job.tests[testproject]))
call add(lines, ' ' . fnamemodify(testfile, ':.'))
let tests = job.tests[testproject][testfile]
if get(tests, '__OmniSharp__removed') | continue | endif
call add(lines, ' ' . fnamemodify(testfile, ':.'))
for name in sort(keys(tests), {a,b -> tests[a].lnum > tests[b].lnum})
let test = tests[name]
if get(test, '__OmniSharp__removed') | continue | endif
let state = s:utils.state2char[test.state]
call add(lines, printf('%s %s', state, name))
if state ==# '-' && !has_key(test, 'spintimer')
@@ -284,15 +322,25 @@ function! OmniSharp#testrunner#SetTests(bufferTests) abort
let job.tests = get(job, 'tests', {})
let projectname = s:utils.getProjectName(buffer.bufnr)
let testproject = get(job.tests, projectname, {})
if has_key(testproject, '__OmniSharp__removed')
unlet testproject.__OmniSharp__removed
endif
let job.tests[projectname] = testproject
let filename = fnamemodify(bufname(buffer.bufnr), ':p')
let filetests = get(testproject, filename, {})
if has_key(testproject, '__OmniSharp__removed')
unlet testproject.__OmniSharp__removed
endif
let testproject[filename] = filetests
for buffertest in buffer.tests
let test = get(filetests, buffertest.name, { 'state': 'Not run' })
if has_key(test, '__OmniSharp__removed')
unlet test.__OmniSharp__removed
endif
let filetests[buffertest.name] = test
let test.name = buffertest.name
let test.filename = filename
let test.projectname = projectname
let test.framework = buffertest.framework
let test.lnum = buffertest.nameRange.Start.Line
endfor
2 changes: 2 additions & 0 deletions ftplugin/omnisharptest/OmniSharp.vim
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ nnoremap <buffer> <Plug>(omnisharp_testrunner_run) :call OmniSharp#testrunner#Ru
nnoremap <buffer> <Plug>(omnisharp_testrunner_debug) :call OmniSharp#testrunner#Debug()<CR>
nnoremap <buffer> <Plug>(omnisharp_testrunner_set_breakpoints) :call OmniSharp#testrunner#SetBreakpoints()<CR>
nnoremap <buffer> <Plug>(omnisharp_testrunner_navigate) :call OmniSharp#testrunner#Navigate()<CR>
nnoremap <buffer> <Plug>(omnisharp_testrunner_remove) :call OmniSharp#testrunner#Remove()<CR>
function! s:map(mode, lhs, plug) abort
let l:rhs = '<Plug>(' . a:plug . ')'
@@ -24,3 +25,4 @@ call s:map('n', '<F5>', 'omnisharp_testrunner_run')
call s:map('n', '<F6>', 'omnisharp_testrunner_debug')
call s:map('n', '<F9>', 'omnisharp_testrunner_set_breakpoints')
call s:map('n', '<CR>', 'omnisharp_testrunner_navigate')
call s:map('n', 'dd', 'omnisharp_testrunner_remove')