From 07c958323f64fd10e48f4414387ac32dc8e98c0a Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 4 Nov 2023 15:34:07 -0400 Subject: [PATCH] nvim: integrate testr for tests --- programs-python | 1 + src/.config/fish/aliases.fish | 3 +++ src/.config/nvim/vimspector.vim | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/programs-python b/programs-python index bacbd19..27fed34 100644 --- a/programs-python +++ b/programs-python @@ -2,3 +2,4 @@ animdl td-watson cppman git+https://github.com/idanpa/calcpy +git+https://github.com/dogeystamp/testr diff --git a/src/.config/fish/aliases.fish b/src/.config/fish/aliases.fish index e301037..829217e 100644 --- a/src/.config/fish/aliases.fish +++ b/src/.config/fish/aliases.fish @@ -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 diff --git a/src/.config/nvim/vimspector.vim b/src/.config/nvim/vimspector.vim index fc133a4..468f639 100644 --- a/src/.config/nvim/vimspector.vim +++ b/src/.config/nvim/vimspector.vim @@ -49,6 +49,23 @@ function RunInput() endfunction nnoremap ri :call RunInput() +" 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 \h" +endfunction +nnoremap dt :call TestRunner() + " debugging program flow nnoremap rs :call vimspector#Restart() nnoremap rr :call vimspector#Stop()