nvim: integrate testr for tests

This commit is contained in:
dogeystamp 2023-11-04 15:34:07 -04:00
parent 7f90afaabc
commit 07c958323f
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
3 changed files with 21 additions and 0 deletions

View File

@ -2,3 +2,4 @@ animdl
td-watson
cppman
git+https://github.com/idanpa/calcpy
git+https://github.com/dogeystamp/testr

View File

@ -91,3 +91,6 @@ function prob_cpp; echo $EDITOR src/(basename (xsel -b)).cpp; end
abbr -a cpp --function prob_cpp
function prob_py; echo $EDITOR src/(basename (xsel -b)).py; end
abbr -a py --function prob_py
# see src/.config/nvim/vimspector.vim and search for TestRunner()
function prob_testdir; echo \~/.cache/termdebug/tests/src/(basename (xsel -b)); end
abbr -a --position anywhere tesd --function prob_testdir

View File

@ -49,6 +49,23 @@ function RunInput()
endfunction
nnoremap <silent> <leader>ri :call RunInput()<cr>
" use test runner
function TestRunner()
if expand("%:e") == "cpp"
let binary=$HOME .. "/.cache/termdebug/bin/" .. expand("%:r")
else
let binary=expand("%:p")
endif
let testfolder=$HOME .. "/.cache/termdebug/tests/" .. expand("%:r")
silent exec "!mkdir -p " .. testfolder
vsp
vertical resize 40
normal G
exec 'terminal ' .. 'testr --exec ' .. binary .. " --testdir " .. testfolder
exec "norm \<c-w>h"
endfunction
nnoremap <silent> <leader>dt :call TestRunner()<cr>
" debugging program flow
nnoremap <silent> <leader>rs :call vimspector#Restart()<cr>
nnoremap <silent> <leader>rr :call vimspector#Stop()<cr>