assert-rs / predicates-rs

Boolean-valued predicate functions in Rust
docs.rs/predicates
Apache License 2.0
173 stars 29 forks source link

Show diff horizontally aligned? #91

Open sourcefrog opened 4 years ago

sourcefrog commented 4 years ago

The string diffs from predicates are great, but would be easier to read if they started in the same column.

I have this code using assert_fs:

    temp.child("subdir")
        .child("subfile")
        .assert("Must I paint you a picture");

I get this output:

---- transport::local::test::write_file stdout ----
thread 'transport::local::test::write_file' panicked at 'Unexpected file, failed var - original <= 0
└── var - original <= 0
    ├── original: Must I paint you a picture
    ├── actual distance: 2
    ├── diff: Must I paint you a picture
Must I paint you a picture?

    └── var as str: Must I paint you a picture?

I would prefer something like this:

---- transport::local::test::write_file stdout ----
thread 'transport::local::test::write_file' panicked at 'Unexpected file, failed var - original <= 0
└── var - original <= 0
    ├── original: Must I paint you a picture
    ├── actual distance: 2
    ├── diff: 
Must I paint you a picture
Must I paint you a picture?
    └── var as str: Must I paint you a picture?

Meta

predicates-rs version: 1.0.4 rustc --version --verbose:

rustc 1.45.0-beta.3359 (b7dc83a3f 2020-06-03)
binary: rustc
commit-hash: b7dc83a3f6ca9746fb3d121761c3605477b77d90
commit-date: 2020-06-03
host: x86_64-apple-darwin
release: 1.45.0-beta.3359
LLVM version: 10.0