Skip to content

also write test stderr to json (xml) output file#7

Merged
rickystewart merged 1 commit intorelease-0.33from
writestderrtoxml
Sep 7, 2022
Merged

also write test stderr to json (xml) output file#7
rickystewart merged 1 commit intorelease-0.33from
writestderrtoxml

Conversation

@rickystewart
Copy link
Copy Markdown

Without this, people are forced to look in the test.log file for output
to stderr, rather than test.xml.

Without this, people are forced to look in the test.log file for output
to stderr, rather than test.xml.
func Wrap(pkg string) error {
var jsonBuffer bytes.Buffer
jsonConverter := NewConverter(&jsonBuffer, pkg, Timestamp)
pipeRead, pipeWrite := io.Pipe()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a pipe needed/chosen here over the following?

cmd.Stderr = io.MultiWriter(os.Stderr, jsonConverter)
cmd.Stdout = io.MultiWriter(os.Stdout, jsonConverter)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I tried first, but it's racy since we have two streams writing to the same underlying bytes.Buffer. The io.Pipe is thread-safe.

@rickystewart rickystewart changed the title Be verbose about the error code returned from failing tests also write test stderr to json (xml) output file Sep 7, 2022
@rickystewart rickystewart merged commit 0f2df9c into release-0.33 Sep 7, 2022
@rickystewart rickystewart deleted the writestderrtoxml branch September 7, 2022 19:05
rickystewart added a commit to rickystewart/cockroach that referenced this pull request Sep 7, 2022
Pull in cockroachdb/rules_go#7.

Closes cockroachdb#69534.
Closes cockroachdb#85650.
Closes cockroachdb#87186.

Release justification: Non-production code changes
Release note: None
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request Sep 8, 2022
87528: bazel: upgrade `rules_go` r=healthy-pod a=rickystewart

Pull in cockroachdb/rules_go#7.

Closes #69534.
Closes #85650.
Closes #87186.

Release justification: Non-production code changes
Release note: None

Co-authored-by: Ricky Stewart <ricky@cockroachlabs.com>
blathers-crl bot pushed a commit to cockroachdb/cockroach that referenced this pull request Sep 8, 2022
Pull in cockroachdb/rules_go#7.

Closes #69534.
Closes #85650.
Closes #87186.

Release justification: Non-production code changes
Release note: None
rickystewart added a commit to cockroachdb/cockroach that referenced this pull request Sep 15, 2022
Pull in cockroachdb/rules_go#7.

Closes #69534.
Closes #85650.
Closes #87186.

Release justification: Non-production code changes
Release note: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants