-
Notifications
You must be signed in to change notification settings - Fork 32
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
Implement option to write output to a file in ec test
#1244
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1244 +/- ##
==========================================
- Coverage 82.43% 82.21% -0.22%
==========================================
Files 72 72
Lines 5721 5746 +25
==========================================
+ Hits 4716 4724 +8
- Misses 1005 1022 +17
Flags with carried forward coverage won't be shown. Click here to find out more.
|
aaa1887
to
d10ab70
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unfortunate that this part of the code base has no unit test at all. Be sure to perform some manual tests.
Not sure if the previous comments were addressed or not. Is this ready for fresh reviews @mbestavros ? |
@simonbaird I wasn't able to get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpickery, otherwise LGTM
cmd/test/test.go
Outdated
if err != nil { | ||
return fmt.Errorf("creating output file: %w", err) | ||
} | ||
} | ||
fmt.Printf("%s\n", reportOutput) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed we're not using cmd.OutOrStdout()
here, we should, could be in a followup PR as this wasn't added here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tossed it in!
cmd/test/test.go
Outdated
if err != nil { | ||
return fmt.Errorf("copying output file to stdout: %w", err) | ||
} | ||
fmt.Println(string(contents)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to use cmd.OutOrStdout()
here
fmt.Println(string(contents)) | |
fmt.Fprintln(cmd.OutOrStdout(), string(contents)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zregvart Done!
fa941d9
to
37cab1d
Compare
Signed-off-by: Mark Bestavros <mbestavr@redhat.com>
This PR adds an option to
ec test
to allow output to a file. Users can use the new option withec test ... --file <file path>
.The PR utilizes new functionality available in Conftest
0.47
to write Conftest output to a file.Resolves EC-55.