From 7b6158603ea13c8f4e922d2ed6615b4a00e01fd0 Mon Sep 17 00:00:00 2001 From: chhsiao90 Date: Wed, 1 Mar 2017 15:18:15 +0800 Subject: [PATCH] Update log message --- config/config.go | 4 ++++ h2spec.go | 3 +-- spec/server.go | 21 ++++++++++++++++++--- spec/specd.go | 4 ++++ 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index adbf41c..70f7b18 100644 --- a/config/config.go +++ b/config/config.go @@ -155,3 +155,7 @@ func (c *Config) buildTargetMap() { c.targetMap[section] = true } } + +func (c *Config) IsBrowserMode() bool { + return c.Exec == "" +} diff --git a/h2spec.go b/h2spec.go index 769e0e4..2381f03 100644 --- a/h2spec.go +++ b/h2spec.go @@ -76,7 +76,7 @@ func RunClientSpec(c *config.Config) error { return err } - if c.Exec != "" { + if !c.IsBrowserMode() { start := time.Now() s.Test(c) end := time.Now() @@ -90,7 +90,6 @@ func RunClientSpec(c *config.Config) error { log.SetIndentLevel(0) log.Println(fmt.Sprintf("Finished in %.4f seconds", d.Seconds())) reporter.PrintSummaryForClient(s) - } else { // Block running log.Println("--exec is not defined, enable BROWSER mode") diff --git a/spec/server.go b/spec/server.go index 7eaf042..5a5ffb5 100644 --- a/spec/server.go +++ b/spec/server.go @@ -81,6 +81,11 @@ func (server *Server) Close() { } 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() err := conn.Handshake() @@ -100,10 +105,12 @@ func (server *Server) handleConn(conn *Conn, tc *ClientTestCase) { // Ensure that connection had been closed go closeConn(conn, request.StreamID) - log.ResetLine() - 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 { 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) } +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) { if !conn.Closed { conn.WriteGoAway(lastStreamID, http2.ErrCodeNo, make([]byte, 0)) diff --git a/spec/specd.go b/spec/specd.go index ef5b0e7..3e48759 100644 --- a/spec/specd.go +++ b/spec/specd.go @@ -162,6 +162,10 @@ func (tc *ClientTestCase) Test(c *config.Config) error { select { case <-done: // command failed with non-zero exit code is accept + if tc.Result != nil { + log.ResetLine() + tc.Result.Print() + } return nil case <-time.After(time.Duration(3) * time.Second): return ErrTimeout