+ if after, err := rcv.ReadBytes('\n'); err != nil || string(after) != "after\n" {
+ t.Fatal("\"after\n\" not received (got \"%s\", %s)", after, err)
+ }
+
+ select {
+ case <-time.After(time.Second):
+ t.Fatal("Timeout")
+ case <-control:
+ // Done.
+ }
+}
+
+func captureLogs() *bufio.Reader {
+ // Send childLog to our bufio reader instead of stderr
+ stderrIn, stderrOut := io.Pipe()
+ childLog = log.New(stderrOut, "", 0)
+ statLog = log.New(stderrOut, "crunchstat: ", 0)
+ return bufio.NewReader(stderrIn)
+}
+
+func uncaptureLogs() {
+ childLog = log.New(os.Stderr, "", 0)
+ statLog = log.New(os.Stderr, "crunchstat: ", 0)