This commit is contained in:
chhsiao90 2017-03-01 15:18:15 +08:00
Родитель 0d21157c91
Коммит 7b6158603e
4 изменённых файлов: 27 добавлений и 5 удалений

Просмотреть файл

@ -155,3 +155,7 @@ func (c *Config) buildTargetMap() {
c.targetMap[section] = true c.targetMap[section] = true
} }
} }
func (c *Config) IsBrowserMode() bool {
return c.Exec == ""
}

Просмотреть файл

@ -76,7 +76,7 @@ func RunClientSpec(c *config.Config) error {
return err return err
} }
if c.Exec != "" { if !c.IsBrowserMode() {
start := time.Now() start := time.Now()
s.Test(c) s.Test(c)
end := time.Now() end := time.Now()
@ -90,7 +90,6 @@ func RunClientSpec(c *config.Config) error {
log.SetIndentLevel(0) log.SetIndentLevel(0)
log.Println(fmt.Sprintf("Finished in %.4f seconds", d.Seconds())) log.Println(fmt.Sprintf("Finished in %.4f seconds", d.Seconds()))
reporter.PrintSummaryForClient(s) reporter.PrintSummaryForClient(s)
} else { } else {
// Block running // Block running
log.Println("--exec is not defined, enable BROWSER mode") log.Println("--exec is not defined, enable BROWSER mode")

Просмотреть файл

@ -81,6 +81,11 @@ func (server *Server) Close() {
} }
func (server *Server) handleConn(conn *Conn, tc *ClientTestCase) { func (server *Server) handleConn(conn *Conn, tc *ClientTestCase) {
if server.config.IsBrowserMode() {
// Only log here when browser mode
log.Println(groupNames(tc.Parent))
}
start := time.Now() start := time.Now()
err := conn.Handshake() err := conn.Handshake()
@ -100,10 +105,12 @@ func (server *Server) handleConn(conn *Conn, tc *ClientTestCase) {
// Ensure that connection had been closed // Ensure that connection had been closed
go closeConn(conn, request.StreamID) go closeConn(conn, request.StreamID)
log.ResetLine()
tr := NewClientTestResult(tc, err, end.Sub(start)) tr := NewClientTestResult(tc, err, end.Sub(start))
tr.Print()
if server.config.IsBrowserMode() {
// Only log here when browser mode
tr.Print()
}
if tc.Result != nil { if tc.Result != nil {
tc.Parent.IncRecursive(tc.Result.Failed, tc.Result.Skipped, -1) tc.Parent.IncRecursive(tc.Result.Failed, tc.Result.Skipped, -1)
@ -113,6 +120,14 @@ func (server *Server) handleConn(conn *Conn, tc *ClientTestCase) {
tc.Parent.IncRecursive(tc.Result.Failed, tc.Result.Skipped, 1) tc.Parent.IncRecursive(tc.Result.Failed, tc.Result.Skipped, 1)
} }
func groupNames(tg *ClientTestGroup) string {
if tg.IsRoot() {
return tg.Title()
}
parentGroupNames := groupNames(tg.Parent)
return fmt.Sprintf("%s -> %s", parentGroupNames, tg.Title())
}
func closeConn(conn *Conn, lastStreamID uint32) { func closeConn(conn *Conn, lastStreamID uint32) {
if !conn.Closed { if !conn.Closed {
conn.WriteGoAway(lastStreamID, http2.ErrCodeNo, make([]byte, 0)) conn.WriteGoAway(lastStreamID, http2.ErrCodeNo, make([]byte, 0))

Просмотреть файл

@ -162,6 +162,10 @@ func (tc *ClientTestCase) Test(c *config.Config) error {
select { select {
case <-done: case <-done:
// command failed with non-zero exit code is accept // command failed with non-zero exit code is accept
if tc.Result != nil {
log.ResetLine()
tc.Result.Print()
}
return nil return nil
case <-time.After(time.Duration(3) * time.Second): case <-time.After(time.Duration(3) * time.Second):
return ErrTimeout return ErrTimeout