-
-
Notifications
You must be signed in to change notification settings - Fork 422
Added --timestamp
option to monitor command.
#2336
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
Conversation
CLA assistant check
All committers have signed the CLA.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@ ## master #2336 +/- ## ========================================== + Coverage 63.03% 63.04% +0.01% ========================================== Files 201 201 Lines 19264 19286 +22 ========================================== + Hits 12143 12159 +16 - Misses 6067 6072 +5 - Partials 1054 1055 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
👋 Thank you, for the contribution. The implementation looks good. 🤩
As you noticed, we do not have any integration tests for the monitor as we cannot provide a real board in the CI.
We can do a unit test in the same folder you're working on by creating a new monitor_test.go
file. You can look at this for some inspiration. In this case, the package name doesn't need to have the suffix _test
as we need to access a private function.
The idea is to test only the timeStampWriter
. These are some hints:
- We call the
newTimeStampWriter
providing something that satisfies theio.Writer
like (bytes.Buffer{}) - We "simulate" the data coming from the board by passing arbitrary input in the
timeStampWriter.Write
func - Once done writing, we should be able to assert the content of the buffer if has the timestamp as a prefix.
Don't forget to run go fmt ./...
from the root of the project. Or if you have task
installed you can run task go:format
. (That should solve the CI error)
If you need help don't hesitate to ping me I'd be more than happy to guide you. 💪
Thanks for the pointers, I'll add a test like you described.
73b87c1
to
a30a158
Compare
Test added and formatting fixed.
Oops, fixed that last formatting issue.
I've done some manual testing, and it works flawlessly. Thank you for your contribution and your patience. 🤓
--timestamp
option to monitor command. (追記ここまで)
Uh oh!
There was an error while loading. Please reload this page.
Please check if the PR fulfills these requirements
before creating one)
our contributing guidelines
What kind of change does this PR introduce?
New feature in the monitor that can add a timestamp to the beginning of each received line.
What is the current behavior?
No such option.
What is the new behavior?
When
--timestamp
is provided, the monitor wraps the output tty with a timestamping Writer. The format of the timestamps isYYYY-mm-dd HH:MM:SS
.Does this PR introduce a breaking change, and is titled accordingly?
Negative.
Other information
This is my first time writing Go (except for the sample program I used to work out the approach), so please review carefully.
There don't appear to be any docs specifically about the monitor command, nor tests of the CLI entry point.
The change was tested by hand using this sketch:
Testing confirmed that individual non-newline characters received are still output immediately, and only newline characters cause the timestamp output: