MCPcopy Index your code
hub / github.com/cortexproject/cortex / captureOutput

Function captureOutput

cmd/cortex/main_test.go:165–189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func captureOutput(t *testing.T) *capturedOutput {
166 stdoutR, stdoutW, err := os.Pipe()
167 require.NoError(t, err)
168 os.Stdout = stdoutW
169
170 stderrR, stderrW, err := os.Pipe()
171 require.NoError(t, err)
172 os.Stderr = stderrW
173
174 co := &capturedOutput{
175 stdoutReader: stdoutR,
176 stdoutWriter: stdoutW,
177 stderrReader: stderrR,
178 stderrWriter: stderrW,
179 }
180 co.wg.Go(func() {
181 io.Copy(&co.stdoutBuf, stdoutR)
182 })
183
184 co.wg.Go(func() {
185 io.Copy(&co.stderrBuf, stderrR)
186 })
187
188 return co
189}
190
191func (co *capturedOutput) Done() (stdout []byte, stderr []byte) {
192 // we need to close writers for readers to stop

Callers 1

testSingleFunction · 0.85

Calls 1

CopyMethod · 0.45

Tested by

no test coverage detected