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

FormatTests: use DiffOptions to avoid ANSI #4765

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import scala.concurrent.duration._

import munit.FunSuite
import munit.diff.Diff
import munit.diff.console.AnsiColors

// TODO(olafur) property test: same solution without optimization or timeout.

Expand All @@ -27,6 +26,8 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
lazy val onlyManual = !onlyUnit && ManualTests.tests.exists(_.only)
lazy val onlyOne = tests.exists(_.only)

private val noAnsiDiffOptions = diffOptions.withForceAnsi(Some(false))

override def ignore(t: DiffTest): Boolean = false

override val tests = if (onlyManual) ManualTests.tests else UnitTests.tests
Expand Down Expand Up @@ -115,10 +116,10 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
assertObtained
} else if (code == obtained) assertObtained
else {
val diff = new Diff(code, obtained)
val diff = new Diff(code, obtained, noAnsiDiffOptions)
if (diff.isEmpty) assertObtained
else {
val report = AnsiColors.filterAnsi(diff.createDiffOnlyReport())
val report = diff.createDiffOnlyReport()
val eol = if (report.last == '\n') "" else "\n"
val error = "Idempotency violated\n" + report + eol
if (error != t.expected) failComparison(error, code, obtained)
Expand Down