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

Show faulty line in DifferencePredicate #112

Closed
Chewie opened this issue Sep 6, 2021 · 2 comments
Closed

Show faulty line in DifferencePredicate #112

Chewie opened this issue Sep 6, 2021 · 2 comments

Comments

@Chewie
Copy link

Chewie commented Sep 6, 2021

Heya,

The regular assert_eq! macro provides the line containing the assert in its output:

thread 'main' panicked at 'assertion failed:  `(left == right)`
  left: `4`,
 right: `2`, tests/test.rs:112:5

This information can be parsed by editors like Vim to fill the quickfix list automatically and jump to the error, which is very helpful.

Unfortunately, the DifferencePredicate doesn't show this information:

---- test_no_yaml stdout ----
thread 'main' panicked at 'Unexpected stdout, failed diff var original
├── original: No test case found. Exuting.

├── diff: 
--- value	expected
+++ value	actual
@@ -1 +1 @@
-No test case found. Exuting.
+No test case found. Exiting.

└── var as str: No test case found. Exiting.

Would it be possible to add this information to the output?

@Chewie
Copy link
Author

Chewie commented Sep 6, 2021

I've been playing with similar and it's companion similar-asserts as a replacement of differences.rs, and the result is very clean. Maybe the predicate could make use of this crate?

@epage
Copy link
Contributor

epage commented Sep 6, 2021

This crate aims to be the low level mechanism for implementing crates like that, like assert_that or assert_cmd.

To get this functionality, it either needs to come via a macro or the recent https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1460-2020-08-27 attribute

For my crates, I've created assert-rs/assert_cmd#133 and assert-rs/assert_fs#68

@epage epage closed this as completed Sep 6, 2021
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

2 participants