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

Output from predicates can be overwhelming with large buffers #106

Open
epage opened this issue May 27, 2021 · 7 comments
Open

Output from predicates can be overwhelming with large buffers #106

epage opened this issue May 27, 2021 · 7 comments
Labels
enhancement Improve the expected question Uncertainty is involved

Comments

@epage
Copy link
Contributor

epage commented May 27, 2021

See assert-rs/assert_cmd#121 for an example

The main question is how to resolve this in a way that is what people expect and works for them.

@epage epage added enhancement Improve the expected question Uncertainty is involved labels May 27, 2021
@epage
Copy link
Contributor Author

epage commented May 27, 2021

I think having a cut off limit with an env variable should do the trick

@ajeetdsouza
Copy link

Putting my suggestion from the linked issue here too -- in the case of a large buffer, it may make sense to indent the whole thing slightly, so it stands out from the actual assertions.

Something like:

expected:
  some multiline output
  indented with
  2 spaces

While skimming through the output, it becomes easy to spot the error messages and differentiate them from the printed buffer.

@epage
Copy link
Contributor Author

epage commented May 29, 2021

This is dependent on the library we use for the tree view because we don't know our indentation level.

We use treeline which doesn't have much activity
https://lib.rs/crates/treeline

ptree also exists but seems a bit ... heavy weight
https://lib.rs/crates/ptree

I'm assuming we'd reach out to treeline and, if they don't respond, will fork it.

@epage
Copy link
Contributor Author

epage commented May 29, 2021

Before I forget, one downside of indenting everything, especially if the tree continues through that indentaton, is its a bit messier to take the output and copy/paste it somewhere.

@ajeetdsouza
Copy link

Perhaps you could output the tree as YAML? YAML has multiline strings, indentation, and is both user and machine readable.

@epage
Copy link
Contributor Author

epage commented May 30, 2021

Its an interesting idea. The main problem is having a yaml generator that gives me control over formatting. Toml ones exist but its harder to find them for Yaml.

For example, with yaml-rust (the core of serde-yaml)

foo:
  bar:
    - 1
    - 2
    - 3
  word: |
    Hello
    World
    How
    Are
    You

Became

---
foo:
  bar:
    - 1
    - 2
    - 3
  word: "Hello\nWorld\nHow\nAre\nYou"

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cd4864755fcd4ef8912ea207d98b0c45

@ajeetdsouza
Copy link

You're right, Rust's YAML support is lacking. If we do this, we'll likely have to do the encoding ourselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected question Uncertainty is involved
Projects
None yet
Development

No branches or pull requests

2 participants