From d8ebbea2560875eb16143eca1fbd3d6b7dcd6087 Mon Sep 17 00:00:00 2001 From: suntala Date: Thu, 24 Apr 2025 22:52:47 +0200 Subject: [PATCH] Add Output method --- api/next/59928.txt | 3 +++ doc/next/6-stdlib/99-minor/testing/59928.md | 1 + src/testing/testing.go | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 api/next/59928.txt create mode 100644 doc/next/6-stdlib/99-minor/testing/59928.md diff --git a/api/next/59928.txt b/api/next/59928.txt new file mode 100644 index 0000000000..375c7c0e90 --- /dev/null +++ b/api/next/59928.txt @@ -0,0 +1,3 @@ +pkg testing, method (*B) Output() io.Writer #59928 +pkg testing, method (*F) Output() io.Writer #59928 +pkg testing, method (*T) Output() io.Writer #59928 diff --git a/doc/next/6-stdlib/99-minor/testing/59928.md b/doc/next/6-stdlib/99-minor/testing/59928.md new file mode 100644 index 0000000000..be80625c81 --- /dev/null +++ b/doc/next/6-stdlib/99-minor/testing/59928.md @@ -0,0 +1 @@ +TODO by Arati. \ No newline at end of file diff --git a/src/testing/testing.go b/src/testing/testing.go index e3992cfcf0..ec2350981c 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1069,6 +1069,16 @@ func (c *common) callSite(skip int) string { return fmt.Sprintf("%s:%d: ", file, line) } +// // Output returns a Writer that writes to the same test output stream as TB.Log. +// // The output is indented like TB.Log lines, but Output does not +// // add source locations or newlines. The output is internally line +// // buffered, and a call to TB.Log or the end of the test will implicitly +// // flush the buffer, followed by a newline. After a test function returns, +// // neither Output nor the Write method may be called. +func (c *common) Output() io.Writer { + return c.o +} + // setOutputWriter initializes an outputWriter and sets it as a common field. func (c *common) setOutputWriter() { c.o = &outputWriter{c: c}