Skip to content

Scope ExUnit diff width tests#15396

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
evadne:feature/test-diff-width
May 15, 2026
Merged

Scope ExUnit diff width tests#15396
josevalim merged 1 commit into
elixir-lang:mainfrom
evadne:feature/test-diff-width

Conversation

@evadne
Copy link
Copy Markdown
Contributor

@evadne evadne commented May 15, 2026

Summary

  • Make ExUnit.DiffTest use :infinity as the default diff formatting width.
  • Add an explicit terminal-width override for tests that exercise display layout.
  • Flatten generated-value expectations for refs and functions so VM-generated inspect strings do not control wrapping.

Context

This follows up on #13954 which changed the test helper to format at 80 columns globally to force-test the inserted/deleted map-in-list formatting. However, this introduced a latent issue in diffs that involve PIDs or Refs that have variable lengths, and such tests may fail intermittently such as in https://github.com/elixir-lang/elixir/actions/runs/25930787536/job/76225550506:

1) test refs (ExUnit.DiffTest)
   test/ex_unit/diff_test.exs:1221
   Assertion with =~ failed
   code:  assert diff_left =~ expected_left
   left:  "{-#Reference<0.134765775.2.103458>-, -#Reference<0.134765775.2.103459>-}"
   right: "{\n  -#Reference<0.134765775.2.103458>-,\n  -#Reference<0.134765775.2.103459>-\n}"
   stacktrace:
     test/ex_unit/diff_test.exs:123: ExUnit.DiffTest.refute_diff/5
     test/ex_unit/diff_test.exs:1233: (test)

This PR keeps that finite-width coverage, but narrows it to deterministic layout assertions:

  • structs with missing keys on match
  • maps in lists
  • structs in lists

Other diff tests default back to :infinity, which makes semantic checks independent from generated inspected values such as refs, pids, and functions.

Tests

  • make test_ex_unit
  • bin/mix format --check-formatted lib/ex_unit/test/ex_unit/diff_test.exs
  • git diff --check

@evadne evadne marked this pull request as ready for review May 15, 2026 21:47
@josevalim josevalim merged commit b58e843 into elixir-lang:main May 15, 2026
15 checks passed
@josevalim
Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants