summaryrefslogtreecommitdiff
path: root/xdelta3/go/src/xdelta
diff options
context:
space:
mode:
authorJoshua MacDonald <josh.macdonald@gmail.com>2015-12-11 00:12:32 -0800
committerJoshua MacDonald <josh.macdonald@gmail.com>2015-12-11 00:12:32 -0800
commit29a5718a2c10feb0d3b92b52dfa7dc470f7c705e (patch)
tree3faa9d34f7e840f2c0a5309febd95c7d2feedf81 /xdelta3/go/src/xdelta
parentb65269806e9b4c01f22614e93782ff4686eea72d (diff)
Add dataset test
Diffstat (limited to 'xdelta3/go/src/xdelta')
-rw-r--r--xdelta3/go/src/xdelta/test.go21
-rw-r--r--xdelta3/go/src/xdelta/tgroup.go11
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
50func TestWrite(what string, f io.WriteCloser, b []byte) error { 50func (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
60func (t *TestGroup) CopyStreams(r io.ReadCloser, w io.WriteCloser, written *int64) *Goroutine { 62func (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
107func (t *TestGroup) Exec(desc string, p *Program, srcfifo bool, flags []string) (*Run, error) { 109func (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 {
29func (g *Goroutine) finish(err error) { 29func (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
59func (t *TestGroup) Main() *Goroutine { return t.main } 64func (t *TestGroup) Main() *Goroutine { return t.main }
60 65
66func (t *TestGroup) Panic(err error) { t.Main().Panic(err) }
67
61func (t *TestGroup) Go(name string, f func(*Goroutine)) *Goroutine { 68func (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
71func (t *TestGroup) Wait(self *Goroutine, procs... *Run) { 78func (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 {