google / google/googletest-rust

Multi-line diffs still show original strings

Open
#387 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
432
Forks
36
Avg merge
7d 17h
Merged PRs (30d)
2

Description

Hello!

I find the multi-line diffs super useful and a main reason to depend on the crate. However, I think they could be made better if they would

- hide the original strings, at least if the strings are very long
- not diff the escaped debug output

Today, I see output like this from AOSP:

```
---- cargo::metadata::tests::parse_metadata stdout ----
thread 'cargo::metadata::tests::parse_metadata' panicked at development/tools/cargo_embargo/src/cargo/metadata.rs:495:13:

Value of: format!("{crates:#?}")
Expected: is equal to "[\n [\n Crate {\n name: \"either\",\n package_name: \"either\",\n version: Some(\n \"1.9.0\",\n ),\n types: [\n Lib,\n ],\n target: Some(\n \"x86_64-unknown-linux-gnu\",\n ),\n features: [\n \"default\",\n \"use_std\",\n ],\n cfgs: [],\n externs: [],\n codegens: [],\n cap_lints: \"\",\n static_libs: [],\n shared_libs: [],\n edition: \"2018\",\n package_dir: \".../external/rust/crates/either\",\n main_src: \"src/lib.rs\",\n empty_test: false,\n },\n Crate {\n name: \"either\",\n package_name: \"either\",\n version: Some(\n \"1.9.0\",\n ),\n types: [\n Test,\n ],\n target: Some(\n \"x86_64-unknown-linux-gnu\",\n ),\n features: [\n \"default\",\n \"use_std\",\n ],\n cfgs: [],\n externs: [\n Extern {\n name: \"serde_json\",\n lib_name: \"serde_json\",\n extern_type: Rust,\n },\n ],\n codegens: [],\n cap_lints: \"\",\n static_libs: [],\n shared_libs: [],\n edition: \"2018\",\n package_dir: \".../external/rust/crates/either\",\n main_src: \"src/lib.rs\",\n empty_test: false,\n },\n ],\n]"
Actual: "[\n [\n Crate {\n name: \"either\",\n package_name: \"either!\",\n version: Some(\n \"1.9.0\",\n ),\n types: [\n Lib,\n ],\n target: Some(\n \"x86_64-unknown-linux-gnu\",\n ),\n features: [\n \"default\",\n \"use_std\",\n ],\n cfgs: [],\n externs: [],\n codegens: [],\n cap_lints: \"\",\n static_libs: [],\n shared_libs: [],\n edition: \"2018\",\n package_dir: \".../external/rust/crates/either\",\n main_src: \"src/lib.rs\",\n empty_test: false,\n },\n Crate {\n name: \"either\",\n package_name: \"either!\",\n version: Some(\n \"1.9.0\",\n ),\n types: [\n Test,\n ],\n target: Some(\n \"x86_64-unknown-linux-gnu\",\n ),\n features: [\n \"default\",\n \"use_std\",\n ],\n cfgs: [],\n externs: [\n Extern {\n name: \"serde_json\",\n lib_name: \"serde_json\",\n extern_type: Rust,\n },\n ],\n codegens: [],\n cap_lints: \"\",\n static_libs: [],\n shared_libs: [],\n edition: \"2018\",\n package_dir: \".../external/rust/crates/either\",\n main_src: \"src/lib.rs\",\n empty_test: false,\n },\n ],\n]",
which isn't equal to "[\n [\n Crate {\n name: \"either\",\n package_name: \"either\",\n version: Some(\n \"1.9.0\",\n ),\n types: [\n Lib,\n ],\n target: Some(\n \"x86_64-unknown-linux-gnu\",\n ),\n features: [\n \"default\",\n \"use_std\",\n ],\n cfgs: [],\n externs: [],\n codegens: [],\n cap_lints: \"\",\n static_libs: [],\n shared_libs: [],\n edition: \"2018\",\n package_dir: \".../external/rust/crates/either\",\n main_src: \"src/lib.rs\",\n empty_test: false,\n },\n Crate {\n name: \"either\",\n package_name: \"either\",\n version: Some(\n \"1.9.0\",\n ),\n types: [\n Test,\n ],\n target: Some(\n \"x86_64-unknown-linux-gnu\",\n ),\n features: [\n \"default\",\n \"use_std\",\n ],\n cfgs: [],\n externs: [\n Extern {\n name: \"serde_json\",\n lib_name: \"serde_json\",\n extern_type: Rust,\n },\n ],\n codegens: [],\n cap_lints: \"\",\n static_libs: [],\n shared_libs: [],\n edition: \"2018\",\n package_dir: \".../external/rust/crates/either\",\n main_src: \"src/lib.rs\",\n empty_test: false,\n },\n ],\n]"
Difference(-actual / +expected):
[
[
Crate {
name: \"either\",
- package_name: \"either!\",
+ package_name: \"either\",
version: Some(
\"1.9.0\",
<---- 22 common lines omitted ---->
Crate {
name: \"either\",
- package_name: \"either!\",
+ package_name: \"either\",
version: Some(
\"1.9.0\",
<---- 28 common lines omitted ---->
],
]
at development/tools/cargo_embargo/src/cargo/metadata.rs:495:13

```

The `\"` in the diff output makes me think that there is some double-escaping going on.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.