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

Print buffer test tool #11

Merged
merged 11 commits into from
Feb 7, 2024
Merged

Conversation

zoechi
Copy link
Contributor

@zoechi zoechi commented Feb 6, 2024

Another test helper.
This PR depends on #3

@zoechi zoechi marked this pull request as draft February 7, 2024 12:36
@zoechi zoechi marked this pull request as ready for review February 7, 2024 14:04
@zoechi
Copy link
Contributor Author

zoechi commented Feb 7, 2024

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).
I hope this change is OK. The exact versions are tracked in the Cargo.lock file anyway for reproducibility.

Copy link
Owner

@Philipp-M Philipp-M left a 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() {
Copy link
Owner

@Philipp-M Philipp-M Feb 7, 2024

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?

Copy link
Contributor Author

@zoechi zoechi Feb 7, 2024

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.

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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.

Copy link
Owner

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.

@Philipp-M Philipp-M merged commit 7d52e43 into Philipp-M:main Feb 7, 2024
7 checks passed
@zoechi zoechi deleted the print_buffer_test_tool branch February 8, 2024 08:44
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.

2 participants