diff --git a/.gitignore b/.gitignore index e34753ce9..17c8429d9 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,4 @@ doc/ test/vagrant-spec/boxes/*.box simple_speed.py +cover.out diff --git a/internal/runner/runner_test.go b/internal/runner/runner_test.go index 77311d571..3632578a7 100644 --- a/internal/runner/runner_test.go +++ b/internal/runner/runner_test.go @@ -18,7 +18,8 @@ func TestRunnerStart(t *testing.T) { require := require.New(t) ctx := context.Background() client := singleprocess.TestServer(t) - rubyRunTime, err := TestRunnerVagrantRubyRuntime() + rubyRunTime, err := TestRunnerVagrantRubyRuntime(t) + defer rubyRunTime.Close() // Initialize our runner runner, err := New( diff --git a/internal/runner/testing.go b/internal/runner/testing.go index e0b6b3d6b..b3600ae67 100644 --- a/internal/runner/testing.go +++ b/internal/runner/testing.go @@ -31,7 +31,7 @@ import ( func TestRunner(t testing.T, opts ...Option) *Runner { require := require.New(t) client := singleprocess.TestServer(t) - rubyRunTime, err := TestRunnerVagrantRubyRuntime() + rubyRunTime, err := TestRunnerVagrantRubyRuntime(t) // Initialize our runner runner, err := New(append([]Option{ @@ -51,7 +51,7 @@ func TestRunner(t testing.T, opts ...Option) *Runner { return runner } -func TestRunnerVagrantRubyRuntime() (rubyRuntime plugin.ClientProtocol, err error) { +func TestRunnerVagrantRubyRuntime(t testing.T) (rubyRuntime plugin.ClientProtocol, err error) { // TODO: Update for actual release usage. This is dev only now. // TODO: We should also locate a free port on startup and use that port _, this_dir, _, _ := runtime.Caller(0) @@ -71,13 +71,8 @@ func TestRunnerVagrantRubyRuntime() (rubyRuntime plugin.ClientProtocol, err erro if _, err = c.Start(); err != nil { return } - if rubyRuntime, err = c.Client(); err != nil { - return - } - - // Ensure the plugin is halted when the basis is cleaned up - // b.cleanup(func() { rubyRuntime.Close() }) - + rubyRuntime, err = c.Client() + t.Cleanup(func() { c.Kill() }) return } @@ -117,5 +112,6 @@ func TestBasis(t testing.T, opts ...core.BasisOption) (b *vagrant_plugin_sdk.Ref basis, err := core.NewBasis(context.Background(), append(opts, defaultOpts...)...) require.NoError(t, err) b = basis.Ref().(*vagrant_plugin_sdk.Ref_Basis) + t.Cleanup(func() { basis.Close() }) return }