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

Multi-line diffs still show original strings #387

Open
mgeisler opened this issue Apr 18, 2024 · 0 comments
Open

Multi-line diffs still show original strings #387

mgeisler opened this issue Apr 18, 2024 · 0 comments

Comments

@mgeisler
Copy link
Contributor

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.

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

No branches or pull requests

1 participant