2020-10-20 01:28:35 +00:00
|
|
|
|
|
|
|
let tmuxTestSessionName = "test"
|
|
|
|
let defaultTmuxPaneId = g:tmuxTestSessionName . ":0.0"
|
|
|
|
|
|
|
|
function InitializeTmuxTestSession()
|
2020-10-27 21:15:29 +00:00
|
|
|
call system("tmux new -ds " . g:tmuxTestSessionName . " -c $HOME >/dev/null 2>&1")
|
2020-10-20 01:28:35 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
" ===================================================================
|
|
|
|
" === test formats ==================================================
|
|
|
|
" ===================================================================
|
|
|
|
|
|
|
|
function TmuxTest(shellCommand, paneId = g:defaultTmuxPaneId)
|
|
|
|
if a:paneId == g:defaultTmuxPaneId
|
2020-10-27 21:15:29 +00:00
|
|
|
silent call InitializeTmuxTestSession()
|
2020-10-20 01:28:35 +00:00
|
|
|
endif
|
|
|
|
|
2020-11-11 20:10:33 +00:00
|
|
|
call system("tmux send-keys -t " . a:paneId . " 'clear; " . a:shellCommand . "' Enter")
|
2020-10-20 01:28:35 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function SplitPaneTest(shellCommand, verticalSplit = 0)
|
|
|
|
if a:verticalSplit
|
|
|
|
execute "vertical terminal " . a:shellCommand
|
|
|
|
else
|
|
|
|
execute "terminal " . a:shellCommand
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function ShellEscapedTest(shellCommand)
|
|
|
|
execute "!" . a:shellCommand
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
" ===================================================================
|
|
|
|
" === python-django =================================================
|
|
|
|
" ===================================================================
|
|
|
|
|
|
|
|
function DjangoTmuxTest(paneId = g:defaultTmuxPaneId)
|
|
|
|
let l:command = "cd " . getcwd() . "; " . GetDjangoTestCommand()
|
|
|
|
call TmuxTest(l:command, a:paneId)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function DjangoSplitTest(verticalSplit = 0)
|
|
|
|
let l:command = GetDjangoTestCommand()
|
|
|
|
call SplitPaneTest(l:command, a:verticalSplit)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function DjangoTest()
|
|
|
|
let l:command = GetDjangoTestCommand()
|
|
|
|
call ShellEscapedTest(l:command)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function GetDjangoTestCommand()
|
|
|
|
return GetDjangoManagePy() . " test --keepdb"
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function GetDjangoManagePy()
|
2021-02-05 22:49:55 +00:00
|
|
|
return substitute(expand(getcwd()), "/code.*", "/code/manage.py", "")
|
2020-10-20 01:28:35 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
2021-04-09 21:25:32 +00:00
|
|
|
" ===================================================================
|
|
|
|
" === dotnet core ===================================================
|
|
|
|
" ===================================================================
|
|
|
|
|
|
|
|
function DotnetTest(filter = '')
|
|
|
|
let l:command =
|
|
|
|
\ 'cd ' . GetDotnetProjectLocation()
|
|
|
|
\ . ';' . 'dotnet build -clp:ErrorsOnly'
|
|
|
|
\ . ';' . 'cd ' . GetDotnetProjectLocation(1)
|
|
|
|
\ . ';' . 'dotnet test -clp:ErrorsOnly'
|
|
|
|
if a:filter != ''
|
|
|
|
let l:command = l:command . ' --filter ' . a:filter
|
|
|
|
endif
|
|
|
|
call TmuxTest(l:command)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function GetDotnetProjectLocation(test = 0)
|
|
|
|
let l:projectRoot = substitute(expand(getcwd()), '/code.*', '/code', '')
|
|
|
|
if a:test
|
|
|
|
let l:testPath = system('ls ' . l:projectRoot . '/**/*.csproj | grep Test | head -1')
|
|
|
|
else
|
|
|
|
let l:testPath = system('ls ' . l:projectRoot . '/**/*.csproj | grep -v Test | head -1')
|
|
|
|
endif
|
|
|
|
return substitute(l:testPath, '\(.*\)/.*.csproj.*', '\1', '')
|
|
|
|
endfunction
|
|
|
|
|
2020-10-20 01:28:35 +00:00
|
|
|
" ===================================================================
|
|
|
|
" === npm ===========================================================
|
|
|
|
" ===================================================================
|
|
|
|
|
|
|
|
function NpmTmuxTest(paneId = g:defaultTmuxPaneId)
|
|
|
|
let l:command = "cd " . getcwd() . "; " . GetNpmTestCommand()
|
|
|
|
call TmuxTest(l:command, a:paneId)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function NpmSplitTest(verticalSplit = 0)
|
|
|
|
let l:command = GetNpmTestCommand()
|
|
|
|
call SplitPaneTest(l:command, a:verticalSplit)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function NpmTest()
|
|
|
|
let l:command = GetNpmTestCommand()
|
|
|
|
call ShellEscapedTest(l:command)
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
|
|
function GetNpmTestCommand()
|
|
|
|
return "npm test"
|
|
|
|
endfunction
|