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_ExecuteInDir() abort
|
|
|
|
let l:tmp = gotest#write_file('a/a.go', ['package a'])
|
|
|
|
try
|
2019-06-03 14:58:18 +00:00
|
|
|
let l:out = go#util#ExecInDir(['pwd'])
|
|
|
|
call assert_equal([l:tmp . "/src/a\n", 0], l:out)
|
2018-05-06 15:45:27 +00:00
|
|
|
finally
|
|
|
|
call delete(l:tmp, 'rf')
|
|
|
|
endtry
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func! Test_ExecuteInDir_nodir() abort
|
|
|
|
let l:tmp = go#util#tempdir("executeindir")
|
|
|
|
exe ':e ' . l:tmp . '/new-dir/a'
|
|
|
|
|
|
|
|
try
|
2019-06-03 14:58:18 +00:00
|
|
|
let l:out = go#util#ExecInDir(['pwd'])
|
|
|
|
call assert_equal(['', 1], l:out)
|
2018-05-06 15:45:27 +00:00
|
|
|
finally
|
|
|
|
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
|