Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standard-json format #313

Merged
merged 2 commits into from
Mar 29, 2023
Merged

Add standard-json format #313

merged 2 commits into from
Mar 29, 2023

Conversation

Pawka
Copy link
Contributor

@Pawka Pawka commented Mar 29, 2023

Solves #312.

Adds a new standard-json format. This format can be used to stream test run output to stdout instead of writing to file via --jsonfile tag and reading the file later. The --jsonfile is still useful if there is a need to use a different format for stdout but also preserve test runs in the JSON file.

Usage: gotestsum --format=standard-json --hide-summary all (is the same as go test -json).

Similar to debug, keep this format out of help text, since in most cases
it would be better to product the desired format directly in gotestsum.

Also change to the new closure style of formatter that allows writing
bytes directly without converting to string.
Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! I made a few small changes. Primarily I hid the new format from the help text for now. As mentioned in #312, I'd love to make a native buildkite format, and my concern is that a documented json format will make it harder to learn about these new formats that could be native to gotestsum. The debug format is in a similar place. It's not documented, but it's an option.

I also changed the formatter to use the new eventFormatterFunc that I created for #315. I think this will be a lot more efficient because we can avoid converting []byte to strings.

{
name: "standard-json",
format: standardJSONFormat,
expectedOut: "input/go-test-json.out",
Copy link
Member

Choose a reason for hiding this comment

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

I changed this to use the input file as the expected value, to show that we output the exact value as the input.

@dnephin dnephin merged commit 790e071 into gotestyourself:main Mar 29, 2023
@Pawka Pawka deleted the issue_312 branch March 30, 2023 07:13
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.

None yet

2 participants