aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/http2_interop/testsuite.go
diff options
context:
space:
mode:
authorGravatar Carl Mastrangelo <notcarl@google.com>2015-12-02 14:46:50 -0800
committerGravatar Carl Mastrangelo <notcarl@google.com>2015-12-04 14:03:14 -0800
commit3c7862478d9da829199714e645b6c5a15fb7f596 (patch)
tree32d6c31fdffbb5490c3ffa170a6357c7080d226e /tools/http2_interop/testsuite.go
parentb67ef24d776fcc2a0b75ca4c85f58be762d0c68d (diff)
Make http2 interop tests always pass, and instead give a report
Diffstat (limited to 'tools/http2_interop/testsuite.go')
-rw-r--r--tools/http2_interop/testsuite.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/http2_interop/testsuite.go b/tools/http2_interop/testsuite.go
new file mode 100644
index 0000000000..fcfacf5fc1
--- /dev/null
+++ b/tools/http2_interop/testsuite.go
@@ -0,0 +1,44 @@
+package http2interop
+
+import (
+ "runtime"
+ "strings"
+ "sync"
+ "testing"
+)
+
+// When a test is skipped or fails, runtime.Goexit() is called which destroys the callstack.
+// This means the name of the test case is lost, so we need to grab a copy of pc before.
+func Report(t testing.TB) func() {
+ pc, _, _, ok := runtime.Caller(1)
+ if !ok {
+ t.Fatal("Can't get caller info")
+ }
+ return func() {
+ fn := runtime.FuncForPC(pc)
+ fullName := fn.Name()
+ name := strings.Split(fullName, ".")[1]
+ allCaseInfos.lock.Lock()
+ defer allCaseInfos.lock.Unlock()
+ allCaseInfos.Cases = append(allCaseInfos.Cases, &caseInfo{
+ Name: name,
+ Passed: !t.Failed(),
+ Skipped: t.Skipped(),
+ })
+ }
+}
+
+type caseInfo struct {
+ Name string `json:"name"`
+ Passed bool `json:"passed"`
+ Skipped bool `json:"skipped"`
+}
+
+type caseInfos struct {
+ lock sync.Mutex
+ Cases []*caseInfo `json:"cases"`
+}
+
+var (
+ allCaseInfos = caseInfos{}
+)