Skip to content

Regression in pretty-printing diff in ExUnit #12828

@fuelen

Description

@fuelen

Elixir and Erlang/OTP versions

erlang 26.0.2
elixir 1.15.4-otp-26

Operating system

Linux

Current behavior

defmodule MyTest do
  use ExUnit.Case, async: true

  defmodule MyStruct do
    @derive {Inspect, only: []}

    defstruct [:callback_fn]
  end

  test "compare" do
    assert %MyStruct{callback_fn: &String.to_atom/1} == %MyStruct{callback_fn: &String.unknown/1}
  end
end

output with elixir 1.15.4-otp-26: left and right are equal

  1) test compare (MyTest)
     test/my_test.exs:10
     Assertion with == failed
     code:  assert %MyStruct{callback_fn: &String.to_atom/1} == %MyStruct{callback_fn: &String.unknown/1}
     left:  #MyTest.MyStruct<...>
     right: #MyTest.MyStruct<...>
     stacktrace:
       test/my_test.exs:11: (test)

output with elixir 1.14.5-otp-25: left and right are different, diff highlighting is present

  1) test compare (MyTest)
     test/my_test.exs:10
     Assertion with == failed
     code:  assert %MyStruct{callback_fn: &String.to_atom/1} == %MyStruct{callback_fn: &String.unknown/1}
     left:  %MyTest.MyStruct{callback_fn: &String.to_atom/1}
     right: %MyTest.MyStruct{callback_fn: &String.unknown/1}
     stacktrace:
       test/my_test.exs:11: (test)

if I remove @derive {Inspect, only: []} then with elixir 1.15.4-otp-26 output is the same as with 1.14.5-otp-25 but without diff highlighting.

Expected behavior

behaviour from previous version

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions