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

Restore newlines when writing Bstrs #161

Merged
merged 5 commits into from
Jan 9, 2023
Merged

Restore newlines when writing Bstrs #161

merged 5 commits into from
Jan 9, 2023

Conversation

smoelius
Copy link
Contributor

Fixes #137 (cc: @tailhook)

I implemented 6 from #137 (comment), since that seemed to be closest in spirit to the code that was already there.

Note: if a piece of text meets both the "too many lines" and "too many bytes" conditions, the former takes precedence, i.e., I display the text by omitting lines rather than bytes. My reasoning is: if a piece of text meets the "too many lines" condition, it is likely to also meet the "too many bytes" condition. In other words, if you didn't do it this way, this enhancement would almost never apply. The downside to this choice is that it could allow really long lines.

src/output.rs Outdated Show resolved Hide resolved
@smoelius
Copy link
Contributor Author

I pushed a commit to address @tailhook's feedback.

Regarding:

I'm thinking many \n can be in binary data too. So It might be good to ensure that there are at least 10 characters on each line or something to have nicely printed output.

I think this point is perfectly valid, but I also think there are a wide range of heuristics that could be applied. So, assuming this feature is merged, maybe it would be better to let people use it first and see how it behaves on real-world data(?).

@tailhook
Copy link
Contributor

Okay. But I also think NewlineRestorer is a bit more complex than needed. Why not format the same as in the "too many lines" case, but don't omit lines?

@smoelius
Copy link
Contributor Author

Why not format the same as in the "too many lines" case, but don't omit lines?

Because I had tunnel vision. :|

How's this?

@tailhook
Copy link
Contributor

Looks good, just two tweaks.

  1. I think we should tweak defaults a bit:

    const LINES_MIN_OVERFLOW: usize = 100;
    const LINES_MAX_START: usize = 25;
    const LINES_MAX_END: usize = 50;  // tail is more likely to contain error in CLI
  2. We probably should have an environment variable like ASSERT_CMD_FULL_OUTPUT to print all the lines.

But now let maintainers of the repo chime in first. /cc @epage

src/output.rs Outdated Show resolved Hide resolved
src/output.rs Outdated Show resolved Hide resolved
src/output.rs Outdated Show resolved Hide resolved
src/output.rs Outdated Show resolved Hide resolved
@smoelius
Copy link
Contributor Author

smoelius commented Jan 7, 2023

  1. We probably should have an environment variable like ASSERT_CMD_FULL_OUTPUT to print all the lines.

@epage Should I implement this?

@epage
Copy link
Contributor

epage commented Jan 9, 2023

  1. We probably should have an environment variable like ASSERT_CMD_FULL_OUTPUT to print all the lines.

@epage Should I implement this?

Considering we elide output today, I would not consider it a blocker for this but something we can discuss in a new issue.

src/output.rs Outdated Show resolved Hide resolved
src/output.rs Outdated Show resolved Hide resolved
src/output.rs Outdated Show resolved Hide resolved
@epage epage merged commit 284fae0 into assert-rs:master Jan 9, 2023
@epage
Copy link
Contributor

epage commented Jan 9, 2023

Thanks!

@smoelius smoelius deleted the restore-newlines branch January 9, 2023 23:00
@smoelius
Copy link
Contributor Author

This feature has significantly improved my quality of life. :) Thanks very much for your feedback and review @tailhook @epage.

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.

stdout/stderr for text processes is ugly
3 participants