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

test: capture stderr for tests #607

Merged
merged 1 commit into from
Nov 9, 2023
Merged

test: capture stderr for tests #607

merged 1 commit into from
Nov 9, 2023

Conversation

phm07
Copy link
Contributor

@phm07 phm07 commented Nov 9, 2023

In the future this will be useful for testing "-o=json" on resource creation, because the actual JSON and status messages will be printed to stdout/stderr respectively.

@phm07 phm07 added the test label Nov 9, 2023
@phm07 phm07 self-assigned this Nov 9, 2023
@phm07 phm07 requested a review from a team as a code owner November 9, 2023 12:12
In the future this will be useful for testing "-o=json" on resource creation, because the actual JSON and status messages will be printed to stdout/stderr respectively.
@phm07 phm07 force-pushed the test-capture-stderr branch from 99d3d9a to 958961b Compare November 9, 2023 12:16
Copy link
Member

@jooola jooola left a comment

Choose a reason for hiding this comment

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

Have you considered renaming the out var to stdout in this PR as well ?

You will probably end up with out, stderr, err := fx.Run(cmd, []string{}) so you might as well rename everything now to maintain consistency:

stdout, _, err := fx.Run(cmd, []string{})
stdout, stderr, err := fx.Run(cmd, []string{})

@phm07
Copy link
Contributor Author

phm07 commented Nov 9, 2023

Have you considered renaming the out var to stdout in this PR as well ?

You will probably end up with out, stderr, err := fx.Run(cmd, []string{}) so you might as well rename everything now to maintain consistency:

stdout, _, err := fx.Run(cmd, []string{})
stdout, stderr, err := fx.Run(cmd, []string{})

In the vast majority of cases there won't be any output to stderr anyway so the second string can be safely ignored. In that case out is still a concise variable name in my opinion.
If you use the second return value though, I agree that the naming you suggested is sensible. I don't think renaming every out now would be needed though.

@phm07 phm07 merged commit a77e553 into main Nov 9, 2023
3 checks passed
@phm07 phm07 deleted the test-capture-stderr branch November 9, 2023 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants