diff options
Diffstat (limited to 'xdelta3/go/src/xdelta/test.go')
-rw-r--r-- | xdelta3/go/src/xdelta/test.go | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/xdelta3/go/src/xdelta/test.go b/xdelta3/go/src/xdelta/test.go index ab4137c..05de487 100644 --- a/xdelta3/go/src/xdelta/test.go +++ b/xdelta3/go/src/xdelta/test.go | |||
@@ -47,9 +47,8 @@ func (t *TestGroup) Drain(f io.ReadCloser, desc string) <-chan []byte { | |||
47 | return c | 47 | return c |
48 | } | 48 | } |
49 | 49 | ||
50 | func (t *TestGroup) Empty(f io.ReadCloser, desc string) { | 50 | func (t *TestGroup) Empty(f io.ReadCloser, desc string) Goroutine { |
51 | t.Go(desc, func (g Goroutine) { | 51 | return t.Go("empty:"+desc, func (g Goroutine) { |
52 | g.OK() | ||
53 | s := bufio.NewScanner(f) | 52 | s := bufio.NewScanner(f) |
54 | for s.Scan() { | 53 | for s.Scan() { |
55 | os.Stderr.Write([]byte(fmt.Sprint(desc, ": ", s.Text(), "\n"))) | 54 | os.Stderr.Write([]byte(fmt.Sprint(desc, ": ", s.Text(), "\n"))) |
@@ -57,9 +56,9 @@ func (t *TestGroup) Empty(f io.ReadCloser, desc string) { | |||
57 | err := s.Err() | 56 | err := s.Err() |
58 | f.Close() | 57 | f.Close() |
59 | if err != nil { | 58 | if err != nil { |
60 | fmt.Println("Empty", desc, err) | ||
61 | g.Panic(err) | 59 | g.Panic(err) |
62 | } | 60 | } |
61 | g.OK() | ||
63 | }) | 62 | }) |
64 | } | 63 | } |
65 | 64 | ||
@@ -75,8 +74,8 @@ func TestWrite(what string, f io.WriteCloser, b []byte) error { | |||
75 | return nil | 74 | return nil |
76 | } | 75 | } |
77 | 76 | ||
78 | func (t *TestGroup) CopyStreams(r io.ReadCloser, w io.WriteCloser) { | 77 | func (t *TestGroup) CopyStreams(r io.ReadCloser, w io.WriteCloser) Goroutine { |
79 | t.Go("copy", func(g Goroutine) { | 78 | return t.Go("copy", func(g Goroutine) { |
80 | _, err := io.Copy(w, r) | 79 | _, err := io.Copy(w, r) |
81 | if err != nil { | 80 | if err != nil { |
82 | fmt.Println("CopyS", err) | 81 | fmt.Println("CopyS", err) |
@@ -96,8 +95,8 @@ func (t *TestGroup) CopyStreams(r io.ReadCloser, w io.WriteCloser) { | |||
96 | }) | 95 | }) |
97 | } | 96 | } |
98 | 97 | ||
99 | func (t *TestGroup) CompareStreams(r1 io.ReadCloser, r2 io.ReadCloser, length int64) { | 98 | func (t *TestGroup) CompareStreams(r1 io.ReadCloser, r2 io.ReadCloser, length int64) Goroutine { |
100 | t.Go("compare", func(g Goroutine) { | 99 | return t.Go("compare", func(g Goroutine) { |
101 | b1 := make([]byte, blocksize) | 100 | b1 := make([]byte, blocksize) |
102 | b2 := make([]byte, blocksize) | 101 | b2 := make([]byte, blocksize) |
103 | var idx int64 | 102 | var idx int64 |
@@ -162,15 +161,13 @@ func (t *TestGroup) Exec(desc string, p *Program, srcfifo bool, flags []string) | |||
162 | if serr := run.Cmd.Start(); serr != nil { | 161 | if serr := run.Cmd.Start(); serr != nil { |
163 | return nil, serr | 162 | return nil, serr |
164 | } | 163 | } |
165 | t.Go("exec-wait:" + desc, func (g Goroutine) { | ||
166 | if err := run.Cmd.Wait(); err != nil { | ||
167 | g.Panic(err) | ||
168 | } | ||
169 | g.OK() | ||
170 | }) | ||
171 | return run, nil | 164 | return run, nil |
172 | } | 165 | } |
173 | 166 | ||
167 | func (r *Run) Wait() error { | ||
168 | return r.Cmd.Wait() | ||
169 | } | ||
170 | |||
174 | func writeFifo(srcfile string, read io.Reader) error { | 171 | func writeFifo(srcfile string, read io.Reader) error { |
175 | fifo, err := os.OpenFile(srcfile, os.O_WRONLY, 0600) | 172 | fifo, err := os.OpenFile(srcfile, os.O_WRONLY, 0600) |
176 | if err != nil { | 173 | if err != nil { |