<feed xmlns='http://www.w3.org/2005/Atom'>
<title>go/src/cmd/internal/test2json/testdata, branch makepkg</title>
<subtitle>Fork of Go programming language with my patches.</subtitle>
<id>http://git.kilabit.info/go/atom?h=makepkg</id>
<link rel='self' href='http://git.kilabit.info/go/atom?h=makepkg'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/'/>
<updated>2025-05-21T22:37:35Z</updated>
<entry>
<title>testing: add Attr</title>
<updated>2025-05-21T22:37:35Z</updated>
<author>
<name>Damien Neil</name>
<email>dneil@google.com</email>
</author>
<published>2025-04-03T00:37:34Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=3cc8b532f9d561397dd0c66496e1e1a82667c926'/>
<id>urn:sha1:3cc8b532f9d561397dd0c66496e1e1a82667c926</id>
<content type='text'>
Add a new Attr method to testing.TB that emits a test attribute.
An attribute is an arbitrary key/value pair.

Fixes #43936

Change-Id: I7ef299efae41f2cf39f2dc61ad4cdd4c3975cdb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/662437
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Alan Donovan &lt;adonovan@google.com&gt;
Auto-Submit: Damien Neil &lt;dneil@google.com&gt;
</content>
</entry>
<entry>
<title>cmd/go: print test2json start events</title>
<updated>2022-11-09T17:33:07Z</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2022-11-07T16:58:45Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=7a92c4fc637621368eb26a7e72bb027b29568e50'/>
<id>urn:sha1:7a92c4fc637621368eb26a7e72bb027b29568e50</id>
<content type='text'>
Add a new "Action":"start" test2json event to mark the
start of the test binary execution. This adds useful information
to the JSON traces, and it also lets programs watching test
execution see the order in which the tests are being run,
because we arrange for the starts to happen sequentially.

Change-Id: I9fc865a486a55a7e9315f8686f59a2aa06455884
Reviewed-on: https://go-review.googlesource.com/c/go/+/448357
Run-TryBot: Russ Cox &lt;rsc@golang.org&gt;
Auto-Submit: Russ Cox &lt;rsc@golang.org&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Bryan Mills &lt;bcmills@google.com&gt;
</content>
</entry>
<entry>
<title>testing: fix many test2json inaccuracies</title>
<updated>2022-10-26T19:50:36Z</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2022-10-13T20:13:46Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=1c72ee7f13831b215b8744f6b35bc4fd53aba5e2'/>
<id>urn:sha1:1c72ee7f13831b215b8744f6b35bc4fd53aba5e2</id>
<content type='text'>
Test2json is parsing the output stream from the test, which includes
package testing's own framing lines intermingled with other output,
in particular any output printed via fmt.Printf, println, and so on.
We have had recurring problems with unexpected partial output lines
causing a framing line to be missed.

A recent talk at GopherCon gave an example of an integration test
involving Docker that happened to print \r-terminated lines instead
of \n-terminated lines in some configurations, which in turn broke
test2json badly. (https://www.gophercon.com/agenda/session/944259)

There are also a variety of open reported issues with similar problems,
which this CL also addresses. The general approach is to add a new
testing flag -test.v=json that means to print additional output to help
test2json. And then test2json takes advantage of that output.

Among the fixes:

 - Identify testing framing more reliably, using ^V
   (#23036, #26325, #43683, GopherCon talk)
 - Test that output with \r\n endings is handled correctly
   (#43683, #34286)
 - Use === RUN in fuzz tests (#52636, #48132)
 - Add === RUN lines to note benchmark starts (#27764, #49505)
 - Print subtest --- PASS/FAIL lines as they happen (#29811)
 - Add === NAME lines to emit more test change events,
   such as when a subtest stops and the parent continues running.
 - Fix event shown in overall test failure (#27568)
 - Avoid interleaving of writes to os.Stdout and os.Stderr (#33419)

Fixes #23036.
Fixes #26325.
Fixes #27568.
Fixes #27764.
Fixes #29811.
Fixes #33419.
Fixes #34286.
Fixes #43683.
Fixes #49505.
Fixes #52636.

Change-Id: Id4207b746a20693f92e52d68c6e4a7f8c41cc7c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/443596
Auto-Submit: Russ Cox &lt;rsc@golang.org&gt;
Run-TryBot: Russ Cox &lt;rsc@golang.org&gt;
Reviewed-by: Bryan Mills &lt;bcmills@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
</content>
</entry>
<entry>
<title>cmd/test2json: do not emit a final Action if the result is not known</title>
<updated>2020-08-17T19:43:21Z</updated>
<author>
<name>Bryan C. Mills</name>
<email>bcmills@google.com</email>
</author>
<published>2020-08-14T21:44:22Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=1b86bdbdc3991c13c6ed156100a5f4918fdd9c6b'/>
<id>urn:sha1:1b86bdbdc3991c13c6ed156100a5f4918fdd9c6b</id>
<content type='text'>
If we are parsing a test output, and the test does not end in the
usual PASS or FAIL line (say, because it panicked), then we need the
exit status of the test binary in order to determine whether the test
passed or failed. If we don't have that status available, we shouldn't
guess arbitrarily — instead, we should omit the final "pass" or "fail"
action entirely.

(In practice, we nearly always DO have the final status, such as when
running 'go test' or 'go tool test2json some.exe'.)

Fixes #40132

Change-Id: Iae482577361a6033395fe4a05d746b980e18c3de
Reviewed-on: https://go-review.googlesource.com/c/go/+/248624
Run-TryBot: Bryan C. Mills &lt;bcmills@google.com&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Jay Conrod &lt;jayconrod@google.com&gt;
</content>
</entry>
<entry>
<title>cmd/test2json: attribute output to the correct test</title>
<updated>2020-06-01T16:13:47Z</updated>
<author>
<name>Daniel Nephin</name>
<email>dnephin@gmail.com</email>
</author>
<published>2020-06-01T16:11:34Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=f8662a5a96698c5fcf3a77f692e425c7b857e681'/>
<id>urn:sha1:f8662a5a96698c5fcf3a77f692e425c7b857e681</id>
<content type='text'>
When printing regular test output check the indentation of the output, and use
the report stack to find the appropriate test name for that output.

This change includes a whitespace change to some golden test files. The
indentation of tests was changed in CL 113177
from tabs to spaces. The golden files have been updated to match the new
output format. The tabs in the golden files cause problems because the indentation check
looks for 4 spaces.

Fixes #29755
Updates #25369

Change-Id: Iebab51816a9755168083a7a665b41497e9dfd85f
GitHub-Last-Rev: 898827f1a6a163fd81dc667f5d27fd4893260038
GitHub-Pull-Request: golang/go#34419
Reviewed-on: https://go-review.googlesource.com/c/go/+/196617
Reviewed-by: Bryan C. Mills &lt;bcmills@google.com&gt;
</content>
</entry>
<entry>
<title>cmd/go: make go test -json report failures for panicking/exiting tests</title>
<updated>2020-03-06T17:28:04Z</updated>
<author>
<name>Jay Conrod</name>
<email>jayconrod@google.com</email>
</author>
<published>2020-03-05T16:11:47Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=5ea58c63468bbc7e8705ee13d0bddbf3693785fe'/>
<id>urn:sha1:5ea58c63468bbc7e8705ee13d0bddbf3693785fe</id>
<content type='text'>
'go test -json' should report that a test failed if the test binary
did not exit normally with status 0. This covers panics, non-zero
exits, and abnormal terminations.

These tests don't print a final result when run with -test.v (which is
used by 'go test -json'). The final result should be "PASS" or "FAIL"
on a line by itself. 'go test' prints "FAIL" in this case, but
includes error information.

test2json was changed in CL 192104 to report that a test passed if it
does not report a final status. This caused 'go test -json' to report
that a test passed after a panic or non-zero exit.

With this change, test2json treats "FAIL" with error information the
same as "FAIL" on a line by itself. This is intended to be a minimal
fix for backporting, but it will likely be replaced by a complete
solution for #29062.

Fixes #37555
Updates #29062
Updates #31969

Change-Id: Icb67bcd36bed97e6a8d51f4d14bf71f73c83ac3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/222243
Run-TryBot: Jay Conrod &lt;jayconrod@google.com&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Bryan C. Mills &lt;bcmills@google.com&gt;
</content>
</entry>
<entry>
<title>testing: provide additional information when test funcs panic</title>
<updated>2019-10-30T20:46:44Z</updated>
<author>
<name>Damien Neil</name>
<email>dneil@google.com</email>
</author>
<published>2019-05-30T16:46:56Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=81a74b4e8d4a1740529bb951eaa9569d429e4c0f'/>
<id>urn:sha1:81a74b4e8d4a1740529bb951eaa9569d429e4c0f</id>
<content type='text'>
Flush the output log up to the root when a test panics. Prior to
this change, only the current test's output log was flushed to its
parent, resulting in no output when a subtest panics.

For the following test function:

	func Test(t *testing.T) {
		for i, test := range []int{1, 0, 2} {
			t.Run(fmt.Sprintf("%v/%v", i, test), func(t *testing.T) {
				_ = 1 / test
			})
		}
	}

Output before this change:

	panic: runtime error: integer divide by zero [recovered]
		panic: runtime error: integer divide by zero
	(stack trace follows)

Output after this change:

	--- FAIL: Test (0.00s)
	    --- FAIL: Test/1/0 (0.00s)
	panic: runtime error: integer divide by zero [recovered]
	(stack trace follows)

Fixes #32121

Change-Id: Ifee07ccc005f0493a902190a8be734943123b6b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/179599
Run-TryBot: Damien Neil &lt;dneil@google.com&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@golang.org&gt;
</content>
</entry>
<entry>
<title>test2json: default to "pass" when the test doesn't report failures</title>
<updated>2019-08-31T01:06:32Z</updated>
<author>
<name>Eli Bendersky</name>
<email>eliben@google.com</email>
</author>
<published>2019-08-28T19:34:48Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=d47526ed777958aa4a2542382e931eb7b3c4c6a9'/>
<id>urn:sha1:d47526ed777958aa4a2542382e931eb7b3c4c6a9</id>
<content type='text'>
When a test has a TestMain that doesn't run any tests (doesn't invoke
m.Run), `go test` passes, but `go test -json` reports a "fail" event
though the exit code is still 0.

This CL fixes test2json to behave similarly to `go test` in such cases -
no output from the test is taken as "pass" by default, not as "fail".

Fixes #31969

Change-Id: I1829d40fc30dc2879e73974fac416f6a34212ccd
Reviewed-on: https://go-review.googlesource.com/c/go/+/192104
Run-TryBot: Ian Lance Taylor &lt;iant@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@golang.org&gt;
</content>
</entry>
<entry>
<title>cmd/internal/test2json: support subtests containing colons</title>
<updated>2018-03-10T10:13:25Z</updated>
<author>
<name>Daniel Martí</name>
<email>mvdan@mvdan.cc</email>
</author>
<published>2018-03-03T19:53:53Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=0c5cfec84424bb453ccd270f4b5c439f21ccf617'/>
<id>urn:sha1:0c5cfec84424bb453ccd270f4b5c439f21ccf617</id>
<content type='text'>
The "updates" lines, such as RUN, do not contain a colon. However,
test2json looked for one anyway, meaning that it would be thrown off if
it encountered a line like:

	=== RUN   TestWithColons/[::1]

In that case, it must not use the first colon it encounters to separate
the action from the test name.

Fixes #23920.

Change-Id: I82eff23e24b83dae183c0cf9f85fc5f409f51c25
Reviewed-on: https://go-review.googlesource.com/98445
Run-TryBot: Daniel Martí &lt;mvdan@mvdan.cc&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@golang.org&gt;
</content>
</entry>
<entry>
<title>cmd/test2json: emit Benchmark name output early</title>
<updated>2018-01-09T01:53:38Z</updated>
<author>
<name>Russ Cox</name>
<email>rsc@golang.org</email>
</author>
<published>2018-01-08T17:11:00Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=9044f018ec7bf35ac030dc5aec1acd7d18d6691c'/>
<id>urn:sha1:9044f018ec7bf35ac030dc5aec1acd7d18d6691c</id>
<content type='text'>
When benchmarks run, they print lines like:

  BenchmarkGenericNoMatch-8   3000000 385 ns/op

The first field, padded by spaces and followed by a tab,
is printed when the benchmark begins running.
The rest of the line is printed when the benchmark ends.
Tools and people can watch the timing of these prints
to see which benchmark is running.

To allow tools consuming json output to continue to be
able to see which benchmark is running, this CL adds a
special case to the usual "line at a time" behavior to flush
the benchmark name if it is observed separately from the
rest of the line.

Fixes #23352.

Change-Id: I7b6410698d78034eec18745d7f57b7d8e9575dbb
Reviewed-on: https://go-review.googlesource.com/86695
Run-TryBot: Russ Cox &lt;rsc@golang.org&gt;
TryBot-Result: Gobot Gobot &lt;gobot@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@golang.org&gt;
</content>
</entry>
</feed>
