From d81e632157c36cb2df001f60597b670b0b7ea53f Mon Sep 17 00:00:00 2001 From: Danielle Tomlinson Date: Wed, 9 Jan 2019 20:26:54 +0000 Subject: [PATCH] testutil: Start vault in the same routine as waiting This is a workaround for the windows process model. Go os/exec does not pass the parent process handle to the child processes STARTUPINFO struct, this means that unless we wait in the _same_ execution context as Starting the process, the handle will be lost, and we cannot kill it without regaining a handle. A better long term solution would be a higher level process abstraction that uses windows.CreateProcess on windows. --- testutil/vault.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/testutil/vault.go b/testutil/vault.go index b2b353c5f..6719b6610 100644 --- a/testutil/vault.go +++ b/testutil/vault.go @@ -167,13 +167,15 @@ func NewTestVaultDelayed(t testing.T) *TestVault { // Start starts the test Vault server and waits for it to respond to its HTTP // API func (tv *TestVault) Start() error { - if err := tv.cmd.Start(); err != nil { - tv.t.Fatalf("failed to start vault: %v", err) - } - // Start the waiter tv.waitCh = make(chan error, 1) + go func() { + if err := tv.cmd.Start(); err != nil { + tv.waitCh <- err + return + } + err := tv.cmd.Wait() tv.waitCh <- err }()