diff options
Diffstat (limited to 'xdelta3/go/src/xdelta')
-rw-r--r-- | xdelta3/go/src/xdelta/test.go | 21 | ||||
-rw-r--r-- | xdelta3/go/src/xdelta/tgroup.go | 11 |
2 files changed, 20 insertions, 12 deletions
diff --git a/xdelta3/go/src/xdelta/test.go b/xdelta3/go/src/xdelta/test.go index bab66f3..7210698 100644 --- a/xdelta3/go/src/xdelta/test.go +++ b/xdelta3/go/src/xdelta/test.go | |||
@@ -47,14 +47,16 @@ func (t *TestGroup) Empty(f io.ReadCloser, desc string) *Goroutine { | |||
47 | }) | 47 | }) |
48 | } | 48 | } |
49 | 49 | ||
50 | func TestWrite(what string, f io.WriteCloser, b []byte) error { | 50 | func (t *TestGroup) TestWrite(what string, f io.WriteCloser, b []byte) *Goroutine { |
51 | if _, err := f.Write(b); err != nil { | 51 | return t.Go("write", func(g *Goroutine) { |
52 | return errors.New(fmt.Sprint(what, ":", err)) | 52 | if _, err := f.Write(b); err != nil { |
53 | } | 53 | g.Panic(err) |
54 | if err := f.Close(); err != nil { | 54 | } |
55 | return errors.New(fmt.Sprint(what, ":", err)) | 55 | if err := f.Close(); err != nil { |
56 | } | 56 | g.Panic(err) |
57 | return nil | 57 | } |
58 | g.OK() | ||
59 | }) | ||
58 | } | 60 | } |
59 | 61 | ||
60 | func (t *TestGroup) CopyStreams(r io.ReadCloser, w io.WriteCloser, written *int64) *Goroutine { | 62 | func (t *TestGroup) CopyStreams(r io.ReadCloser, w io.WriteCloser, written *int64) *Goroutine { |
@@ -104,7 +106,7 @@ func (t *TestGroup) CompareStreams(r1 io.ReadCloser, r2 io.ReadCloser, length in | |||
104 | }) | 106 | }) |
105 | } | 107 | } |
106 | 108 | ||
107 | func (t *TestGroup) Exec(desc string, p *Program, srcfifo bool, flags []string) (*Run, error) { | 109 | func (t *TestGroup) Exec(desc string, p Program, srcfifo bool, flags []string) (*Run, error) { |
108 | var err error | 110 | var err error |
109 | run := &Run{} | 111 | run := &Run{} |
110 | args := []string{p.Path} | 112 | args := []string{p.Path} |
@@ -133,7 +135,6 @@ func (t *TestGroup) Exec(desc string, p *Program, srcfifo bool, flags []string) | |||
133 | run.Cmd.Path = p.Path | 135 | run.Cmd.Path = p.Path |
134 | run.Cmd.Args = append(args, flags...) | 136 | run.Cmd.Args = append(args, flags...) |
135 | run.Cmd.Dir = t.Runner.Testdir | 137 | run.Cmd.Dir = t.Runner.Testdir |
136 | fmt.Println("Start command", run.Cmd.Args) | ||
137 | if serr := run.Cmd.Start(); serr != nil { | 138 | if serr := run.Cmd.Start(); serr != nil { |
138 | return nil, serr | 139 | return nil, serr |
139 | } | 140 | } |
diff --git a/xdelta3/go/src/xdelta/tgroup.go b/xdelta3/go/src/xdelta/tgroup.go index 0a3b41b..b1b04ec 100644 --- a/xdelta3/go/src/xdelta/tgroup.go +++ b/xdelta3/go/src/xdelta/tgroup.go | |||
@@ -29,6 +29,11 @@ func (g *Goroutine) String() string { | |||
29 | func (g *Goroutine) finish(err error) { | 29 | func (g *Goroutine) finish(err error) { |
30 | wait := false | 30 | wait := false |
31 | tg := g.TestGroup | 31 | tg := g.TestGroup |
32 | sbuf := make([]byte, 4096) | ||
33 | sbuf = sbuf[0:runtime.Stack(sbuf, false)] | ||
34 | if err != nil { | ||
35 | err = fmt.Errorf("%v:%v:%v", g.name, err, string(sbuf)) | ||
36 | } | ||
32 | tg.Lock() | 37 | tg.Lock() |
33 | if g.done { | 38 | if g.done { |
34 | if err != nil { | 39 | if err != nil { |
@@ -58,6 +63,8 @@ func (g *Goroutine) Panic(err error) { | |||
58 | 63 | ||
59 | func (t *TestGroup) Main() *Goroutine { return t.main } | 64 | func (t *TestGroup) Main() *Goroutine { return t.main } |
60 | 65 | ||
66 | func (t *TestGroup) Panic(err error) { t.Main().Panic(err) } | ||
67 | |||
61 | func (t *TestGroup) Go(name string, f func(*Goroutine)) *Goroutine { | 68 | func (t *TestGroup) Go(name string, f func(*Goroutine)) *Goroutine { |
62 | g := &Goroutine{t, name, false} | 69 | g := &Goroutine{t, name, false} |
63 | t.Lock() | 70 | t.Lock() |
@@ -68,8 +75,8 @@ func (t *TestGroup) Go(name string, f func(*Goroutine)) *Goroutine { | |||
68 | return g | 75 | return g |
69 | } | 76 | } |
70 | 77 | ||
71 | func (t *TestGroup) Wait(self *Goroutine, procs... *Run) { | 78 | func (t *TestGroup) Wait(procs... *Run) { |
72 | self.OK() | 79 | t.Main().OK() |
73 | t.WaitGroup.Wait() | 80 | t.WaitGroup.Wait() |
74 | for _, p := range procs { | 81 | for _, p := range procs { |
75 | if err := p.Wait(); err != nil { | 82 | if err := p.Wait(); err != nil { |