From 4bb917e48d0850be408dba39049249930d1738ba Mon Sep 17 00:00:00 2001 From: Alex Brainman Date: Tue, 28 Oct 2014 16:59:58 +1100 Subject: [PATCH] go.tools/cmd/godoc: wait for godoc to exit before removing tmp directory otherwise tmp directories do not get deleted on windows LGTM=adg R=golang-codereviews, adg CC=golang-codereviews https://golang.org/cl/166750043 --- cmd/godoc/godoc_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/godoc/godoc_test.go b/cmd/godoc/godoc_test.go index c59ea4a6e7..946c1ec0a9 100644 --- a/cmd/godoc/godoc_test.go +++ b/cmd/godoc/godoc_test.go @@ -140,6 +140,11 @@ func waitForServer(t *testing.T, address string) { t.Fatalf("Server %q failed to respond in 5 seconds", address) } +func killAndWait(cmd *exec.Cmd) { + cmd.Process.Kill() + cmd.Wait() +} + // Basic integration test for godoc HTTP interface. func TestWeb(t *testing.T) { bin, cleanup := buildGodoc(t) @@ -152,7 +157,7 @@ func TestWeb(t *testing.T) { if err := cmd.Start(); err != nil { t.Fatalf("failed to start godoc: %s", err) } - defer cmd.Process.Kill() + defer killAndWait(cmd) waitForServer(t, addr) tests := []struct { path string @@ -282,7 +287,7 @@ func main() { print(lib.V) } if err := cmd.Start(); err != nil { t.Fatalf("failed to start godoc: %s", err) } - defer cmd.Process.Kill() + defer killAndWait(cmd) waitForServer(t, addr) // Wait for type analysis to complete.