@@ -11,7 +11,7 @@ func! Test_GometaGolangciLint() abort
11
11
endfunc
12
12
13
13
func ! s: gometa (metalinter) abort
14
- let $GOPATH = fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint'
14
+ let RestoreGOPATH = go#util#SetEnv ( ' GOPATH ' , fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint' )
15
15
silent exe ' e ' . $GOPATH . ' /src/lint/lint.go'
16
16
17
17
try
@@ -36,6 +36,7 @@ func! s:gometa(metalinter) abort
36
36
37
37
call gotest#assert_quickfix (actual, expected)
38
38
finally
39
+ call call (RestoreGOPATH, [])
39
40
unlet g: go_metalinter_enabled
40
41
endtry
41
42
endfunc
@@ -49,7 +50,7 @@ func! Test_GometaWithDisabledGolangciLint() abort
49
50
endfunc
50
51
51
52
func ! s: gometawithdisabled (metalinter) abort
52
- let $GOPATH = fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint'
53
+ let RestoreGOPATH = go#util#SetEnv ( ' GOPATH ' , fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint' )
53
54
silent exe ' e ' . $GOPATH . ' /src/lint/lint.go'
54
55
55
56
try
@@ -74,6 +75,7 @@ func! s:gometawithdisabled(metalinter) abort
74
75
75
76
call gotest#assert_quickfix (actual, expected)
76
77
finally
78
+ call call (RestoreGOPATH, [])
77
79
unlet g: go_metalinter_disabled
78
80
endtry
79
81
endfunc
@@ -87,7 +89,7 @@ func! Test_GometaAutoSaveGolangciLint() abort
87
89
endfunc
88
90
89
91
func ! s: gometaautosave (metalinter) abort
90
- let $GOPATH = fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint'
92
+ let RestoreGOPATH = go#util#SetEnv ( ' GOPATH ' , fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint' )
91
93
silent exe ' e ' . $GOPATH . ' /src/lint/lint.go'
92
94
93
95
try
@@ -114,12 +116,13 @@ func! s:gometaautosave(metalinter) abort
114
116
115
117
call gotest#assert_quickfix (actual, expected)
116
118
finally
119
+ call call (RestoreGOPATH, [])
117
120
unlet g: go_metalinter_autosave_enabled
118
121
endtry
119
122
endfunc
120
123
121
124
func ! Test_Vet () abort
122
- let $GOPATH = fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint'
125
+ let RestoreGOPATH = go#util#SetEnv ( ' GOPATH ' , fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint' )
123
126
silent exe ' e ' . $GOPATH . ' /src/vet/vet.go'
124
127
compiler go
125
128
@@ -142,6 +145,63 @@ func! Test_Vet() abort
142
145
let actual = getqflist ()
143
146
endwhile
144
147
148
+ call gotest#assert_quickfix (actual, expected)
149
+ call call (RestoreGOPATH, [])
150
+ endfunc
151
+
152
+ func ! Test_Lint_GOPATH () abort
153
+ let RestoreGOPATH = go#util#SetEnv (' GOPATH' , fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint' )
154
+
155
+ silent exe ' e ' . $GOPATH . ' /src/lint/lint.go'
156
+ compiler go
157
+
158
+ let expected = [
159
+ \ {' lnum' : 5 , ' bufnr' : bufnr (' %' ), ' col' : 1 , ' valid' : 1 , ' vcol' : 0 , ' nr' : -1 , ' type' : ' ' , ' pattern' : ' ' , ' text' : ' exported function MissingDoc should have comment or be unexported' },
160
+ \ {' lnum' : 5 , ' bufnr' : 6 , ' col' : 1 , ' valid' : 1 , ' vcol' : 0 , ' nr' : -1 , ' type' : ' ' , ' pattern' : ' ' , ' text' : ' exported function AlsoMissingDoc should have comment or be unexported' }
161
+ \ ]
162
+
163
+ let winnr = winnr ()
164
+
165
+ " clear the location lists
166
+ call setqflist ([], ' r' )
167
+
168
+ call go#lint#Golint (1 )
169
+
170
+ let actual = getqflist ()
171
+ let start = reltime ()
172
+ while len (actual) == 0 && reltimefloat (reltime (start )) < 10
173
+ sleep 100 m
174
+ let actual = getqflist ()
175
+ endwhile
176
+
177
+ call gotest#assert_quickfix (actual, expected)
178
+
179
+ call call (RestoreGOPATH, [])
180
+ endfunc
181
+
182
+ func ! Test_Lint_NullModule () abort
183
+ silent exe ' e ' . fnameescape (fnamemodify (getcwd (), ' :p' )) . ' test-fixtures/lint/src/lint/lint.go'
184
+ compiler go
185
+
186
+ let expected = [
187
+ \ {' lnum' : 5 , ' bufnr' : bufnr (' %' ), ' col' : 1 , ' valid' : 1 , ' vcol' : 0 , ' nr' : -1 , ' type' : ' ' , ' pattern' : ' ' , ' text' : ' exported function MissingDoc should have comment or be unexported' },
188
+ \ {' lnum' : 5 , ' bufnr' : 6 , ' col' : 1 , ' valid' : 1 , ' vcol' : 0 , ' nr' : -1 , ' type' : ' ' , ' pattern' : ' ' , ' text' : ' exported function AlsoMissingDoc should have comment or be unexported' }
189
+ \ ]
190
+
191
+ let winnr = winnr ()
192
+
193
+ " clear the location lists
194
+ call setqflist ([], ' r' )
195
+
196
+ call go#lint#Golint (1 )
197
+
198
+ let actual = getqflist ()
199
+ let start = reltime ()
200
+ while len (actual) == 0 && reltimefloat (reltime (start )) < 10
201
+ sleep 100 m
202
+ let actual = getqflist ()
203
+ endwhile
204
+
145
205
call gotest#assert_quickfix (actual, expected)
146
206
endfunc
147
207
0 commit comments