-
Notifications
You must be signed in to change notification settings - Fork 2
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
Print buffer test tool #11
Conversation
to get access to the rendered buffer after a widget is rendered
Co-authored-by: Philipp Mildenberger <[email protected]>
Co-authored-by: Philipp Mildenberger <[email protected]>
564aa8b
to
7c8cd6c
Compare
7c8cd6c
to
a6bb858
Compare
I fixed the cachedir to work on all platforms to fix the CI failure on Windows. I sorted the dependencies and loosened the version constrain to ignore patch version (just mentioned it in case it gets lost because of reordering). |
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.
Well I thought about disabling the windows CI for now, but fixing it is even better :)
Sure no issue, I mean it's only patch versions, so theoretically semver compatible (although I think that's not strictly true for zero ver...). I want to keep it up to date with latest versions anyway (unless there's a good reason against it). Maybe I'm activating Dependabot at some time (but currently, I think it's more annoying than it really helps).
/// when multiple tests are run at once. | ||
/// Running it multiple times might usually leads to good output (for now, with small widget output) | ||
pub fn print_buffer(buffer: &Buffer) -> std::io::Result<()> { | ||
if env::var("DEBUG_SNAPSHOT").is_ok() { |
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.
Nice job on the doc comment.
I tried the one test with with_borders(BorderKind::Rounded)
and it seems to put the whole buffer linewise on one line to stdout, do you know whether it's possible to fix this?
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.
That was the sole purpose, but I don't know much about Ratatui and Crossterm yet and I failed to try a more "elaborate" 😉 example with multiple lines.
(I guess I did but failed to recognize because they were empty lines)
I will of course make an attempt to get that working.
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 will call cargo outdated
frequently to check anyway and if it doesn't bother you just upgrade when newer versions become available.
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.
Anyway I don't think printing the buffer is super important (that doesn't mean I'm against merging this), as the diff of insta is already quite helpful I think (which seems to correctly display the full buffer minus styling).
You could split the Windows CI fix into a separate PR though.
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.
Snapshotting the buffer includes styles but in a section below the text. So if it unintentionally changes, the test catches it. It's just a bit cumbersome to manually verify whether it's correct.
Printing the buffer was only meant as interactive debugging tool.
I think merging should be fine. It reduces potential merge conflicts.
I'll iterate on it and if I don't get it working properly I'll dump it.
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.
Printing the buffer was only meant as interactive debugging tool.
FWIW I'm using the examples for this (as it directly serves a documentation purpose as well). Long-term automated tests are certainly more robust though...
I think merging should be fine. It reduces potential merge conflicts.
Fine by me, doesn't really introduce much code to maintain anyway.
Another test helper.
This PR depends on #3