2019-06-03 14:58:18 +00:00
|
|
|
" don't spam the user when Vim is started in Vi compatibility mode
|
|
|
|
let s:cpo_save = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
|
2018-05-06 15:45:27 +00:00
|
|
|
func! Test_GoTermNewMode()
|
2020-10-28 13:35:24 +00:00
|
|
|
if !(has('nvim') || has('terminal'))
|
2018-05-06 15:45:27 +00:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
try
|
|
|
|
let l:filename = 'term/term.go'
|
|
|
|
let l:tmp = gotest#load_fixture(l:filename)
|
|
|
|
exe 'cd ' . l:tmp . '/src/term'
|
|
|
|
|
|
|
|
let expected = expand('%:p')
|
|
|
|
|
|
|
|
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
|
|
|
|
|
|
|
|
set nosplitright
|
2019-06-03 14:58:18 +00:00
|
|
|
call go#term#new(0, cmd, &errorformat)
|
2018-05-06 15:45:27 +00:00
|
|
|
let actual = expand('%:p')
|
|
|
|
call assert_equal(actual, l:expected)
|
|
|
|
|
|
|
|
finally
|
2020-10-28 13:35:24 +00:00
|
|
|
sleep 50m
|
2018-05-06 15:45:27 +00:00
|
|
|
call delete(l:tmp, 'rf')
|
|
|
|
endtry
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func! Test_GoTermNewMode_SplitRight()
|
2020-10-28 13:35:24 +00:00
|
|
|
if !(has('nvim') || has('terminal'))
|
2018-05-06 15:45:27 +00:00
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
try
|
|
|
|
let l:filename = 'term/term.go'
|
|
|
|
let l:tmp = gotest#load_fixture(l:filename)
|
|
|
|
exe 'cd ' . l:tmp . '/src/term'
|
|
|
|
|
|
|
|
let expected = expand('%:p')
|
|
|
|
|
|
|
|
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
|
|
|
|
|
|
|
|
set splitright
|
2019-06-03 14:58:18 +00:00
|
|
|
call go#term#new(0, cmd, &errorformat)
|
2018-05-06 15:45:27 +00:00
|
|
|
let actual = expand('%:p')
|
|
|
|
call assert_equal(actual, l:expected)
|
|
|
|
|
|
|
|
finally
|
2020-10-28 13:35:24 +00:00
|
|
|
sleep 50m
|
2018-05-06 15:45:27 +00:00
|
|
|
call delete(l:tmp, 'rf')
|
|
|
|
set nosplitright
|
|
|
|
endtry
|
|
|
|
endfunc
|
|
|
|
|
2020-10-28 13:35:24 +00:00
|
|
|
func! Test_GoTermReuse()
|
|
|
|
if !(has('nvim') || has('terminal'))
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
|
|
|
|
try
|
|
|
|
let l:filename = 'term/term.go'
|
|
|
|
let l:tmp = gotest#load_fixture(l:filename)
|
|
|
|
exe 'cd ' . l:tmp . '/src/term'
|
|
|
|
|
|
|
|
let expected = expand('%:p')
|
|
|
|
|
|
|
|
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
|
|
|
|
|
|
|
|
set nosplitright
|
|
|
|
|
|
|
|
let g:go_term_reuse = 1
|
|
|
|
call go#term#new(0, cmd, &errorformat)
|
|
|
|
let actual = expand('%:p')
|
|
|
|
call assert_equal(actual, l:expected)
|
|
|
|
call assert_equal(3, len(getwininfo()))
|
|
|
|
|
|
|
|
call go#term#new(0, cmd, &errorformat)
|
|
|
|
let actual = expand('%:p')
|
|
|
|
call assert_equal(actual, l:expected)
|
|
|
|
|
|
|
|
call assert_equal(3, len(getwininfo()))
|
|
|
|
finally
|
|
|
|
sleep 50m
|
|
|
|
unlet g:go_term_reuse
|
|
|
|
call delete(l:tmp, 'rf')
|
|
|
|
endtry
|
|
|
|
endfunc
|
|
|
|
|
2019-06-03 14:58:18 +00:00
|
|
|
" restore Vi compatibility settings
|
|
|
|
let &cpo = s:cpo_save
|
|
|
|
unlet s:cpo_save
|
|
|
|
|
2018-05-06 15:45:27 +00:00
|
|
|
" vim: sw=2 ts=2 et
|