go.tools/cmd/godoc: wait for analysis to complete in TestTypeAnalysis

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/157590043
This commit is contained in:
Alex Brainman 2014-10-28 12:25:46 +11:00
parent 113eb67ee0
commit d8b266df1c
1 changed files with 20 additions and 1 deletions

View File

@ -5,8 +5,10 @@
package main_test
import (
"bufio"
"bytes"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
@ -272,7 +274,10 @@ func main() { print(lib.V) }
cmd.Env = append(cmd.Env, e)
}
cmd.Stdout = os.Stderr
cmd.Stderr = os.Stderr
stderr, err := cmd.StderrPipe()
if err != nil {
t.Fatal(err)
}
cmd.Args[0] = "godoc"
if err := cmd.Start(); err != nil {
t.Fatalf("failed to start godoc: %s", err)
@ -280,6 +285,20 @@ func main() { print(lib.V) }
defer cmd.Process.Kill()
waitForServer(t, addr)
// Wait for type analysis to complete.
reader := bufio.NewReader(stderr)
for {
s, err := reader.ReadString('\n')
if err != nil {
t.Fatal(err)
}
fmt.Fprint(os.Stderr, s)
if strings.Contains(s, "Type analysis complete.") {
break
}
}
go io.Copy(os.Stderr, reader)
t0 := time.Now()
// Make an HTTP request and check for a regular expression match.