lambdaisland / lambdaisland/deep-diff2

Print string-based diff if there's a mismatch of two strings

Open
#50 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Clojure
Stars
326
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I sometimes need to write tests for functions that output strings, in particular multi-line strings. Right now deep-diff2 will just say -<expected-string> +<actual-string>, which isn't very useful for longer strings and strings containing newlines.
Right now I try to work around this by splitting the strings on newlines and letting deep-diff2 diff the arrays, which at least will highlight the lines with changes, but it's not great.

I think it'd be useful to print a string-based diff, like git-diff would, if both expressions for a mismatch are string.

For no newlines they could still be printed in place, but for newlines it likely would make sense to introduce a linebreak and then show the diff without worrying about indentation.

I found deep-diff2.printer-impl/print-mismatch, and (and (string? (:- expr)) (string? (:+ expr))) seems like an easy enough condition there, so I'm playing around with it.

Would you consider this for deep-diff2, or do you see problems with the approach? Perhaps it could be an option to not break any existing consumers.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading deep-diff2.printer-impl/print-mismatch and the existing mismatch-printing behavior. Decide how string-versus-string mismatches should be rendered, including multiline values and whether the behavior needs an option; done means useful git-like output without breaking existing consumers.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.