@@ -13,7 +13,8 @@ import (
13
13
"time"
14
14
)
15
15
16
- func newChildProcess (tb testing.TB ) (v * Nvim , cleanup func ()) {
16
+ // newChildProcess returns the new *Nvim, and registers cleanup to tb.Cleanup.
17
+ func newChildProcess (tb testing.TB ) (v * Nvim ) {
17
18
tb .Helper ()
18
19
19
20
envs := os .Environ ()
@@ -41,7 +42,7 @@ func newChildProcess(tb testing.TB) (v *Nvim, cleanup func()) {
41
42
done <- v .Serve ()
42
43
}()
43
44
44
- cleanup = func () {
45
+ tb . Cleanup ( func () {
45
46
if err := v .Close (); err != nil {
46
47
tb .Fatal (err )
47
48
}
@@ -75,13 +76,13 @@ func newChildProcess(tb testing.TB) (v *Nvim, cleanup func()) {
75
76
}); walkErr != nil && ! os .IsNotExist (err ) {
76
77
tb .Fatal (fmt .Errorf ("walkErr: %w" , errors .Unwrap (walkErr )))
77
78
}
78
- }
79
+ })
79
80
80
81
if err := v .Command ("set packpath=" ); err != nil {
81
82
tb .Fatal (err )
82
83
}
83
84
84
- return v , cleanup
85
+ return v
85
86
}
86
87
87
88
func TestDial (t * testing.T ) {
@@ -91,9 +92,7 @@ func TestDial(t *testing.T) {
91
92
92
93
t .Parallel ()
93
94
94
- v1 , cleanup := newChildProcess (t )
95
- defer cleanup ()
96
-
95
+ v1 := newChildProcess (t )
97
96
var addr string
98
97
if err := v1 .Eval ("$NVIM_LISTEN_ADDRESS" , & addr ); err != nil {
99
98
t .Fatal (err )
@@ -168,8 +167,7 @@ func TestEmbedded(t *testing.T) {
168
167
func TestCallWithNoArgs (t * testing.T ) {
169
168
t .Parallel ()
170
169
171
- v , cleanup := newChildProcess (t )
172
- defer cleanup ()
170
+ v := newChildProcess (t )
173
171
174
172
var wd string
175
173
err := v .Call ("getcwd" , & wd )
@@ -181,8 +179,7 @@ func TestCallWithNoArgs(t *testing.T) {
181
179
func TestStructValue (t * testing.T ) {
182
180
t .Parallel ()
183
181
184
- v , cleanup := newChildProcess (t )
185
- defer cleanup ()
182
+ v := newChildProcess (t )
186
183
187
184
t .Run ("Nvim" , func (t * testing.T ) {
188
185
var expected , actual struct {
0 commit comments