munit icon indicating copy to clipboard operation
munit copied to clipboard

Request: Publish internal difflib as a micro-library

Open zainab-ali opened this issue 2 years ago • 2 comments

Munit's internal difflib is based on a myers diff algorithm to compare strings.

This produces nice user-friendly diffs, even for large multi-line strings.

It would be great to publish it as a separate library so that it can be used with other testing frameworks. For instance, it could be used alongside weaver without needing to pull in the rest of munit:

libraryDependencies += Seq(
    "org.scalameta" %% "munit-diff" % "munit-version", // only pulls in the difflib
    "com.disneystreaming" %% "weaver-cats" % "weaver-version" // weaver as the actual framework
)

What do you think? If this is feasible, I'd be happy to make a PR to achieve it.

zainab-ali avatar Feb 26 '24 11:02 zainab-ali

Thanks for reporting! We've been actually thinking about it since, we do use it in a number of places including Metals and I think scalafmt (or we would want to use it for Scala Native support).

It could even be a separate library altogether:

"org.scalameta" %% "scala-diff" % "version"

I can create a separate repo for it.

tgodzik avatar Feb 26 '24 14:02 tgodzik

@tgodzik, that would be fantastic! Let me know once you've got the repo at hand and I'll happily help port the code over.

zainab-ali avatar Mar 07 '24 13:03 zainab-ali

We discussed this issue offline with @tgodzik and we decided to implement scala-diff as a separate sbt module in munit. I'll pick this one

majk-p avatar Mar 25 '24 11:03 majk-p