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

Use ANSI color code to represent added and removed line. #232

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

bjacotg
Copy link
Collaborator

@bjacotg bjacotg commented Jun 16, 2023

By default, the difference summary will color the extra lines. Extra lines in actual will be red while extra line in expected will be blue.

For instance the error from verify_that(vec![1,2,3,4], eq(vec![1,2,5,4])) will look like:

Error: Value of: vec![1, 2, 3, 4]
Expected: is equal to [1, 2, 5, 4]
Actual: [1, 2, 3, 4],
  which isn't equal to [1, 2, 5, 4]
Difference:
 [
     1,
     2,
+    3, // <---- this is in red
-    5, // <---- this is in blue
     4,
 ]

The original behavior (= no color) can still be triggered by setting the environment variable GTEST_RUST_NO_COLOR to any value.

This PR also refactor the summarize logic in its own file summarize_diff.rs

Note: You can comment on github/markup#1440 if you would like to this PR to have nice color instead of comments.

Partial work on #221

@bjacotg bjacotg force-pushed the color-difference branch 4 times, most recently from 3a7250f to 2f84c3c Compare June 30, 2023 08:21
@bjacotg bjacotg force-pushed the color-difference branch from 2f84c3c to 8ed42d0 Compare June 30, 2023 08:25
@copybara-service copybara-service bot merged commit 933c8bc into main Jun 30, 2023
@gribozavr gribozavr deleted the color-difference branch February 17, 2025 18:29
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

Successfully merging this pull request may close these issues.

1 participant