1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // TODO(@musiol, @odeke-em): re-unify this entire file back into
8 // example.go when js/wasm gets an os.Pipe implementation
9 // and no longer needs this separation.
21 func runExample(eg InternalExample
) (ok
bool) {
23 fmt
.Printf("=== RUN %s\n", eg
.Name
)
28 r
, w
, err
:= os
.Pipe()
30 fmt
.Fprintln(os
.Stderr
, err
)
34 outC
:= make(chan string)
36 var buf strings
.Builder
37 _
, err
:= io
.Copy(&buf
, r
)
40 fmt
.Fprintf(os
.Stderr
, "testing: copying pipe: %v\n", err
)
49 // Clean up in a deferred call so we can recover if the example panics.
51 timeSpent
:= time
.Since(start
)
53 // Close pipe, restore stdout, get output.
59 ok
= eg
.processRunResult(out
, timeSpent
, finished
, err
)