Clean up test instances

This commit is contained in:
sophia 2021-07-21 12:45:07 -05:00 committed by Paul Hinze
parent b0c129e461
commit b223ea2b6c
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
3 changed files with 8 additions and 10 deletions

1
.gitignore vendored
View File

@ -57,3 +57,4 @@ doc/
test/vagrant-spec/boxes/*.box
simple_speed.py
cover.out

View File

@ -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(

View File

@ -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
}