summaryrefslogtreecommitdiff
path: root/xdelta3/go/src/xdelta/tgroup.go
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/go/src/xdelta/tgroup.go')
-rw-r--r--xdelta3/go/src/xdelta/tgroup.go17
1 files changed, 6 insertions, 11 deletions
diff --git a/xdelta3/go/src/xdelta/tgroup.go b/xdelta3/go/src/xdelta/tgroup.go
index 7f6c875..0a3b41b 100644
--- a/xdelta3/go/src/xdelta/tgroup.go
+++ b/xdelta3/go/src/xdelta/tgroup.go
@@ -2,11 +2,13 @@ package xdelta
2 2
3import ( 3import (
4 "fmt" 4 "fmt"
5 "runtime"
5 "sync" 6 "sync"
6) 7)
7 8
8type TestGroup struct { 9type TestGroup struct {
9 *Runner 10 *Runner
11 main *Goroutine
10 sync.Mutex 12 sync.Mutex
11 sync.WaitGroup 13 sync.WaitGroup
12 running []*Goroutine 14 running []*Goroutine
@@ -20,14 +22,6 @@ type Goroutine struct {
20 done bool 22 done bool
21} 23}
22 24
23func NewTestGroup(r *Runner) (*TestGroup, *Goroutine) {
24 tg := &TestGroup{Runner: r}
25 tg.WaitGroup.Add(1)
26 g0 := &Goroutine{tg, "main", false}
27 tg.running = append(tg.running, g0)
28 return tg, g0
29}
30
31func (g *Goroutine) String() string { 25func (g *Goroutine) String() string {
32 return fmt.Sprint("[", g.name, "]") 26 return fmt.Sprint("[", g.name, "]")
33} 27}
@@ -59,9 +53,11 @@ func (g *Goroutine) OK() {
59 53
60func (g *Goroutine) Panic(err error) { 54func (g *Goroutine) Panic(err error) {
61 g.finish(err) 55 g.finish(err)
62 select {} 56 runtime.Goexit()
63} 57}
64 58
59func (t *TestGroup) Main() *Goroutine { return t.main }
60
65func (t *TestGroup) Go(name string, f func(*Goroutine)) *Goroutine { 61func (t *TestGroup) Go(name string, f func(*Goroutine)) *Goroutine {
66 g := &Goroutine{t, name, false} 62 g := &Goroutine{t, name, false}
67 t.Lock() 63 t.Lock()
@@ -87,7 +83,6 @@ func (t *TestGroup) Wait(self *Goroutine, procs... *Run) {
87 fmt.Println("(ERROR)", err) 83 fmt.Println("(ERROR)", err)
88 } 84 }
89 if len(t.errors) != 0 { 85 if len(t.errors) != 0 {
90 panic(fmt.Sprintf("Test failed with", len(t.errors), "errors")) 86 t.Fail("Test failed with", len(t.errors), "errors")
91 } 87 }
92} 88}
93