Skip to content

Commit 73f660f

Browse files
committed
Add test and fix Exec() call
1 parent e520f55 commit 73f660f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

autoload/go/tool.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function! go#tool#ExecuteInDir(cmd) abort
170170
" that don't actually exist on the file system (e.g. vim-fugitive's
171171
" GitDiff).
172172
if !isdirectory(expand("%:p:h"))
173-
let out = go#util#Exec("false")
173+
let [out, err] = go#util#Exec(["false"])
174174
return out
175175
endif
176176

autoload/go/tool_test.vim

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
func! Test_ExecuteInDir() abort
2+
let l:tmp = gotest#write_file('a/a.go', ['package a'])
3+
try
4+
let l:out = go#tool#ExecuteInDir("pwd")
5+
call assert_equal(l:tmp . "/src/a\n", l:out)
6+
finally
7+
call delete(l:tmp, 'rf')
8+
endtry
9+
endfunc
10+
11+
func! Test_ExecuteInDir_nodir() abort
12+
let l:tmp = go#util#tempdir("executeindir")
13+
exe ':e ' . l:tmp . '/new-dir/a'
14+
15+
try
16+
let l:out = go#tool#ExecuteInDir("pwd")
17+
call assert_equal('', l:out)
18+
finally
19+
call delete(l:tmp, 'rf')
20+
endtry
21+
endfunc

0 commit comments

Comments
 (0)